mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	ring-buffer: typecast cmpxchg to fix PowerPC warning
The cmpxchg used by PowerPC does the following:
  ({									 \
     __typeof__(*(ptr)) _o_ = (o);					 \
     __typeof__(*(ptr)) _n_ = (n);					 \
     (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_,		 \
				    (unsigned long)_n_, sizeof(*(ptr))); \
  })
This does a type check of *ptr to both o and n.
Unfortunately, the code in ring-buffer.c assigns longs to pointers
and pointers to longs and causes a warning on PowerPC:
ring_buffer.c: In function 'rb_head_page_set':
ring_buffer.c:704: warning: initialization makes pointer from integer without a cast
ring_buffer.c:704: warning: initialization makes pointer from integer without a cast
ring_buffer.c: In function 'rb_head_page_replace':
ring_buffer.c:797: warning: initialization makes integer from pointer without a cast
This patch adds the typecasts inside cmpxchg to annotate that a long is
being cast to a pointer and a pointer is being casted to a long and this
removes the PowerPC warnings.
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
			
			
This commit is contained in:
		
							parent
							
								
									60ba770227
								
							
						
					
					
						commit
						08a4081617
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -701,7 +701,7 @@ static int rb_head_page_set(struct ring_buffer_per_cpu *cpu_buffer,
 | 
			
		|||
 | 
			
		||||
	val &= ~RB_FLAG_MASK;
 | 
			
		||||
 | 
			
		||||
	ret = (unsigned long)cmpxchg(&list->next,
 | 
			
		||||
	ret = cmpxchg((unsigned long *)&list->next,
 | 
			
		||||
		      val | old_flag, val | new_flag);
 | 
			
		||||
 | 
			
		||||
	/* check if the reader took the page */
 | 
			
		||||
| 
						 | 
				
			
			@ -794,7 +794,7 @@ static int rb_head_page_replace(struct buffer_page *old,
 | 
			
		|||
	val = *ptr & ~RB_FLAG_MASK;
 | 
			
		||||
	val |= RB_PAGE_HEAD;
 | 
			
		||||
 | 
			
		||||
	ret = cmpxchg(ptr, val, &new->list);
 | 
			
		||||
	ret = cmpxchg(ptr, val, (unsigned long)&new->list);
 | 
			
		||||
 | 
			
		||||
	return ret == val;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue