Skip to contentSkip to conversation

-Wshadow: variables named 'up' clash with up()

RFC PATCH In review Jesper Juhl 2 participants 3 messages Jul 10, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 5/9 -Wshadow: variables named 'up' clash with up()

(please see the mail titled
"[RFC][PATCH 0/9] -Wshadow: Making the kernel build clean with -Wshadow" for an explanation of why I'm doing this)

Fix -Wshadow warnings related to variables of the name 'up' clashing with the global function name up().
(this patch fixes only those occurences that show up for allnoconfig)

---

 drivers/char/vt_ioctl.c |   60 +++++++++++++++++++-------------------
 fs/select.c             |    6 +--
 kernel/user.c           |   42 +++++++++++++-------------
 3 files changed, 54 insertions(+), 54 deletions(-)
kernel/user.c +21 -21
@@ -56,24 +56,24 @@ struct user_struct root_user = {
 /*
  * These routines must be called with the uidhash spinlock held!
  */
-static inline void uid_hash_insert(struct user_struct *up, struct list_head *hashent)
+static inline void uid_hash_insert(struct user_struct *_up, struct list_head *hashent)
 {
-	list_add(&up->uidhash_list, hashent);
+	list_add(&_up->uidhash_list, hashent);
 }
 
-static inline void uid_hash_remove(struct user_struct *up)
+static inline void uid_hash_remove(struct user_struct *_up)
 {
-	list_del(&up->uidhash_list);
+	list_del(&_up->uidhash_list);
 }
 
 static inline struct user_struct *uid_hash_find(uid_t uid, struct list_head *hashent)
 {
-	struct list_head *up;
+	struct list_head *_up;
 
-	list_for_each(up, hashent) {
+	list_for_each(_up, hashent) {
 		struct user_struct *user;
 
-		user = list_entry(up, struct user_struct, uidhash_list);
+		user = list_entry(_up, struct user_struct, uidhash_list);
 
 		if(user->uid == uid) {
 			atomic_inc(&user->__count);
@@ -101,20 +101,20 @@ struct user_struct *find_user(uid_t uid)
 	return ret;
 }
 
-void free_uid(struct user_struct *up)
+void free_uid(struct user_struct *_up)
 {
 	unsigned long flags;
 
-	if (!up)
+	if (!_up)
 		return;
 
 	local_irq_save(flags);
-	if (atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
-		uid_hash_remove(up);
+	if (atomic_dec_and_lock(&_up->__count, &uidhash_lock)) {
+		uid_hash_remove(_up);
 		spin_unlock_irqrestore(&uidhash_lock, flags);
-		key_put(up->uid_keyring);
-		key_put(up->session_keyring);
-		kmem_cache_free(uid_cachep, up);
+		key_put(_up->uid_keyring);
+		key_put(_up->session_keyring);
+		kmem_cache_free(uid_cachep, _up);
 	} else {
 		local_irq_restore(flags);
 	}
@@ -123,13 +123,13 @@ void free_uid(struct user_struct *up)
 struct user_struct * alloc_uid(uid_t uid)
 {
 	struct list_head *hashent = uidhashentry(uid);
-	struct user_struct *up;
+	struct user_struct *_up;
 
 	spin_lock_irq(&uidhash_lock);
-	up = uid_hash_find(uid, hashent);
+	_up = uid_hash_find(uid, hashent);
 	spin_unlock_irq(&uidhash_lock);
 
-	if (!up) {
+	if (!_up) {
 		struct user_struct *new;
 
 		new = kmem_cache_alloc(uid_cachep, SLAB_KERNEL);
@@ -158,19 +158,19 @@ struct user_struct * alloc_uid(uid_t uid
 		 * on adding the same user already..
 		 */
 		spin_lock_irq(&uidhash_lock);
-		up = uid_hash_find(uid, hashent);
-		if (up) {
+		_up = uid_hash_find(uid, hashent);
+		if (_up) {
 			key_put(new->uid_keyring);
 			key_put(new->session_keyring);
 			kmem_cache_free(uid_cachep, new);
 		} else {
 			uid_hash_insert(new, hashent);
-			up = new;
+			_up = new;
 		}
 		spin_unlock_irq(&uidhash_lock);
 
 	}
-	return up;
+	return _up;
 }
 
 void switch_uid(struct user_struct *new_user)
fs/select.c +3 -3
@@ -524,17 +524,17 @@ asmlinkage long sys_pselect6(int n, fd_s
 	fd_set __user *exp, struct timespec __user *tsp, void __user *sig)
 {
 	size_t sigsetsize = 0;
-	sigset_t __user *up = NULL;
+	sigset_t __user *_up = NULL;
 
 	if (sig) {
 		if (!access_ok(VERIFY_READ, sig, sizeof(void *)+sizeof(size_t))
-		    || __get_user(up, (sigset_t __user * __user *)sig)
+		    || __get_user(_up, (sigset_t __user * __user *)sig)
 		    || __get_user(sigsetsize,
 				(size_t __user *)(sig+sizeof(void *))))
 			return -EFAULT;
 	}
 
-	return sys_pselect7(n, inp, outp, exp, tsp, up, sigsetsize);
+	return sys_pselect7(n, inp, outp, exp, tsp, _up, sigsetsize);
 }
 #endif /* TIF_RESTORE_SIGMASK */
 
drivers/char/vt_ioctl.c +30 -30

204 lines not on this page · raw message

#1 lore raw

kernel/user.c struct user_struct root_user = { · line 60

Quoted 3 lines
kernel/user.c +1 -1
-static inline void uid_hash_insert(struct user_struct *up, struct list_head *hashent)
+static inline void uid_hash_insert(struct user_struct *_up, struct list_head *hashent)
 {

Please never use such ugly names. A simply 'u' as variable name would do it instead in most places.

#2 lore raw
Quoted 7 lines · Christoph Hellwig

kernel/user.c struct user_struct root_user = { · line 60

Quoted 3 lines
kernel/user.c +1 -1
-static inline void uid_hash_insert(struct user_struct *up, struct list_head *hashent)
+static inline void uid_hash_insert(struct user_struct *_up, struct list_head *hashent)
 {

Please never use such ugly names. A simply 'u' as variable name would do it instead in most places.

Ok, will do.
Thank you for the feedback.

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html