public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gcc-plugins: use swap() to make code cleaner
@ 2021-10-28  0:35 Yang Guang
  2021-12-02 19:35 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Guang @ 2021-10-28  0:35 UTC (permalink / raw)
  To: Kees Cook; +Cc: Yang Guang, Zeal Robot, linux-hardening, linux-kernel

Using swap() make it more readable.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
 scripts/gcc-plugins/randomize_layout_plugin.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c
index 334741a31d0a..feee5ba8fa2b 100644
--- a/scripts/gcc-plugins/randomize_layout_plugin.c
+++ b/scripts/gcc-plugins/randomize_layout_plugin.c
@@ -244,11 +244,8 @@ static void full_shuffle(tree *newtree, unsigned long length, ranctx *prng_state
 	unsigned long i, randnum;
 
 	for (i = length - 1; i > 0; i--) {
-		tree tmp;
 		randnum = ranval(prng_state) % (i + 1);
-		tmp = newtree[i];
-		newtree[i] = newtree[randnum];
-		newtree[randnum] = tmp;
+		swap(newtree[i], newtree[randnum]);
 	}
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-02 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-28  0:35 [PATCH] gcc-plugins: use swap() to make code cleaner Yang Guang
2021-12-02 19:35 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox