]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
lib/bootconfig: use size_t for strlen result in xbc_node_match_prefix()
authorJosh Law <objecting@objecting.org>
Wed, 18 Mar 2026 15:59:16 +0000 (15:59 +0000)
committerMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 18 Mar 2026 23:44:34 +0000 (08:44 +0900)
  lib/bootconfig.c:198:19: warning: conversion from 'size_t' to 'int'
  may change value [-Wconversion]
  lib/bootconfig.c:200:33: warning: conversion to '__kernel_size_t'
  from 'int' may change the sign of the result [-Wsign-conversion]

strlen() returns size_t but the result was stored in an int.  The value
is then passed back to strncmp() which expects size_t, causing a second
sign-conversion warning on the round-trip.  Use size_t throughout to
match the API types.

Link: https://lore.kernel.org/all/20260318155919.78168-11-objecting@objecting.org/
Signed-off-by: Josh Law <objecting@objecting.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
lib/bootconfig.c

index 94ae6662531d577e2ef9ef415e8e72fb20924d00..9f059bb68e4102b2176c8d7c75827302408effa8 100644 (file)
@@ -195,7 +195,7 @@ static bool __init
 xbc_node_match_prefix(struct xbc_node *node, const char **prefix)
 {
        const char *p = xbc_node_get_data(node);
-       int len = strlen(p);
+       size_t len = strlen(p);
 
        if (strncmp(*prefix, p, len))
                return false;