summaryrefslogtreecommitdiff
path: root/libgcompat/string.c
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-08 19:46:12 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-08 19:46:12 -0500
commite3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b (patch)
tree91aec83a2a1d33347514d213e7519ab605c98fee /libgcompat/string.c
parentc820eed56f8e30a524050d8f91148decfea1ec9b (diff)
downloadgcompat-e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b.tar.gz
gcompat-e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b.tar.bz2
gcompat-e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b.tar.xz
gcompat-e3d2ec038eb2b84928e718f5fddf8bdcca7e4c5b.zip
string: reduce scope of variables in strfry
Diffstat (limited to 'libgcompat/string.c')
-rw-r--r--libgcompat/string.c9
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;
}