Skip to content

Commit

Permalink
sysctl: use min() helper for namecmp()
Browse files Browse the repository at this point in the history
Make it slightly readable by using min().

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Kees Cook <keescook@chromium.org>
  • Loading branch information
Masahiro Yamada committed Apr 24, 2021
1 parent c3d7ef3 commit d8fc9b6
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions fs/proc/proc_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,9 @@ static void sysctl_print_dir(struct ctl_dir *dir)

static int namecmp(const char *name1, int len1, const char *name2, int len2)
{
int minlen;
int cmp;

minlen = len1;
if (minlen > len2)
minlen = len2;

cmp = memcmp(name1, name2, minlen);
cmp = memcmp(name1, name2, min(len1, len2));
if (cmp == 0)
cmp = len1 - len2;
return cmp;
Expand Down

0 comments on commit d8fc9b6

Please sign in to comment.