On Tue, Jul 19, 2022 at 10:19 AM Martin KaFai Lau <kafai@xxxxxx> wrote: > > On Tue, Jul 19, 2022 at 12:53:01PM +0300, Dan Carpenter wrote: > > The return from strcmp() is inverted so the it returns true instead > > of false and vise versa. > > > > Fixes: a1c9d61b19cb ("libbpf: Improve library identification for uprobe binary path resolution") > > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > > --- > > Spotted during review. *cmp() functions should always have a comparison > > to zero. > > if (strcmp(a, b) < 0) { <-- means a < b > > if (strcmp(a, b) >= 0) { <-- means a >= b > > if (strcmp(a, b) != 0) { <-- means a != b > > etc. > > > > tools/lib/bpf/libbpf_internal.h | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h > > index 9cd7829cbe41..008485296a29 100644 > > --- a/tools/lib/bpf/libbpf_internal.h > > +++ b/tools/lib/bpf/libbpf_internal.h > > @@ -108,9 +108,9 @@ static inline bool str_has_sfx(const char *str, const char *sfx) > > size_t str_len = strlen(str); > > size_t sfx_len = strlen(sfx); > > > > - if (sfx_len <= str_len) > > - return strcmp(str + str_len - sfx_len, sfx); > > - return false; > > + if (sfx_len > str_len) > > + return false; > > + return strcmp(str + str_len - sfx_len, sfx) == 0; > Please tag the subject with "bpf" next time. > > Acked-by: Martin KaFai Lau <kafai@xxxxxx> Alan, If it was so broken how did it work earlier? Do we have a test for this?