From owner-freebsd-bugs@FreeBSD.ORG Mon May 26 09:20:04 2008 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD9FF106566B for ; Mon, 26 May 2008 09:20:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 9C9618FC29 for ; Mon, 26 May 2008 09:20:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m4Q9K4ht055513 for ; Mon, 26 May 2008 09:20:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m4Q9K4gC055512; Mon, 26 May 2008 09:20:04 GMT (envelope-from gnats) Date: Mon, 26 May 2008 09:20:04 GMT Message-Id: <200805260920.m4Q9K4gC055512@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Cc: Subject: Re: bin/123807: [patch] timed does not run on arm (incorrect getopt usage) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 May 2008 09:20:04 -0000 The following reply was made to PR bin/123807; it has been noted by GNATS. From: Giorgos Keramidas To: Matthew Luckie 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 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.