From 1136f5bd18ce5b1657347dc26b0aa8e3153786ce Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Tue, 14 Nov 2023 00:54:15 +0100 Subject: permchain.c: Address warning -Wunused-parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fix is a near 1:1 copy of what add_chmod_rule_to_permchain already does about the same problem. Symptom was: > src/permchain.c: In function ‘add_octal_rule_to_permchain’: > src/permchain.c:151:71: error: unused parameter ‘end’ [-Werror=unused-parameter] > 151 | static int add_octal_rule_to_permchain(const char *start, const char *end, > | --- src/permchain.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/permchain.c b/src/permchain.c index ad32f9d..d101aa1 100644 --- a/src/permchain.c +++ b/src/permchain.c @@ -151,8 +151,18 @@ error: static int add_octal_rule_to_permchain(const char *start, const char *end, struct permchain *pc) { + // Make [start..end[ available as a null-terminated string to `strtol` + const int len = end - start; + char * const buf = malloc((len + 1) * sizeof(char)); + if (buf == NULL) + return -1; + memcpy(buf, start, len); + buf[len] = '\0'; + struct permchain *newpc = permchain_create(); - long mode = strtol(start, NULL, 8); + + long mode = strtol(buf, NULL, 8); + free(buf); if (mode < 0 || mode > 0777) { permchain_destroy(newpc); -- cgit v1.2.3