From owner-freebsd-current Fri Jul 20 17:18:35 2001 Delivered-To: freebsd-current@freebsd.org Received: from Veronica.wmol.com (veronica.wmol.com [208.242.83.241]) by hub.freebsd.org (Postfix) with ESMTP id 8ED3737B401 for ; Fri, 20 Jul 2001 17:18:30 -0700 (PDT) (envelope-from david@phobia.ms) Received: from rain.hill.hom (081bc122.chartermi.net [24.247.81.122]) by Veronica.wmol.com (Vircom SMTPRS 4.6.189) with ESMTP id for ; Fri, 20 Jul 2001 20:16:21 -0400 Date: Fri, 20 Jul 2001 20:18:04 -0400 From: David Hill To: current@freebsd.org Subject: usr.bin/write/write.c patch Message-Id: <20010720201804.5491b17c.david@phobia.ms> X-Mailer: Sylpheed version 0.5.1 (GTK+ 1.2.10; i386-unknown-freebsd5.0) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart_Fri__20_Jul_2001_20:18:04_-0400_0811e600" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --Multipart_Fri__20_Jul_2001_20:18:04_-0400_0811e600 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hello - I patched up write.c a bit. 1. Constified 2. Changed a strncpy to strlcpy 3. change S_IWRITE >> 3 to S_IWGRP 4. Changed fileno(stdin/stdout/stderr) to STD*_FILENO 5. cleaned up 2 pieces of code so it will compile when WARNS=2 is set. The patch is attached, and can be found at http://www.phobia.ms/patches/write.c.20072001.diff Any comments? - David Hill --Multipart_Fri__20_Jul_2001_20:18:04_-0400_0811e600 Content-Type: application/octet-stream; name="write.c.20072001.diff" Content-Disposition: attachment; filename="write.c.20072001.diff" Content-Transfer-Encoding: base64 KioqIC91c3Ivc3JjL3Vzci5iaW4vd3JpdGUvd3JpdGUuYy5vcmlnCUZyaSBBdWcgMjcgMjE6MDc6 NDggMTk5OQotLS0gL3Vzci9zcmMvdXNyLmJpbi93cml0ZS93cml0ZS5jCUZyaSBKdWwgMjAgMjA6 MDU6NDQgMjAwMQoqKioqKioqKioqKioqKioKKioqIDY0LDc1ICoqKioKICAjaW5jbHVkZSA8dXRt cC5oPgogIAogIHZvaWQgZG9uZSBfX1AoKGludCkpOwohIHZvaWQgZG9fd3JpdGUgX19QKChjaGFy ICosIGNoYXIgKiwgdWlkX3QpKTsKICBzdGF0aWMgdm9pZCB1c2FnZSBfX1AoKHZvaWQpKTsKISBp bnQgdGVybV9jaGsgX19QKChjaGFyICosIGludCAqLCB0aW1lX3QgKiwgaW50KSk7CiAgdm9pZCB3 cl9mcHV0cyBfX1AoKHVuc2lnbmVkIGNoYXIgKnMpKTsKISB2b2lkIHNlYXJjaF91dG1wIF9fUCgo Y2hhciAqLCBjaGFyICosIGNoYXIgKiwgdWlkX3QpKTsKISBpbnQgdXRtcF9jaGsgX19QKChjaGFy ICosIGNoYXIgKikpOwogIAogIGludAogIG1haW4oYXJnYywgYXJndikKLS0tIDY0LDc1IC0tLS0K ICAjaW5jbHVkZSA8dXRtcC5oPgogIAogIHZvaWQgZG9uZSBfX1AoKGludCkpOwohIHZvaWQgZG9f d3JpdGUgX19QKChjb25zdCBjaGFyICosIGNvbnN0IGNoYXIgKiwgdWlkX3QpKTsKICBzdGF0aWMg dm9pZCB1c2FnZSBfX1AoKHZvaWQpKTsKISBpbnQgdGVybV9jaGsgX19QKChjb25zdCBjaGFyICos IGludCAqLCB0aW1lX3QgKiwgaW50KSk7CiAgdm9pZCB3cl9mcHV0cyBfX1AoKHVuc2lnbmVkIGNo YXIgKnMpKTsKISB2b2lkIHNlYXJjaF91dG1wIF9fUCgoY29uc3QgY2hhciAqLCBjb25zdCBjaGFy ICosIGNoYXIgKiwgdWlkX3QpKTsKISBpbnQgdXRtcF9jaGsgX19QKChjb25zdCBjaGFyICosIGNv bnN0IGNoYXIgKikpOwogIAogIGludAogIG1haW4oYXJnYywgYXJndikKKioqKioqKioqKioqKioq CioqKiA4NSw5Ni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ljaGFyIHBhdGhb TUFYUEFUSExFTl0sIGhvc3RbTUFYSE9TVE5BTUVMRU5dLCBsaW5lWzUxMl07Ci0tLSAyNTAsMjYw IC0tLS0KICAgKi8KICB2b2lkCiAgZG9fd3JpdGUodHR5LCBteXR0eSwgbXl1aWQpCiEgCWNvbnN0 IGNoYXIgKnR0eSwgKm15dHR5OwogIAl1aWRfdCBteXVpZDsKICB7CiEgCXJlZ2lzdGVyIGNoYXIg Y29uc3QgKmxvZ2luOwohIAlyZWdpc3RlciBjaGFyICpub3dzOwogIAlyZWdpc3RlciBzdHJ1Y3Qg cGFzc3dkICpwd2Q7CiAgCXRpbWVfdCBub3c7CiAgCWNoYXIgcGF0aFtNQVhQQVRITEVOXSwgaG9z dFtNQVhIT1NUTkFNRUxFTl0sIGxpbmVbNTEyXTsKKioqKioqKioqKioqKioqCioqKiAyOTMsMjk4 ICoqKioKLS0tIDI5NCwzMDAgLS0tLQogIGRvbmUobikKICBpbnQgbjsgIC8qIHNpZ25hbCBudW1i ZXIgKi8KICB7CisgCW4gPSAwOwogIAkodm9pZClwcmludGYoIkVPRlxyXG4iKTsKICAJZXhpdCgw KTsKICB9Cg== --Multipart_Fri__20_Jul_2001_20:18:04_-0400_0811e600-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message