diff options
-rw-r--r-- | src/fids/db.c | 3 | ||||
-rw-r--r-- | src/fids/main.c | 11 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/fids/db.c b/src/fids/db.c index e0021bc48..35caf7eeb 100644 --- a/src/fids/db.c +++ b/src/fids/db.c | |||
@@ -32,11 +32,10 @@ static DB *database[HASH_MAX] = {NULL}; | |||
32 | 32 | ||
33 | // djb2 hash function by Dan Bernstein | 33 | // djb2 hash function by Dan Bernstein |
34 | static unsigned hash(const char *str) { | 34 | static unsigned hash(const char *str) { |
35 | const unsigned char *s = (unsigned char *) str; | ||
36 | unsigned long hash = 5381; | 35 | unsigned long hash = 5381; |
37 | int c; | 36 | int c; |
38 | 37 | ||
39 | while (c = *s++) | 38 | while ((c = *str++) != '\0') |
40 | hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ | 39 | hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ |
41 | 40 | ||
42 | return hash & (HASH_MAX - 1); | 41 | return hash & (HASH_MAX - 1); |
diff --git a/src/fids/main.c b/src/fids/main.c index b53a9828e..c899b55e1 100644 --- a/src/fids/main.c +++ b/src/fids/main.c | |||
@@ -47,9 +47,10 @@ static inline int is_dir(const char *fname) { | |||
47 | assert(fname); | 47 | assert(fname); |
48 | 48 | ||
49 | struct stat s; | 49 | struct stat s; |
50 | int rv = stat(fname, &s); | 50 | if (stat(fname, &s) == 0) { |
51 | if (S_ISDIR(s.st_mode)) | 51 | if (S_ISDIR(s.st_mode)) |
52 | return 1; | 52 | return 1; |
53 | } | ||
53 | return 0; | 54 | return 0; |
54 | } | 55 | } |
55 | 56 | ||
@@ -116,7 +117,7 @@ static void file_checksum(const char *fname) { | |||
116 | 117 | ||
117 | // calculate blake2 checksum | 118 | // calculate blake2 checksum |
118 | char str_checksum[(KEY_SIZE / 8) * 2 + 1]; | 119 | char str_checksum[(KEY_SIZE / 8) * 2 + 1]; |
119 | int i; | 120 | int long unsigned i; |
120 | char *ptr = str_checksum; | 121 | char *ptr = str_checksum; |
121 | for (i = 0; i < sizeof(checksum); i++, ptr += 2) | 122 | for (i = 0; i < sizeof(checksum); i++, ptr += 2) |
122 | sprintf(ptr, "%02x", (unsigned char ) checksum[i]); | 123 | sprintf(ptr, "%02x", (unsigned char ) checksum[i]); |
@@ -190,7 +191,7 @@ void globbing(const char *fname) { | |||
190 | exit(1); | 191 | exit(1); |
191 | } | 192 | } |
192 | 193 | ||
193 | int i; | 194 | long unsigned i; |
194 | for (i = 0; i < globbuf.gl_pathc; i++) { | 195 | for (i = 0; i < globbuf.gl_pathc; i++) { |
195 | char *path = globbuf.gl_pathv[i]; | 196 | char *path = globbuf.gl_pathv[i]; |
196 | assert(path); | 197 | assert(path); |