Skip to contentSkip to conversation

ring_buffer: fix warning

PATCH Superseded Lai Jiangshan 3 participants 6 messages Jul 14, 2009 – Jul 16, 2009

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

PATCH 1/1 ring_buffer: fix warning

kernel/trace/ring_buffer.c: In function 'rb_tail_page_update':
kernel/trace/ring_buffer.c:849: warning: value computed is not used kernel/trace/ring_buffer.c:850: warning: value computed is not used

Add a "(void)" to fix this warning.

---

kernel/trace/ring_buffer.c +2 -2
index e648ba4..d371279 100644
@@ -846,8 +846,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
 		 * not come in and change it. In which case, we
 		 * do not want to modify it.
 		 */
-		local_cmpxchg(&next_page->write, old_write, val);
-		local_cmpxchg(&next_page->entries, old_entries, eval);
+		(void)local_cmpxchg(&next_page->write, old_write, val);
+		(void)local_cmpxchg(&next_page->entries, old_entries, eval);
 
 		/*
 		 * No need to worry about races with clearing out the commit.
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Lai Jiangshan

kernel/trace/ring_buffer.c: In function 'rb_tail_page_update':
kernel/trace/ring_buffer.c:849: warning: value computed is not used kernel/trace/ring_buffer.c:850: warning: value computed is not used

Add a "(void)" to fix this warning.

---

kernel/trace/ring_buffer.c +0 -0
index e648ba4..d371279 100644

kernel/trace/ring_buffer.c static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer, · line 853

Quoted 10 lines
kernel/trace/ring_buffer.c +2 -2
@@ -846,8 +846,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
 		 * not come in and change it. In which case, we
 		 * do not want to modify it.
 		 */
-		local_cmpxchg(&next_page->write, old_write, val);
-		local_cmpxchg(&next_page->entries, old_entries, eval);
+		(void)local_cmpxchg(&next_page->write, old_write, val);
+		(void)local_cmpxchg(&next_page->entries, old_entries, eval);
 
 		/*
 		 * No need to worry about races with clearing out the commit.

Looks good. Indeed the rest of the path remains the same, whether the interrupts have already won the race or not.

maintainer Acked-by
#2 lore raw
Quoted 23 lines · Frederic Weisbecker
Quoted 22 lines · Lai Jiangshan

kernel/trace/ring_buffer.c: In function 'rb_tail_page_update':
kernel/trace/ring_buffer.c:849: warning: value computed is not used kernel/trace/ring_buffer.c:850: warning: value computed is not used

Add a "(void)" to fix this warning.

---

kernel/trace/ring_buffer.c +2 -2
index e648ba4..d371279 100644
@@ -846,8 +846,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
 		 * not come in and change it. In which case, we
 		 * do not want to modify it.
 		 */
-		local_cmpxchg(&next_page->write, old_write, val);
-		local_cmpxchg(&next_page->entries, old_entries, eval);
+		(void)local_cmpxchg(&next_page->write, old_write, val);
+		(void)local_cmpxchg(&next_page->entries, old_entries, eval);
 
Quoted 6 lines

kernel/trace/ring_buffer.c static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer, · line 853

Quoted 2 lines
kernel/trace/ring_buffer.c +0 -0
 		/*
 		 * No need to worry about races with clearing out the commit.

Looks good. Indeed the rest of the path remains the same, whether the interrupts have already won the race or not.

Yes, but it needs a comment:

/*
* We add (void) to let the compiler know that we do not care
* about the return value of these functions. We use the
* cmpxchg to only update if an interrupt did not already
* do it for us. If the cmpxchg fails, we don't care. */

Then you can have my:

-- Steve

Quoted 4 lines
#3 lore raw

Re: [PATCH -tip] ring_buffer: fix warning (V2)

In reply to Lai Jiangshan

kernel/trace/ring_buffer.c: In function 'rb_tail_page_update':
kernel/trace/ring_buffer.c:849: warning: value computed is not used kernel/trace/ring_buffer.c:850: warning: value computed is not used

Add "(void)"s to fix this warning.

Changed from V1:
Add a comment(which is written by Steven) for it.

---

kernel/trace/ring_buffer.c +7 -2
index e648ba4..51633d7 100644
@@ -845,9 +845,14 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
 		 * This will only succeed if an interrupt did
 		 * not come in and change it. In which case, we
 		 * do not want to modify it.
+		 *
+		 * We add (void) to let the compiler know that we do not care
+		 * about the return value of these functions. We use the
+		 * cmpxchg to only update if an interrupt did not already
+		 * do it for us. If the cmpxchg fails, we don't care.
 		 */
-		local_cmpxchg(&next_page->write, old_write, val);
-		local_cmpxchg(&next_page->entries, old_entries, eval);
+		(void)local_cmpxchg(&next_page->write, old_write, val);
+		(void)local_cmpxchg(&next_page->entries, old_entries, eval);
 
 		/*
 		 * No need to worry about races with clearing out the commit.
#4 lore raw

PATCH v2 1/1 ring_buffer: fix warning

Sorry for missing Reviewed-by and Acked-by, so I resend it.

Subject: [PATCH -tip V2] ring_buffer: fix warning

kernel/trace/ring_buffer.c: In function 'rb_tail_page_update':
kernel/trace/ring_buffer.c:849: warning: value computed is not used kernel/trace/ring_buffer.c:850: warning: value computed is not used

Add "(void)"s to fix this warning.

Changed from V1:
Add a comment(which is written by Steven) for it.

---

kernel/trace/ring_buffer.c +7 -2
index e648ba4..51633d7 100644
@@ -845,9 +845,14 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
 		 * This will only succeed if an interrupt did
 		 * not come in and change it. In which case, we
 		 * do not want to modify it.
+		 *
+		 * We add (void) to let the compiler know that we do not care
+		 * about the return value of these functions. We use the
+		 * cmpxchg to only update if an interrupt did not already
+		 * do it for us. If the cmpxchg fails, we don't care.
 		 */
-		local_cmpxchg(&next_page->write, old_write, val);
-		local_cmpxchg(&next_page->entries, old_entries, eval);
+		(void)local_cmpxchg(&next_page->write, old_write, val);
+		(void)local_cmpxchg(&next_page->entries, old_entries, eval);
 
 		/*
 		 * No need to worry about races with clearing out the commit.
#5 lore raw
Quoted 8 lines · Lai Jiangshan

Sorry for missing Reviewed-by and Acked-by, so I resend it.

Subject: [PATCH -tip V2] ring_buffer: fix warning

kernel/trace/ring_buffer.c: In function 'rb_tail_page_update':
kernel/trace/ring_buffer.c:849: warning: value computed is not used kernel/trace/ring_buffer.c:850: warning: value computed is not used

Quoted 8 lines

Add "(void)"s to fix this warning.

Changed from V1:
Add a comment(which is written by Steven) for it.

Queued for .32, thanks!

Quoted 23 lines

---

kernel/trace/ring_buffer.c +7 -2
index e648ba4..51633d7 100644
@@ -845,9 +845,14 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
 		 * This will only succeed if an interrupt did
 		 * not come in and change it. In which case, we
 		 * do not want to modify it.
+		 *
+		 * We add (void) to let the compiler know that we do not care
+		 * about the return value of these functions. We use the
+		 * cmpxchg to only update if an interrupt did not already
+		 * do it for us. If the cmpxchg fails, we don't care.
 		 */
-		local_cmpxchg(&next_page->write, old_write, val);
-		local_cmpxchg(&next_page->entries, old_entries, eval);
+		(void)local_cmpxchg(&next_page->write, old_write, val);
+		(void)local_cmpxchg(&next_page->entries, old_entries, eval);
 
 		/*
 		 * No need to worry about races with clearing out the commit.