From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, martin.lau@linux.dev, kernel-team@fb.com,
yonghong.song@linux.dev, laoar.shao@gmail.com,
mykyta.yatsenko5@gmail.com
Subject: Re: [PATCH bpf-next v2 1/1] selftests/bpf: more precise cpu_mitigations state detection
Date: Mon, 16 Jun 2025 14:27:12 -0700 [thread overview]
Message-ID: <d92b2e43d7710624deaf10a9919cdfa45ee91bdb.camel@gmail.com> (raw)
In-Reply-To: <CAEf4BzYh38ZW5x_tttT7qGSPbUtT4SLC7F+aoE_cymkV5q59hw@mail.gmail.com>
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.
[...]
next prev parent reply other threads:[~2025-06-16 21:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-14 5:06 [PATCH bpf-next v2 0/1] selftests/bpf: more precise cpu_mitigations state detection Eduard Zingerman
2025-06-14 5:06 ` [PATCH bpf-next v2 1/1] " Eduard Zingerman
2025-06-15 2:18 ` Yafang Shao
2025-06-16 21:13 ` Andrii Nakryiko
2025-06-16 21:27 ` Eduard Zingerman [this message]
2025-06-16 23:36 ` Andrii Nakryiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d92b2e43d7710624deaf10a9919cdfa45ee91bdb.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=laoar.shao@gmail.com \
--cc=martin.lau@linux.dev \
--cc=mykyta.yatsenko5@gmail.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox