Revert "odhcp6c: Replace strerror(errno) with %m"
authorHans Dedecker <Hans Dedecker dedeckeh@gmail.com>
Wed, 3 Jan 2018 09:47:32 +0000 (10:47 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 3 Jan 2018 09:51:54 +0000 (10:51 +0100)
The code is ISO C source enforced by the usage of the pedantic compile
option; using %m triggers the compiler warning "error: ISO C does not
support the '%m' gnu_printf format [-Werror=format=]" which breaks
compilation due to Werror being set set.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
CMakeLists.txt
src/dhcpv6.c
src/odhcp6c.c

index c80c32a9a29d240736b69a40bad84f63b5c1dbcb..a5b0cb397e0965550fb5710b62165e06c3a598db 100644 (file)
@@ -5,7 +5,7 @@ cmake_policy(SET CMP0015 NEW)
 project(odhcp6c C)
 set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=c99")
-add_definitions(-D_GNU_SOURCE -Wall -Werror -Wextra)
+add_definitions(-D_GNU_SOURCE -Wall -Werror -Wextra -pedantic)
 
 if(${EXT_PREFIX_CLASS})
        add_definitions(-DEXT_PREFIX_CLASS=${EXT_PREFIX_CLASS})
index 0944dd205aae7e6482ae0d6bd7d647e94151823a..9dce577250400b29a0dde12841d6b7ea0ba90882 100644 (file)
@@ -522,9 +522,9 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs)
        if (sendmsg(sock, &msg, 0) < 0) {
                char in6_str[INET6_ADDRSTRLEN];
 
-               syslog(LOG_ERR, "Failed to send DHCPV6 message to %s (%m)",
+               syslog(LOG_ERR, "Failed to send DHCPV6 message to %s (%s)",
                        inet_ntop(AF_INET6, (const void *)&srv.sin6_addr,
-                               in6_str, sizeof(in6_str)));
+                               in6_str, sizeof(in6_str)), strerror(errno));
        }
 }
 
index a14c22ef0dd1dffcf3d2f2f282d1b9ee005e64f9..666af5c398493f07f97d6d775bbd65755c869171 100644 (file)
@@ -255,14 +255,15 @@ int main(_unused int argc, char* const argv[])
                        init_dhcpv6(ifname, client_options, sol_timeout) ||
                        ra_init(ifname, &ifid, ra_options, ra_holdoff_interval) ||
                        script_init(script, ifname)) {
-               syslog(LOG_ERR, "failed to initialize: %m");
+               syslog(LOG_ERR, "failed to initialize: %s", strerror(errno));
                return 3;
        }
 
        if (daemonize) {
                openlog("odhcp6c", LOG_PID, LOG_DAEMON); // Disable LOG_PERROR
                if (daemon(0, 0)) {
-                       syslog(LOG_ERR, "Failed to daemonize: %m");
+                       syslog(LOG_ERR, "Failed to daemonize: %s",
+                                       strerror(errno));
                        return 4;
                }