Skip to content

Commit 1ac9aa4

Browse files
jlabundydtor
authored andcommitted
Input: iqs626a - replace snprintf() with scnprintf()
W=1 builds warn that the data written to 'tc_name' is truncated for theoretical strings such as "channel-2147483646". Solve this problem by replacing snprintf() with scnprintf() so that the return value corresponds to what was actually written. In practice, the largest string that will be written is "channel-8", and the return value is not actually evaluated. Instead, this patch ultimately removes the warning without unnecessarily increasing the size of 'tc_name' from 10 bytes. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202412221136.0S4kRoCC-lkp@intel.com/ Signed-off-by: Jeff LaBundy <jeff@labundy.com> Link: https://lore.kernel.org/r/Z3rV8GTHxLyjBQ5I@nixie71 Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 4f97860 commit 1ac9aa4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/input/misc/iqs626a.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ static int iqs626_parse_trackpad(struct iqs626_private *iqs626,
771771
u8 *thresh = &sys_reg->tp_grp_reg.ch_reg_tp[i].thresh;
772772
char tc_name[10];
773773

774-
snprintf(tc_name, sizeof(tc_name), "channel-%d", i);
774+
scnprintf(tc_name, sizeof(tc_name), "channel-%d", i);
775775

776776
struct fwnode_handle *tc_node __free(fwnode_handle) =
777777
fwnode_get_named_child_node(ch_node, tc_name);

0 commit comments

Comments
 (0)