Skip to content

Commit

Permalink
generic swap(): don't return a value from swap()
Browse files Browse the repository at this point in the history
The swap() macro is accidentally retuning the value of its first argument.
Change it into a doesn't-return-anything macro before someone goes and
relies upon this behaviour.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wu Fengguang <wfg@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Peter Zijlstra authored and Linus Torvalds committed Feb 5, 2009
1 parent c073b2d commit ac7b900
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
/*
* swap - swap value of @a and @b
*/
#define swap(a, b) ({ typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; })
#define swap(a, b) \
do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)

/**
* container_of - cast a member of a structure out to the containing structure
Expand Down

0 comments on commit ac7b900

Please sign in to comment.