Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lib/bootconfig: change xbc_node_index() return type to uint16_t

lib/bootconfig.c:136:21: warning: conversion from 'long int' to
'int' may change value [-Wconversion]
lib/bootconfig.c:308:33: warning: conversion from 'int' to 'uint16_t'
may change value [-Wconversion]
lib/bootconfig.c:467:37: warning: conversion from 'int' to 'uint16_t'
may change value [-Wconversion]
lib/bootconfig.c:469:40: warning: conversion from 'int' to 'uint16_t'
may change value [-Wconversion]
lib/bootconfig.c:472:54: warning: conversion from 'int' to 'uint16_t'
may change value [-Wconversion]
lib/bootconfig.c:476:45: warning: conversion from 'int' to 'uint16_t'
may change value [-Wconversion]

xbc_node_index() returns the position of a node in the xbc_nodes array,
which has at most XBC_NODE_MAX (8192) entries, well within uint16_t
range. Every caller stores the result in a uint16_t field (node->parent,
node->child, node->next, or the keys[] array in compose_key_after), so
the int return type causes narrowing warnings at all six call sites.

Change the return type to uint16_t and add an explicit cast on the
pointer subtraction to match the storage width and eliminate the
warnings.

Link: https://lore.kernel.org/all/20260318155919.78168-14-objecting@objecting.org/

Signed-off-by: Josh Law <objecting@objecting.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

authored by

Josh Law and committed by
Masami Hiramatsu (Google)
6eb255d0 05213e4b

+3 -3
+1 -1
include/linux/bootconfig.h
··· 66 66 67 67 /* Node tree access raw APIs */ 68 68 struct xbc_node * __init xbc_root_node(void); 69 - int __init xbc_node_index(struct xbc_node *node); 69 + uint16_t __init xbc_node_index(struct xbc_node *node); 70 70 struct xbc_node * __init xbc_node_get_parent(struct xbc_node *node); 71 71 struct xbc_node * __init xbc_node_get_child(struct xbc_node *node); 72 72 struct xbc_node * __init xbc_node_get_next(struct xbc_node *node);
+2 -2
lib/bootconfig.c
··· 131 131 * 132 132 * Return the index number of @node in XBC node list. 133 133 */ 134 - int __init xbc_node_index(struct xbc_node *node) 134 + uint16_t __init xbc_node_index(struct xbc_node *node) 135 135 { 136 - return node - &xbc_nodes[0]; 136 + return (uint16_t)(node - &xbc_nodes[0]); 137 137 } 138 138 139 139 /**