[igt-dev] [i-g-t,2/7] runner: make the usage function variadic

Knop, Ryszard ryszard.knop at intel.com
Thu Jun 30 13:16:56 UTC 2022


On Tue, 2022-06-28 at 20:51 -0300, Maíra Canal wrote:
> On 6/28/22 11:44, Ryszard Knop wrote:
> > For easier error logging, make the usage() function variadic and
> > pass
> > its arguments to vfprintf. Additionally, reorder its arguments so
> > that
> > it visually matches all the printf functions.
> > 
> > Signed-off-by: Ryszard Knop <ryszard.knop at intel.com>
> > ---
> 
> Hi,
> 
> Overall this looks good, just a small typo.
> 
> > @@ -806,24 +808,19 @@ bool serialize_settings(struct settings
> > *settings)
> >  
> >         if (!settings->overwrite &&
> >             faccessat(dirfd, settings_filename, F_OK, 0) == 0) {
> > -               usage("Settings metadata already exists and not
> > overwriting", stderr);
> > +               usage(stderr, "Settings metadata already exists and
> > not overwriting");
> >                 return false;
> >         }
> >  
> >         if (settings->overwrite &&
> >             unlinkat(dirfd, settings_filename, 0) != 0 &&
> >             errno != ENOENT) {
> > -               usage("Error removing old settings metadata",
> > stderr);
> > +               usage(stderr, "Error removing old settings
> > metadata");
> >                 return false;
> >         }
> >  
> >         if ((fd = openat(dirfd, settings_filename, O_CREAT | O_EXCL
> > | O_WRONLY, 0666)) < 0) {
> > -               char *msg;
> > -
> > -               asprintf(&msg, "Creating settings serialization
> > file failed: %s", strerror(errno));
> > -               usage(msg, stderr);
> > -
> > -               free(msg);
> > +               usage(msg, "Creating settings serialization file
> > failed: %s", strerror(errno));
> 
> I believe this should be:
>     usage(stderr, "Creating settings serialization file failed: %s",
> strerror(errno));

That's right, sorry, missed this one while splitting the patch.

Thanks, Ryszard

> 
> Reviewed-by: Maíra Canal <maira.canal at usp.br>
> 
> Best Regards,
> - Maíra Canal
> 
> >                 close(dirfd);
> >                 return false;
> >   }



More information about the igt-dev mailing list