2015-05-03 08:57:12

by Nicholas Mc Guire

[permalink] [raw]
Subject: [PATCH] genirq: fix unnecessary automatic type conversion

kstat_irqs is unsigned int and the return type of kstat_irqs() is also
unsigned int so sum should be unsigned int as well even if the result
is correct due to automatic type conversion.

Signed-off-by: Nicholas Mc Guire <[email protected]>
---

This also helps make static code checkers happy.

Patch was compile tested with x86_64_defconfig

Patch is against 4.1-rc1 (localversion-next is -next-20150501)

kernel/irq/irqdesc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 996ab1c..73a76e2 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -619,7 +619,7 @@ unsigned int kstat_irqs(unsigned int irq)
{
struct irq_desc *desc = irq_to_desc(irq);
int cpu;
- int sum = 0;
+ unsigned int sum = 0;

if (!desc || !desc->kstat_irqs)
return 0;
--
1.7.10.4


Subject: [tip:irq/core] genirq: Fix unnecessary automatic type conversion

Commit-ID: 5e9662fa511794e1e72baf8eee21238962140480
Gitweb: http://git.kernel.org/tip/5e9662fa511794e1e72baf8eee21238962140480
Author: Nicholas Mc Guire <[email protected]>
AuthorDate: Sun, 3 May 2015 10:48:50 +0200
Committer: Thomas Gleixner <[email protected]>
CommitDate: Tue, 5 May 2015 10:45:58 +0200

genirq: Fix unnecessary automatic type conversion

kstat_irqs is unsigned int and the return type of kstat_irqs() is also
unsigned int so sum should be unsigned int as well even if the result
is correct due to automatic type conversion.

Signed-off-by: Nicholas Mc Guire <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
---
kernel/irq/irqdesc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 99793b9..8228f73 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -619,7 +619,7 @@ unsigned int kstat_irqs(unsigned int irq)
{
struct irq_desc *desc = irq_to_desc(irq);
int cpu;
- int sum = 0;
+ unsigned int sum = 0;

if (!desc || !desc->kstat_irqs)
return 0;