Skip to content

Commit 47af06c

Browse files
andy-shevKAGA-KOKO
authored andcommitted
genirq: Consistently use '%u' format specifier for unsigned int variables
There are three cases in the genirq code when the irq, as an unsigned integer variable, is converted to text representation by sprintf(). In two cases it uses '%d' specifier which is for signed values. While it's not a problem right now, potentially it might be in the future in case too big (> INT_MAX) number will appear there. Consistently use '%u' format specifier for @irq which is declared as unsigned int in all these cases. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20250509154643.1499171-1-andriy.shevchenko@linux.intel.com
1 parent b5fcb68 commit 47af06c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

kernel/irq/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
230230
if (!irq_dir || !desc || desc->debugfs_file)
231231
return;
232232

233-
sprintf(name, "%d", irq);
233+
sprintf(name, "%u", irq);
234234
desc->debugfs_file = debugfs_create_file(name, 0644, irq_dir, desc,
235235
&dfs_irq_ops);
236236
}

kernel/irq/proc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static bool name_unique(unsigned int irq, struct irqaction *new_action)
309309

310310
void register_handler_proc(unsigned int irq, struct irqaction *action)
311311
{
312-
char name [MAX_NAMELEN];
312+
char name[MAX_NAMELEN];
313313
struct irq_desc *desc = irq_to_desc(irq);
314314

315315
if (!desc->dir || action->dir || !action->name || !name_unique(irq, action))
@@ -345,7 +345,7 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
345345
return;
346346

347347
/* create /proc/irq/1234 */
348-
sprintf(name, "%d", irq);
348+
sprintf(name, "%u", irq);
349349
desc->dir = proc_mkdir(name, root_irq_dir);
350350
if (!desc->dir)
351351
return;

0 commit comments

Comments
 (0)