summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2025-01-28 18:55:25 +0000
committerFelix Fietkau2025-01-28 18:56:34 +0000
commitf3fc0b76040685829191debc03edf72f486ae8ae (patch)
tree9f81e387311ccd73d6c4ce004b5a2215f6a8a14b
parent16ff0badbde7e17ec3bd1f827ffe45922956cf86 (diff)
downloaduci-f3fc0b76040685829191debc03edf72f486ae8ae.tar.gz
libuci: fix false positive warning on older gcc versions
Fixes the following warning: libuci.c: In function 'uci_set_conf2dir': libuci.c:97:59: error: argument 'dir' might be clobbered by 'longjmp' or 'vfork' [-Werror=clobbered] 97 | int uci_set_conf2dir(struct uci_context *ctx, const char *dir) | ~~~~~~~~~~~~^~~ cc1: all warnings being treated as errors Reported-by: Matthias Franck <matthias.franck@softathome.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--libuci.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libuci.c b/libuci.c
index cffb916..d854549 100644
--- a/libuci.c
+++ b/libuci.c
@@ -98,11 +98,11 @@ int uci_set_conf2dir(struct uci_context *ctx, const char *dir)
{
char *cdir;
- UCI_HANDLE_ERR(ctx);
- if (dir && !dir[0])
- dir = NULL;
+ if (!dir || !dir[0])
+ cdir = NULL;
+ else if ((cdir = strdup(dir)) == NULL)
+ return UCI_ERR_MEM;
- cdir = dir ? uci_strdup(ctx, dir) : NULL;
if (ctx->conf2dir != uci_conf2dir)
free(ctx->conf2dir);
ctx->conf2dir = cdir;