Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 May 2008 09:20:04 GMT
From:      Giorgos Keramidas <keramida@freebsd.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/123807: [patch] timed does not run on arm (incorrect getopt usage)
Message-ID:  <200805260920.m4Q9K4gC055512@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/123807; it has been noted by GNATS.

From: Giorgos Keramidas <keramida@freebsd.org>
To: Matthew Luckie <mjl@luckie.org.nz>
Cc: bug-followup@freebsd.org
Subject: Re: bin/123807: [patch] timed does not run on arm (incorrect getopt usage)
Date: Mon, 26 May 2008 12:09:25 +0300

 On Mon, 19 May 2008 19:26:18 +1200, Matthew Luckie <mjl@luckie.org.nz> wrote:
 > getopt returns an integer, -1 when there is no further options to
 > parse.  char on arm is an unsigned byte value, so it cannot hold -1.
 > therefore the getopt hack to hold the return value in a char and loop
 > on that will fail and leave the application in an infinite loop
 
 > --- patch-timed.c begins here ---
 > --- usr.sbin/timed/timed/timed.c.orig	2003-07-06 22:37:00.000000000 +1200
 > +++ usr.sbin/timed/timed/timed.c	2008-05-19 19:14:26.000000000 +1200
 > @@ -134,7 +134,7 @@ main(argc, argv)
 >  	struct nets *nt;
 >  	struct sockaddr_in server;
 >  	u_short port;
 > -	char c;
 > +	int c;
 >
 >  #ifdef lint
 >  	ntip = NULL;
 > @@ -147,7 +147,7 @@ main(argc, argv)
 >
 >  	opterr = 0;
 >  	while ((c = getopt(argc, argv, "Mtdn:i:F:G:P:")) != -1) {
 > -		switch (c) {
 > +		switch ((char)c) {
 >  		case 'M':
 >  			Mflag = 1;
 >  			break;
 > --- patch-timed.c ends here ---
 
 The first hunk of the patch looks ok, but do we really need the second
 one too?  There are far too many places where an `int' return from
 getopt() is compared with '?'-style characters in switch(), so if we
 don't need it let's not add a cast.
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200805260920.m4Q9K4gC055512>