From owner-freebsd-arch@FreeBSD.ORG Tue Aug 24 04:03:34 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D616B16A4CE; Tue, 24 Aug 2004 04:03:34 +0000 (GMT) Received: from rosebud.otenet.gr (rosebud.otenet.gr [195.170.0.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 938C043D45; Tue, 24 Aug 2004 04:03:31 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-b136.otenet.gr [212.205.244.144]) i7O43RqZ023351; Tue, 24 Aug 2004 07:03:28 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id i7O426XF029849; Tue, 24 Aug 2004 07:02:06 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id i7O426uJ029848; Tue, 24 Aug 2004 07:02:06 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Tue, 24 Aug 2004 07:02:06 +0300 From: Giorgos Keramidas To: John Baldwin Message-ID: <20040824040206.GA28962@gothmog.gr> References: <20040821191659.GA94336@gothmog.gr> <20040821202252.GB94336@gothmog.gr> <200408231141.25077.jhb@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200408231141.25077.jhb@FreeBSD.org> Phone: +30-2610-312145 Mobile: +30-6944-116520 cc: freebsd-arch@freebsd.org Subject: Re: Introducing a poweroff(8) command X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2004 04:03:35 -0000 On 2004-08-23 11:41, John Baldwin wrote: > On Saturday 21 August 2004 04:22 pm, Giorgos Keramidas wrote: > > --- reboot.c 9 Apr 2004 19:58:35 -0000 1.20 > > +++ reboot.c 17 Aug 2004 21:55:57 -0000 > > @@ -70,9 +70,13 @@ > > char *kernel, *p; > > const char *user; > > > > - if (strstr((p = rindex(*argv, '/')) ? p + 1 : *argv, "halt")) { > > + p = rindex(*argv, '/') ? p + 1 : *argv; > > + if (strcmp(p, "halt") == 0) { > > I think this is buggy in that p will point to the / character since you don't > modify it in the second case. I.e. what you wrote is basically this: > > p = rindex(*argv, '/'); > if (p != NULL) > p + 1; /* does nothing */ > else > *argv; /* also does nothing */ True. I think I'll have to write this as this: > p = rindex(argv[0], '/'); > if (p != NULL) > p++; > else > p = argv[0]; Thanks for spotting this :-)