Re: [PATCH 2/2] hwclock: fix regression from c3ae785

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 18 July 2017, Ruediger Meier wrote:
> On Tuesday 18 July 2017, J William Piggott wrote:
> > hwclock --get foobar
> > hwclock: 3 too many arguments given
> >
> > Fixed:
> >
> > hwclock --get foobar
> > hwclock: 1 too many arguments given
> >
> > Signed-off-by: J William Piggott <elseifthen@xxxxxxx>
> > ---
> >  sys-utils/hwclock.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
> > index 9745158..9b313cf 100644
> > --- a/sys-utils/hwclock.c
> > +++ b/sys-utils/hwclock.c
> > @@ -1448,9 +1448,10 @@ int main(int argc, char **argv)
> >  		}
> >  	}
> >
> > -	if (argc > optind) {
> > +	argc -= optind;
> > +	if (argc > 0) {
> >  		warnx(_("%d too many arguments given"), argc);
>
> Oops, sorry for this regression ;)

BTW I removed

-       argc -= optind;
-       argv += optind;

only where I thought *both* are not used later. In this case I've made a 
mistake. If you really want to keep "argc -= optind" then you could 
also re-add the unused "argv += optind" to avoid confusing other 
code-readers in future. Making the clang-analyzer happy is not the most 
important thing.

> Anyways, at least for me "1 too many arguments given" does not sound
> really understandable.  Maybe we don't need that number at all!?
>
> > -		errtryhelp(EXIT_FAILURE);
> > +		errtryhelp(EX_USAGE);
>
> What about changing also the last other errtryhelp(EXIT_FAILURE) to
> EX_USAGE, 5 lines above?
>
> >  	}
> >
> >  	if (!ctl.adj_file_name)
> > --
> > To unsubscribe from this list: send the line "unsubscribe
> > util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux"
> in the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux