mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	locking/ww_mutex/test: Use swap() macro
Fixes the following Coccinelle/coccicheck warning reported by swap.cocci: WARNING opportunity for swap() Compile-tested only. [Boqun: Add the report tags from Jiapeng and Abaci Robot [1].] Reported-by: Abaci Robot <abaci@linux.alibaba.com> Reported-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=11531 Link: https://lore.kernel.org/r/20241025081455.55089-1-jiapeng.chong@linux.alibaba.com [1] Acked-by: Waiman Long <longman@redhat.com> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://lore.kernel.org/r/20240731135850.81018-2-thorsten.blum@toblux.com
This commit is contained in:
		
							parent
							
								
									63a48181fb
								
							
						
					
					
						commit
						0d3547df69
					
				
					 1 changed files with 3 additions and 6 deletions
				
			
		|  | @ -404,7 +404,7 @@ static inline u32 prandom_u32_below(u32 ceil) | ||||||
| static int *get_random_order(int count) | static int *get_random_order(int count) | ||||||
| { | { | ||||||
| 	int *order; | 	int *order; | ||||||
| 	int n, r, tmp; | 	int n, r; | ||||||
| 
 | 
 | ||||||
| 	order = kmalloc_array(count, sizeof(*order), GFP_KERNEL); | 	order = kmalloc_array(count, sizeof(*order), GFP_KERNEL); | ||||||
| 	if (!order) | 	if (!order) | ||||||
|  | @ -415,11 +415,8 @@ static int *get_random_order(int count) | ||||||
| 
 | 
 | ||||||
| 	for (n = count - 1; n > 1; n--) { | 	for (n = count - 1; n > 1; n--) { | ||||||
| 		r = prandom_u32_below(n + 1); | 		r = prandom_u32_below(n + 1); | ||||||
| 		if (r != n) { | 		if (r != n) | ||||||
| 			tmp = order[n]; | 			swap(order[n], order[r]); | ||||||
| 			order[n] = order[r]; |  | ||||||
| 			order[r] = tmp; |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return order; | 	return order; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Thorsten Blum
						Thorsten Blum