Re: [PATCH bpf-next v2 1/1] selftests/bpf: more precise cpu_mitigations state detection

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

 



On Mon, 2025-06-16 at 14:13 -0700, Andrii Nakryiko wrote:

[...]

> > +static int config_contains(const char *pat)
> 
> int-returning function... but we return do `ret = true;`, that looks
> accidental and sloppy. Let's add a comment that it returns <0 on
> error, 0 for no match, 1 for match and stick to numbers everywhere?

It was actually intentional but ok, I can change that.

> > +{
> > +       int n, err, ret = -1;
> > +       const char *msg;
> > +       char buf[1024];
> > +       gzFile config;
> > +
> > +       config = open_config();
> > +       if (!config)
> > +               goto out;
> 
> nothing to gzclose if open_config() returns NULL, just return
> 
> pw-bot: cr
> 
> > +
> > +       for (;;) {
> > +               if (!gzgets(config, buf, sizeof(buf))) {
> > +                       msg = gzerror(config, &err);
> > +                       if (err == Z_ERRNO)
> > +                               perror("gzgets /proc/config.gz");
> > +                       else if (err != Z_OK)
> > +                               fprintf(stderr, "gzgets /proc/config.gz: %s", msg);
> > +                       goto out;
> 
> nit: I'd probably just do
> 
> gzclose(config);
> return -EINVAL; (or whatever the error code might be)

I'll make this change just to avoid arguing but don't understand why tbh.

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux