Message ID | 80d5d60030f9f4c0d299e139597f67c562f1d6b2.1636092427.git.yang.guang5@zte.com.cn |
---|---|
State | Accepted |
Headers | show |
Series | [v2] um: use swap() to make code cleaner | expand |
From: Yang Guang > Sent: 05 November 2021 06:19 > > Use the macro 'swap()' defined in 'include/linux/minmax.h' to avoid > opencoding it. Is there any real point to any of these patches?? If I'm reading a 'random' piece of code I now have to assume that swap() is something that 'magically' exchanges two items. This requires more brain-power than parsing the three lines that do an actual swap. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c index 9e71794839e8..37d60e72cf26 100644 --- a/arch/um/os-Linux/sigio.c +++ b/arch/um/os-Linux/sigio.c @@ -3,6 +3,7 @@ * Copyright (C) 2002 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com) */ +#include <linux/minmax.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> @@ -50,7 +51,7 @@ static struct pollfds all_sigio_fds; static int write_sigio_thread(void *unused) { - struct pollfds *fds, tmp; + struct pollfds *fds; struct pollfd *p; int i, n, respond_fd; char c; @@ -77,9 +78,7 @@ static int write_sigio_thread(void *unused) "write_sigio_thread : " "read on socket failed, " "err = %d\n", errno); - tmp = current_poll; - current_poll = next_poll; - next_poll = tmp; + swap(current_poll, next_poll); respond_fd = sigio_private[1]; } else {