lkml.org 
[lkml]   [2013]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH v2] kernel/irq/proc.c: set MAX_NAMELEN 11 instead of 10 and use "%u" instead of "%d" for printing 'irq'
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@asianux.com>
---
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

\
 
 \ /
  Last update: 2013-10-07 13:21    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog