bin/54123: [patch] fix assignments of getopt() return values to
char variables
Stefan Farfeleder
stefan at fafoe.narf.at
Sat Jul 5 03:40:20 PDT 2003
>Number: 54123
>Category: bin
>Synopsis: [patch] fix assignments of getopt() return values to char variables
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Jul 05 03:40:17 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Stefan Farfeleder
>Release: FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD frog.fafoe.narf.at 5.1-CURRENT FreeBSD 5.1-CURRENT #19: Fri Jul 4 14:44:41 CEST 2003 freebsd at frog.fafoe.narf.at:/freebsd/frog/obj/freebsd/frog/src/sys/FROG i386
>Description:
The diff in the Fix section changes all occurrences of
char ch; ch = getopt()
I found in the tree into
int ch; ch = getopt().
On architectures like the PowerPC with an unsigned char as plain char the -1
return value from getopt() will be wrapped to UCHAR_MAX otherwise and the
comparison with -1 will always fail.
>How-To-Repeat:
>Fix:
--- getopt.diff begins here ---
Index: src/usr.sbin/edquota/edquota.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.sbin/edquota/edquota.c,v
retrieving revision 1.20
diff -u -r1.20 edquota.c
--- src/usr.sbin/edquota/edquota.c 3 May 2003 21:06:36 -0000 1.20
+++ src/usr.sbin/edquota/edquota.c 4 Jul 2003 16:32:01 -0000
@@ -107,8 +107,8 @@
int i, quotatype, range, tmpfd;
uid_t startuid, enduid;
u_int32_t *limp;
- char *protoname, *cp, *oldoptarg, ch;
- int eflag = 0, tflag = 0, pflag = 0;
+ char *protoname, *cp, *oldoptarg;
+ int eflag = 0, tflag = 0, pflag = 0, ch;
char *fspath = NULL;
char buf[30];
Index: src/usr.sbin/getfmac/getfmac.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.sbin/getfmac/getfmac.c,v
retrieving revision 1.1
diff -u -r1.1 getfmac.c
--- src/usr.sbin/getfmac/getfmac.c 23 Oct 2002 03:15:23 -0000 1.1
+++ src/usr.sbin/getfmac/getfmac.c 4 Jul 2003 16:36:15 -0000
@@ -58,9 +58,9 @@
int
main(int argc, char *argv[])
{
- char ch, *labellist, *string;
+ char *labellist, *string;
mac_t label;
- int hflag;
+ int ch, hflag;
int error, i;
labellist = NULL;
Index: src/usr.sbin/getpmac/getpmac.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.sbin/getpmac/getpmac.c,v
retrieving revision 1.1
diff -u -r1.1 getpmac.c
--- src/usr.sbin/getpmac/getpmac.c 23 Oct 2002 03:15:23 -0000 1.1
+++ src/usr.sbin/getpmac/getpmac.c 4 Jul 2003 16:43:00 -0000
@@ -57,10 +57,10 @@
int
main(int argc, char *argv[])
{
- char ch, *labellist, *string;
+ char *labellist, *string;
mac_t label;
pid_t pid;
- int error, pid_set;
+ int ch, error, pid_set;
pid_set = 0;
pid = 0;
Index: src/usr.sbin/mixer/mixer.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.sbin/mixer/mixer.c,v
retrieving revision 1.20
diff -u -r1.20 mixer.c
--- src/usr.sbin/mixer/mixer.c 15 Jun 2003 08:46:04 -0000 1.20
+++ src/usr.sbin/mixer/mixer.c 4 Jul 2003 16:46:36 -0000
@@ -93,7 +93,7 @@
int l = 0, r = 0, t = 0;
char lstr[5], rstr[5];
int n = 0, lrel = 0, rrel = 0;
- char ch;
+ int ch;
char *name;
Index: src/usr.sbin/quotaon/quotaon.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.sbin/quotaon/quotaon.c,v
retrieving revision 1.8
diff -u -r1.8 quotaon.c
--- src/usr.sbin/quotaon/quotaon.c 3 May 2003 21:06:39 -0000 1.8
+++ src/usr.sbin/quotaon/quotaon.c 4 Jul 2003 16:52:07 -0000
@@ -80,9 +80,9 @@
main(int argc, char **argv)
{
register struct fstab *fs;
- char ch, *qfnp, *whoami;
+ char *qfnp, *whoami;
long argnum, done = 0;
- int i, offmode = 0, errs = 0;
+ int ch, i, offmode = 0, errs = 0;
whoami = rindex(*argv, '/') + 1;
if (whoami == (char *)1)
Index: src/usr.sbin/repquota/repquota.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.sbin/repquota/repquota.c,v
retrieving revision 1.15
diff -u -r1.15 repquota.c
--- src/usr.sbin/repquota/repquota.c 3 May 2003 21:06:39 -0000 1.15
+++ src/usr.sbin/repquota/repquota.c 4 Jul 2003 16:52:22 -0000
@@ -111,7 +111,8 @@
register struct group *gr;
int gflag = 0, uflag = 0, errs = 0;
long i, argnum, done = 0;
- char ch, *qfnp;
+ char *qfnp;
+ int ch;
while ((ch = getopt(argc, argv, "aguv")) != -1) {
switch(ch) {
Index: src/usr.sbin/sa/main.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.sbin/sa/main.c,v
retrieving revision 1.13
diff -u -r1.13 main.c
--- src/usr.sbin/sa/main.c 3 May 2003 21:06:40 -0000 1.13
+++ src/usr.sbin/sa/main.c 4 Jul 2003 16:52:39 -0000
@@ -81,7 +81,7 @@
int
main(int argc, char **argv)
{
- char ch;
+ int ch;
char pathacct[] = _PATH_ACCT;
int error = 0;
Index: src/usr.sbin/watch/watch.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.sbin/watch/watch.c,v
retrieving revision 1.28
diff -u -r1.28 watch.c
--- src/usr.sbin/watch/watch.c 3 May 2003 21:06:41 -0000 1.28
+++ src/usr.sbin/watch/watch.c 4 Jul 2003 16:53:09 -0000
@@ -283,9 +283,9 @@
int
main(int ac, char *av[])
{
- int res, rv, nread;
+ int ch, res, rv, nread;
size_t b_size = MIN_SIZE;
- char ch, *buf, chb[READB_LEN];
+ char *buf, chb[READB_LEN];
fd_set fd_s;
(void) setlocale(LC_TIME, "");
Index: src/usr.bin/locale/locale.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.bin/locale/locale.c,v
retrieving revision 1.10
diff -u -r1.10 locale.c
--- src/usr.bin/locale/locale.c 26 Jun 2003 11:05:56 -0000 1.10
+++ src/usr.bin/locale/locale.c 4 Jul 2003 16:17:54 -0000
@@ -211,7 +211,7 @@
int
main(int argc, char *argv[])
{
- char ch;
+ int ch;
int tmp;
while ((ch = getopt(argc, argv, "ackm")) != -1) {
Index: src/usr.bin/quota/quota.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.bin/quota/quota.c,v
retrieving revision 1.20
diff -u -r1.20 quota.c
--- src/usr.bin/quota/quota.c 15 Jun 2003 06:54:36 -0000 1.20
+++ src/usr.bin/quota/quota.c 4 Jul 2003 16:54:48 -0000
@@ -115,7 +115,7 @@
int ngroups;
gid_t mygid, gidset[NGROUPS];
int i, gflag = 0, uflag = 0;
- char ch;
+ int ch;
while ((ch = getopt(argc, argv, "glquv")) != -1) {
switch(ch) {
Index: src/usr.bin/showmount/showmount.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.bin/showmount/showmount.c,v
retrieving revision 1.13
diff -u -r1.13 showmount.c
--- src/usr.bin/showmount/showmount.c 12 Oct 2002 05:45:01 -0000 1.13
+++ src/usr.bin/showmount/showmount.c 4 Jul 2003 16:55:20 -0000
@@ -117,7 +117,7 @@
register struct exportslist *exp;
register struct grouplist *grp;
register int rpcs = 0, mntvers = 1;
- char ch;
+ int ch;
const char *host;
int estat;
Index: src/usr.bin/uuencode/uuencode.c
===================================================================
RCS file: /usr/home/ncvs/src/usr.bin/uuencode/uuencode.c,v
retrieving revision 1.17
diff -u -r1.17 uuencode.c
--- src/usr.bin/uuencode/uuencode.c 3 May 2003 19:44:46 -0000 1.17
+++ src/usr.bin/uuencode/uuencode.c 4 Jul 2003 16:25:47 -0000
@@ -77,7 +77,7 @@
{
struct stat sb;
int base64;
- char ch;
+ int ch;
char *outfile;
base64 = 0;
Index: src/sbin/devfs/devfs.c
===================================================================
RCS file: /usr/home/ncvs/src/sbin/devfs/devfs.c,v
retrieving revision 1.4
diff -u -r1.4 devfs.c
--- src/sbin/devfs/devfs.c 29 Jul 2002 17:09:21 -0000 1.4
+++ src/sbin/devfs/devfs.c 4 Jul 2003 15:42:29 -0000
@@ -59,7 +59,7 @@
{
const char *mountpt;
struct cmd *c;
- char ch;
+ int ch;
mountpt = NULL;
while ((ch = getopt(ac, av, "m:")) != -1)
Index: src/sbin/devfs/rule.c
===================================================================
RCS file: /usr/home/ncvs/src/sbin/devfs/rule.c,v
retrieving revision 1.4
diff -u -r1.4 rule.c
--- src/sbin/devfs/rule.c 28 Jul 2002 06:59:40 -0000 1.4
+++ src/sbin/devfs/rule.c 4 Jul 2003 15:47:43 -0000
@@ -82,7 +82,7 @@
rule_main(int ac, char **av)
{
struct cmd *c;
- char ch;
+ int ch;
setprogname("devfs rule");
optreset = optind = 1;
Index: src/sbin/ffsinfo/ffsinfo.c
===================================================================
RCS file: /usr/home/ncvs/src/sbin/ffsinfo/ffsinfo.c,v
retrieving revision 1.5
diff -u -r1.5 ffsinfo.c
--- src/sbin/ffsinfo/ffsinfo.c 21 Aug 2002 18:10:14 -0000 1.5
+++ src/sbin/ffsinfo/ffsinfo.c 4 Jul 2003 16:57:03 -0000
@@ -141,7 +141,7 @@
{
DBG_FUNC("main")
char *device, *special, *cp;
- char ch;
+ int ch;
size_t len;
struct stat st;
struct disklabel *lp;
Index: src/sbin/growfs/growfs.c
===================================================================
RCS file: /usr/home/ncvs/src/sbin/growfs/growfs.c,v
retrieving revision 1.15
diff -u -r1.15 growfs.c
--- src/sbin/growfs/growfs.c 12 May 2003 05:37:16 -0000 1.15
+++ src/sbin/growfs/growfs.c 4 Jul 2003 16:57:12 -0000
@@ -1933,7 +1933,7 @@
{
DBG_FUNC("main")
char *device, *special, *cp;
- char ch;
+ int ch;
unsigned int size=0;
size_t len;
unsigned int Nflag=0;
Index: src/sbin/mdmfs/mdmfs.c
===================================================================
RCS file: /usr/home/ncvs/src/sbin/mdmfs/mdmfs.c,v
retrieving revision 1.13
diff -u -r1.13 mdmfs.c
--- src/sbin/mdmfs/mdmfs.c 3 May 2003 18:41:58 -0000 1.13
+++ src/sbin/mdmfs/mdmfs.c 4 Jul 2003 16:03:29 -0000
@@ -93,7 +93,8 @@
bool have_mdtype;
bool detach, softdep, autounit;
char *mtpoint, *unitstr;
- char ch, *p;
+ int ch;
+ char *p;
/* Misc. initialization. */
(void)memset(&mi, '\0', sizeof(mi));
Index: src/sbin/quotacheck/quotacheck.c
===================================================================
RCS file: /usr/home/ncvs/src/sbin/quotacheck/quotacheck.c,v
retrieving revision 1.21
diff -u -r1.21 quotacheck.c
--- src/sbin/quotacheck/quotacheck.c 3 May 2003 18:41:59 -0000 1.21
+++ src/sbin/quotacheck/quotacheck.c 4 Jul 2003 16:12:16 -0000
@@ -152,7 +152,8 @@
struct quotaname *auxdata;
int i, argnum, maxrun, errs;
long done = 0;
- char ch, *name;
+ int ch;
+ char *name;
errs = maxrun = 0;
while ((ch = getopt(argc, argv, "aguvl:")) != -1) {
--- getopt.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list