drivers/can: Fix gcc-8 warning about improper string concatenation
PATCH 1/1 drivers/can: Fix gcc-8 warning about improper string concatenation
From: Jan Kiszka <[email protected]>
The compiler correctly remarks that strncat was used with the target buffer size as input, ignoring the required space for the terminating \0 - not to speak of the fact the we did this two times in a row.
Signed-off-by Jan Kiszka <[email protected]>
--- kernel/drivers/can/rtcan_module.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/drivers/can/rtcan_module.c +3 -5
@@ -47,11 +47,9 @@ struct proc_dir_entry *rtcan_proc_root;static void rtcan_dev_get_ctrlmode_name (can_ctrlmode_t ctrlmode,char * name,int max_len) { - *name ='\0' ; -if (ctrlmode &CAN_CTRLMODE_LISTENONLY ) -strncat (name,"listen-only " , max_len); -if (ctrlmode &CAN_CTRLMODE_LOOPBACK ) -strncat (name,"loopback " , max_len); +snprintf (name, max_len,"%s%s" , + ctrlmode &CAN_CTRLMODE_LISTENONLY ?"listen-only " :"" , + ctrlmode &CAN_CTRLMODE_LOOPBACK ?"loopback " :"" ); }static char *rtcan_state_names[] = {
Signature · 1 line
2.16.4