summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-12-18 00:37:08 +0100
committerRichard Braun <rbraun@sceen.net>2017-12-18 00:37:08 +0100
commita0568115cdc9e6aa14820c5553f45f6ec701fb0c (patch)
tree8205ebae02a5e7135ef3a4c9710b18fc19ac6355
parentd6176a972708c34ed06a644c07b19a4bd0eae37c (diff)
hash: fix side effect in condition
-rw-r--r--hash.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/hash.h b/hash.h
index 1ef1fbe..fc80b79 100644
--- a/hash.h
+++ b/hash.h
@@ -108,7 +108,13 @@ hash_str(const char *str, unsigned int bits)
unsigned long hash;
char c;
- for (hash = 0; (c = *str) != '\0'; str++) {
+ for (hash = 0; /* no condition */; str++) {
+ c = *str;
+
+ if (c == '\0') {
+ break;
+ }
+
hash = ((hash << 5) - hash) + c;
}