From 5d7d8aaa3166cb8461ced12d07009336b50e8177 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 2 Sep 2024 08:55:09 +0200 Subject: [PATCH] confd: unchecked return value from remove() Not much we can do, other than log and report. Found by Coverity Scan Signed-off-by: Joachim Wiberg --- src/confd/src/ietf-syslog.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/confd/src/ietf-syslog.c b/src/confd/src/ietf-syslog.c index a2b376b5b..a522fa9c0 100644 --- a/src/confd/src/ietf-syslog.c +++ b/src/confd/src/ietf-syslog.c @@ -146,7 +146,8 @@ static void action(sr_session_ctx_t *session, const char *name, const char *xpat if (!selector(session, &act)) { /* No selectors, must've been a delete operation after all. */ fclose(act.fp); - remove(act.path); + if (remove(act.path)) + ERRNO("failed removing %s", act.path); return; } @@ -229,10 +230,12 @@ static int file_change(sr_session_ctx_t *session, uint32_t sub_id, const char *m const char *name; name = getnm(node, path, sizeof(path)); - if (op == LYDX_OP_DELETE) - remove(filename(name, false, path, sizeof(path))); - else + if (op == LYDX_OP_DELETE) { + if (remove(filename(name, false, path, sizeof(path)))) + ERRNO("failed removing %s", path); + } else { action(session, name, path, NULL); + } } srx_free_changes(tree); @@ -263,7 +266,8 @@ static int remote_change(sr_session_ctx_t *session, uint32_t sub_id, const char name = getnm(node, path, sizeof(path)); if (op == LYDX_OP_DELETE) { - remove(filename(name, true, path, sizeof(path))); + if (remove(filename(name, true, path, sizeof(path)))) + ERRNO("failed removing %s", path); } else { struct addr addr; @@ -324,7 +328,8 @@ static int server_change(sr_session_ctx_t *session, uint32_t sub_id, const char return SR_ERR_OK; if (!srx_enabled(session, "%s/enabled", xpath)) { - remove(SYSLOG_SERVER); + if (remove(SYSLOG_SERVER)) + ERRNO("failed disabling syslog server"); goto done; }