diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-05-08 19:46:12 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-05-08 19:46:12 -0500 |
commit | e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b (patch) | |
tree | 91aec83a2a1d33347514d213e7519ab605c98fee | |
parent | c820eed56f8e30a524050d8f91148decfea1ec9b (diff) | |
download | gcompat-e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b.tar.gz gcompat-e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b.tar.bz2 gcompat-e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b.tar.xz gcompat-e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b.zip |
string: reduce scope of variables in strfry
-rw-r--r-- | libgcompat/string.c | 9 |
1 files changed, 4 insertions, 5 deletions
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; } |