bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/6] kern/lock.h: quiet GCC warnings about set but unused variabl


From: Marin Ramesa
Subject: [PATCH 2/6] kern/lock.h: quiet GCC warnings about set but unused variables
Date: Thu, 12 Dec 2013 18:27:04 +0100

This is a better version of these two patches:

http://lists.gnu.org/archive/html/bug-hurd/2013-12/msg00006.html
http://lists.gnu.org/archive/html/bug-hurd/2013-12/msg00375.html

It uses an empty structure to represent a lock when !MACH_SLOCKS
and a modified simple_unlock() to quiet GCC warnings about set
but unused variables.

* kern/lock.h (l): Define.
(decl_simple_lock_data): Likewise.
(simple_unlock): Likewise.
* kern/sched_prim.c [!MACH_SLOCKS] (lock): Declare.
* kern/task.c (task_info) (task_unlock) (task): Remove address operator.

---
 kern/lock.h       | 9 ++++++---
 kern/sched_prim.c | 6 ++++++
 kern/task.c       | 2 +-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/kern/lock.h b/kern/lock.h
index 4f38ea3..a4e4d10 100644
--- a/kern/lock.h
+++ b/kern/lock.h
@@ -94,7 +94,10 @@ extern void          check_simple_locks(void);
 /*
  * Do not allocate storage for locks if not needed.
  */
-#define        decl_simple_lock_data(class,name)
+struct l {};
+#define        decl_simple_lock_data(class,name) \
+class struct l name;
+
 #define        simple_lock_addr(lock)          ((simple_lock_t)0)
 
 /*
@@ -102,8 +105,8 @@ extern void         check_simple_locks(void);
  */
 #define simple_lock_init(l)
 #define simple_lock(l)
-#define simple_unlock(l)
-#define simple_lock_try(l)     (TRUE)  /* always succeeds */
+#define simple_unlock(l) ((void)(l))
+#define simple_lock_try(l) (TRUE)      /* always succeeds */
 #define simple_lock_taken(l)   (1)     /* always succeeds */
 #define check_simple_locks()
 #define simple_lock_pause()
diff --git a/kern/sched_prim.c b/kern/sched_prim.c
index c06cd77..71f32c5 100644
--- a/kern/sched_prim.c
+++ b/kern/sched_prim.c
@@ -228,6 +228,8 @@ void assert_wait(
        thread_t                thread;
 #if    MACH_SLOCKS
        simple_lock_t           lock;
+#else /* MACH_SLOCKS */
+       decl_simple_lock_data( , lock);
 #endif /* MACH_SLOCKS */
        spl_t                   s;
 
@@ -286,6 +288,8 @@ void clear_wait(
        queue_t                 q;
 #if    MACH_SLOCKS
        simple_lock_t           lock;
+#else /* MACH_SLOCKS */
+       decl_simple_lock_data( , lock);
 #endif /* MACH_SLOCKS */
        event_t                 event;
        spl_t                   s;
@@ -389,6 +393,8 @@ void thread_wakeup_prim(
        thread_t                thread, next_th;
 #if    MACH_SLOCKS
        simple_lock_t           lock;
+#else /* MACH_SLOCKS */
+       decl_simple_lock_data( , lock);
 #endif  /* MACH_SLOCKS */
        spl_t                   s;
        int                     state;
diff --git a/kern/task.c b/kern/task.c
index 8fe3672..67067cf 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -769,7 +769,7 @@ kern_return_t task_info(
                event_info->cow_faults = task->cow_faults;
                event_info->messages_sent = task->messages_sent;
                event_info->messages_received = task->messages_received;
-               task_unlock(&task);
+               task_unlock(task);
 
                *task_info_count = TASK_EVENTS_INFO_COUNT;
                break;
-- 
1.8.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]