[PATCH v2] kernel/irq/proc.c: set MAX_NAMELEN 11 instead of 10 anduse "%u" instead of "%d" for printing 'irq'

From: Chen Gang
Date: Mon Oct 07 2013 - 06:48:23 EST


Theoretically, the maximize size of "%u" is 11 (10 + '\0'), so need set
MAX_NAMELEN 11 instead of 10, and also 'irq' is unsigned int, so need
use "%u" instead of "%d".

In real world, it may not cause issue, but still recommend to fix the
'theoretical' bugs (especially original definition already considered
about 'theoretical' using).


Signed-off-by: Chen Gang <gang.chen@xxxxxxxxxxx>
---
kernel/irq/proc.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 36f6ee1..efda701 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -305,7 +305,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)

#undef MAX_NAMELEN

-#define MAX_NAMELEN 10
+#define MAX_NAMELEN 11

void register_irq_proc(unsigned int irq, struct irq_desc *desc)
{
@@ -315,7 +315,7 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
return;

memset(name, 0, MAX_NAMELEN);
- sprintf(name, "%d", irq);
+ sprintf(name, "%u", irq);

/* create /proc/irq/1234 */
desc->dir = proc_mkdir(name, root_irq_dir);
--
1.7.7.6
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/