All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <jesper.juhl@gmail.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [RFC][expample patch] Make the kernel -Wshadow clean ?
Date: Thu, 15 Dec 2005 00:19:57 +0100	[thread overview]
Message-ID: <200512150019.57124.jesper.juhl@gmail.com> (raw)

Hi,

Variables shadowing eachother have a nasty potential to contain hard to 
discover bugs, so I propose we clean that up.

There are *lots* of cases of variable shadowing in the kernel and real bugs 
could be lurking in there.

I'm full willing to audit every single case and clean them up, but before I 
begin such a task I want to "test the waters".

So to get things started I give you the patch below that cleans up

784 counts of
include/linux/jiffies.h:331: warning: declaration of 'jiffies' shadows a global declaration

784 counts of
include/linux/jiffies.h:369: warning: declaration of 'jiffies' shadows a global declaration

30 counts of
include/linux/usb.h:877: warning: declaration of 'complete' shadows a global declaration

30 counts of
include/linux/usb.h:908: warning: declaration of 'complete' shadows a global declaration

30 counts of
include/linux/usb.h:943: warning: declaration of 'complete' shadows a global declaration

1 count of
mm/swap.c:42: warning: declaration of 'page' shadows a parameter


So with just one simple patch we've nuked 1659 -Wshadow warnings out of a total
of 2403 that this build of mine generated with my regular .config
Of course I picked some of the easy targets to start with, a lot of the 
remaining ones are cases of 1-10 identical warnings generated by one instance.

Anyway, I think this is a worthwhile task and I'm willing to do it and we may 
even discover/fix real bugs along the way, so what do you say?

Comments are very welcome as always, and feel free to merge this patch as a 
starting point if you agree that this is something that ought to be done.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 include/linux/jiffies.h |    8 ++++----
 include/linux/usb.h     |   12 ++++++------
 mm/swap.c               |    2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

--- linux-2.6.15-rc5-git4-orig/include/linux/jiffies.h	2005-10-28 02:02:08.000000000 +0200
+++ linux-2.6.15-rc5-git4/include/linux/jiffies.h	2005-12-14 22:52:07.000000000 +0100
@@ -328,13 +328,13 @@ timespec_to_jiffies(const struct timespe
 }
 
 static __inline__ void
-jiffies_to_timespec(const unsigned long jiffies, struct timespec *value)
+jiffies_to_timespec(const unsigned long jiff, struct timespec *value)
 {
 	/*
 	 * Convert jiffies to nanoseconds and separate with
 	 * one divide.
 	 */
-	u64 nsec = (u64)jiffies * TICK_NSEC;
+	u64 nsec = (u64)jiff * TICK_NSEC;
 	value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec);
 }
 
@@ -366,13 +366,13 @@ timeval_to_jiffies(const struct timeval 
 }
 
 static __inline__ void
-jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
+jiffies_to_timeval(const unsigned long jiff, struct timeval *value)
 {
 	/*
 	 * Convert jiffies to nanoseconds and separate with
 	 * one divide.
 	 */
-	u64 nsec = (u64)jiffies * TICK_NSEC;
+	u64 nsec = (u64)jiff * TICK_NSEC;
 	value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_usec);
 	value->tv_usec /= NSEC_PER_USEC;
 }
--- linux-2.6.15-rc5-git4-orig/include/linux/usb.h	2005-12-04 18:48:51.000000000 +0100
+++ linux-2.6.15-rc5-git4/include/linux/usb.h	2005-12-14 23:57:09.000000000 +0100
@@ -874,7 +874,7 @@ static inline void usb_fill_control_urb 
 					 unsigned char *setup_packet,
 					 void *transfer_buffer,
 					 int buffer_length,
-					 usb_complete_t complete,
+					 usb_complete_t comp,
 					 void *context)
 {
 	spin_lock_init(&urb->lock);
@@ -883,7 +883,7 @@ static inline void usb_fill_control_urb 
 	urb->setup_packet = setup_packet;
 	urb->transfer_buffer = transfer_buffer;
 	urb->transfer_buffer_length = buffer_length;
-	urb->complete = complete;
+	urb->complete = comp;
 	urb->context = context;
 }
 
@@ -905,7 +905,7 @@ static inline void usb_fill_bulk_urb (st
 				      unsigned int pipe,
 				      void *transfer_buffer,
 				      int buffer_length,
-				      usb_complete_t complete,
+				      usb_complete_t comp,
 				      void *context)
 {
 	spin_lock_init(&urb->lock);
@@ -913,7 +913,7 @@ static inline void usb_fill_bulk_urb (st
 	urb->pipe = pipe;
 	urb->transfer_buffer = transfer_buffer;
 	urb->transfer_buffer_length = buffer_length;
-	urb->complete = complete;
+	urb->complete = comp;
 	urb->context = context;
 }
 
@@ -940,7 +940,7 @@ static inline void usb_fill_int_urb (str
 				     unsigned int pipe,
 				     void *transfer_buffer,
 				     int buffer_length,
-				     usb_complete_t complete,
+				     usb_complete_t comp,
 				     void *context,
 				     int interval)
 {
@@ -949,7 +949,7 @@ static inline void usb_fill_int_urb (str
 	urb->pipe = pipe;
 	urb->transfer_buffer = transfer_buffer;
 	urb->transfer_buffer_length = buffer_length;
-	urb->complete = complete;
+	urb->complete = comp;
 	urb->context = context;
 	if (dev->speed == USB_SPEED_HIGH)
 		urb->interval = 1 << (interval - 1);
--- linux-2.6.15-rc5-git4-orig/mm/swap.c	2005-12-04 18:48:54.000000000 +0100
+++ linux-2.6.15-rc5-git4/mm/swap.c	2005-12-14 23:04:28.000000000 +0100
@@ -39,7 +39,7 @@ void put_page(struct page *page)
 	if (unlikely(PageCompound(page))) {
 		page = (struct page *)page_private(page);
 		if (put_page_testzero(page)) {
-			void (*dtor)(struct page *page);
+			void (*dtor)(struct page *pge);
 
 			dtor = (void (*)(struct page *))page[1].mapping;
 			(*dtor)(page);




             reply	other threads:[~2005-12-14 23:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-14 23:19 Jesper Juhl [this message]
2005-12-14 23:22 ` [RFC][expample patch] Make the kernel -Wshadow clean ? Russell King
2005-12-14 23:24   ` Jesper Juhl
2005-12-14 23:26   ` Randy.Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200512150019.57124.jesper.juhl@gmail.com \
    --to=jesper.juhl@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.