From e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Wed, 8 May 2019 19:46:12 -0500 Subject: string: reduce scope of variables in strfry --- libgcompat/string.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'libgcompat') diff --git a/libgcompat/string.c b/libgcompat/string.c index 9207db4..acc0566 100644 --- a/libgcompat/string.c +++ b/libgcompat/string.c @@ -288,17 +288,16 @@ void *memfrob(void *s, size_t n) char *strfry(char *s) { static unsigned int seed; - size_t len = strlen(s), i, j; - char t; + size_t len = strlen(s); if (!len) return s; seed += time(NULL) ^ getpid() ^ (uintptr_t) s; - for (i = 0; i < len - 1; ++i) { - j = rand_r(&seed) % (len - i) + i; - t = s[i]; + for (size_t i = 0; i < len - 1; ++i) { + size_t j = rand_r(&seed) % (len - i) + i; + char t = s[i]; s[i] = s[j]; s[j] = t; } -- cgit v1.2.3-70-g09d2