From 58c11bca5e276f57547f0b741e289028970da478 Mon Sep 17 00:00:00 2001 From: Simo Piiroinen Date: Wed, 6 Jul 2016 14:28:45 +0300 Subject: [PATCH] [compilation] Remove -pedantic compiler option Unless the code base is actively used with other than gcc compilers, use of -pedantic just denies use of handy gcc extensions like use of "%m" format parameter instead of non-thread-safe strerror(). Drop the '-pedantic' option and replace all strerror() calls with "%m". Signed-off-by: Simo Piiroinen --- configure.ac | 2 +- src/usb_moded-modesetting.c | 6 ++---- src/usb_moded-network.c | 2 +- src/usb_moded.c | 5 ++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index b6c090e..b2501c1 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ test_gcc_flag() { # We use gnu99 instead of c99 because many have interpreted the standard # in a way that int64_t isn't defined on non-64 bit platforms. -CFLAGS="-Os -std=gnu99 -Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -finline-small-functions -Wno-unused-result -fstack-protector -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now -fPIE -fpie -pie" +CFLAGS="-Os -std=gnu99 -Wall -W -Wextra -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -finline-small-functions -Wno-unused-result -fstack-protector -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now -fPIE -fpie -pie" AC_ARG_ENABLE([debug], AS_HELP_STRING([--enable-debug],[Enable debug @<:@default=false@:>@]), [case "${enableval}" in diff --git a/src/usb_moded-modesetting.c b/src/usb_moded-modesetting.c index 9f77a87..e588c21 100644 --- a/src/usb_moded-modesetting.c +++ b/src/usb_moded-modesetting.c @@ -61,9 +61,7 @@ int write_to_file(const char *path, const char *text) /* no O_CREAT -> writes only to already existing files */ if( (fd = TEMP_FAILURE_RETRY(open(path, O_WRONLY))) == -1 ) { - /* gcc -pedantic does not like "%m" - log_warning("open(%s): %m", path); */ - log_warning("open(%s): %s", path, strerror(errno)); + log_warning("open(%s): %m", path); goto cleanup; } @@ -72,7 +70,7 @@ int write_to_file(const char *path, const char *text) ssize_t n = TEMP_FAILURE_RETRY(write(fd, text, todo)); if( n < 0 ) { - log_warning("write(%s): %s", path, strerror(errno)); + log_warning("write(%s): %m", path); goto cleanup; } todo -= n; diff --git a/src/usb_moded-network.c b/src/usb_moded-network.c index 18d7e12..fcaa5a3 100644 --- a/src/usb_moded-network.c +++ b/src/usb_moded-network.c @@ -400,7 +400,7 @@ static int write_udhcpd_conf(struct ipforward_data *ipforward, struct mode_list_ link: if (symlink(UDHCP_CONFIG_PATH, UDHCP_CONFIG_LINK) == -1) { - log_debug("Error creating link "UDHCP_CONFIG_LINK" -> "UDHCP_CONFIG_PATH": %s\n", strerror(errno)); + log_debug("Error creating link "UDHCP_CONFIG_LINK" -> "UDHCP_CONFIG_PATH": %m\n"); unlink(UDHCP_CONFIG_PATH); return(1); } diff --git a/src/usb_moded.c b/src/usb_moded.c index 268dac9..674cc2c 100644 --- a/src/usb_moded.c +++ b/src/usb_moded.c @@ -938,14 +938,13 @@ static void write_to_sysfs_file(const char *path, const char *text) if ((fd = open(path, O_WRONLY)) == -1) { if (errno != ENOENT) { - log_warning("%s: open for writing failed: %s", - path, strerror(errno)); + log_warning("%s: open for writing failed: %m", path); } goto EXIT; } if (write(fd, text, strlen(text)) == -1) { - log_warning("%s: write failed : %s", path, strerror(errno)); + log_warning("%s: write failed : %m", path); goto EXIT; } EXIT: