[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87pn3uwjrd.fsf@toke.dk>
Date: Mon, 30 Nov 2020 23:40:54 +0100
From: Toke Høiland-Jørgensen <toke@...hat.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Daniel Borkmann <daniel@...earbox.net>,
Alexei Starovoitov <ast@...com>,
Andrii Nakryiko <andrii@...nel.org>, bpf <bpf@...r.kernel.org>,
Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf] libbpf: reset errno after probing kernel features
Andrii Nakryiko <andrii.nakryiko@...il.com> writes:
> On Mon, Nov 30, 2020 at 7:42 AM Toke Høiland-Jørgensen <toke@...hat.com> wrote:
>>
>> The kernel feature probing results in 'errno' being set if the probing
>> fails (as is often the case). This can stick around and leak to the caller,
>> which can lead to confusion later. So let's make sure we always reset errno
>> after calling a probe function.
>
> What specifically is the problem and what sort of confusion we are
> talking about here? You are not supposed to check errno, unless the
> function returned -1 or other error result.
>
> In some cases, you have to reset errno manually just to avoid
> confusion (see how strtol() is used, as an example).
>
> I.e., I don't see the problem here, any printf() technically can set
> errno to <0, we don't reset errno after each printf call though,
> right?
Well yeah, technically things work fine in the common case. But this
errno thing sent me on quite the wild goose chase when trying to find
the root cause of the pinning issue I also sent a patch for...
So since reseting errno doesn't hurt either I figured I'd save others
ending up in similar trouble. If it's not to your taste feel free to
just drop the patch :)
-Toke
Powered by blists - more mailing lists