summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorNicolas Pitre <nico@fluxnic.net>2021-03-23 12:43:03 -0400
committerNicolas Pitre <nico@fluxnic.net>2021-03-23 12:43:03 -0400
commitdf0e87be34f506dd428f31715bbfe149afcdec35 (patch)
treed2a228e52bd5a0a7b7e06886c5b4142f9ab71cec /src/utils
parent255a39684dd12bb0b585027f4c2780b2fcc4c844 (diff)
tiny code logic simplification
No functional change.
Diffstat (limited to 'src/utils')
-rwxr-xr-xsrc/utils/dictionary.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/utils/dictionary.c b/src/utils/dictionary.c
index 3d7e3a0..2c66038 100755
--- a/src/utils/dictionary.c
+++ b/src/utils/dictionary.c
@@ -239,11 +239,13 @@ void parse_str(struct dictionary *d, const char *str, int split_on_blanks) {
/* spaces in the key are invalid */
return;
}
- if (i >= sizeof(key) - 1) {
+
+ key[i++] = *str++;
+
+ if (i >= sizeof(key)) {
/* won't have room for final '\0' */
return;
}
- key[i++] = *str++;
}
if (*str != '=') {
@@ -261,11 +263,13 @@ void parse_str(struct dictionary *d, const char *str, int split_on_blanks) {
put(d, key, value);
break;
}
- if (i >= sizeof(value) - 1) {
+
+ value[i++] = *str++;
+
+ if (i >= sizeof(value)) {
/* won't have room for final '\0' */
return;
}
- value[i++] = *str++;
}
}
}