On Wed, Jul 03, 2019 at 10:44:57PM -0700, Michael Forney wrote: > On 2019-07-03, Richard Ipsum <[email protected]> wrote: [snip] > > > > @@ -66,14 +67,21 @@ main(int argc, char *argv[]) > > if (argc < 2) > > usage(); > > > > - errno = 0; > > - if (!(gr = getgrnam(argv[0]))) { > > - if (errno) > > - eprintf("getgrnam %s:", argv[0]); > > - else > > - eprintf("getgrnam %s: no such group\n", argv[0]); > > + group = argv[0]; > > + if (group && *group) { > > I don't think you need to check if group != NULL here, since we know > argc >= 2 at this point. > > Also, do we need to check *group? Is it an error to call getgrnam(3) > with an empty string? I assume it would just fail to find a group.
Forgot to mention that I just took this from chown pretty much. I'm not convinced the checks are needed there either, without the checks you'll just get an error instead of a usage message. Thanks, Richard
