bin/123807: [patch] timed does not run on arm (incorrect getopt
usage)
Giorgos Keramidas
keramida at freebsd.org
Mon May 26 09:20:04 UTC 2008
The following reply was made to PR bin/123807; it has been noted by GNATS.
From: Giorgos Keramidas <keramida at freebsd.org>
To: Matthew Luckie <mjl at luckie.org.nz>
Cc: bug-followup at 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 at 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.
More information about the freebsd-bugs
mailing list