CLEANUP: state-file: make the path concatenation code a bit more consistent
There are as many ways to build the globalfilepathlen variable as branches
in the if/then/else, creating lots of confusion. Address the most obvious
parts, but some polishing definitely is still needed.
diff --git a/src/server.c b/src/server.c
index 9a03920..c0122b6 100644
--- a/src/server.c
+++ b/src/server.c
@@ -3164,14 +3164,13 @@
}
else if (global.server_state_base) {
len = strlen(global.server_state_base);
- globalfilepathlen += len;
-
- if (globalfilepathlen > MAXPATHLEN) {
+ if (len > MAXPATHLEN) {
globalfilepathlen = 0;
goto globalfileerror;
}
memcpy(globalfilepath, global.server_state_base, len);
- globalfilepath[globalfilepathlen] = 0;
+ globalfilepath[len] = 0;
+ globalfilepathlen = len;
/* append a slash if needed */
if (!globalfilepathlen || globalfilepath[globalfilepathlen - 1] != '/') {