Skip to content

Commit d49e7d0

Browse files
committed
Input: serio-raw - fix potential serio port name truncation
When compiling with W=1 the following warnings are triggered: drivers/input/serio/serio_raw.c: In function ‘serio_raw_connect’: drivers/input/serio/serio_raw.c:303:28: error: ‘%ld’ directive output may be truncated writing between 1 and 11 bytes into a region of size 7 [-Werror=format-truncation=] 303 | "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no)); atomic_inc_return() returns an int, so there is no reason to cast it to long and print as such. Fix the issue by removing the cast, printing it as unsigned decimal, and expanding the name from 16 to 20 bytes to accommodate the largest possible port number. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 5b53a9d commit d49e7d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/input/serio/serio_raw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct serio_raw {
2929
unsigned char queue[SERIO_RAW_QUEUE_LEN];
3030
unsigned int tail, head;
3131

32-
char name[16];
32+
char name[20];
3333
struct kref kref;
3434
struct serio *serio;
3535
struct miscdevice dev;
@@ -277,7 +277,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
277277
}
278278

279279
snprintf(serio_raw->name, sizeof(serio_raw->name),
280-
"serio_raw%ld", (long)atomic_inc_return(&serio_raw_no));
280+
"serio_raw%u", atomic_inc_return(&serio_raw_no));
281281
kref_init(&serio_raw->kref);
282282
INIT_LIST_HEAD(&serio_raw->client_list);
283283
init_waitqueue_head(&serio_raw->wait);

0 commit comments

Comments
 (0)