Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Jul 7, 2016
1 parent 2bb04f4 commit 58c11bc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/usb_moded-modesetting.c
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/usb_moded-network.c
Expand Up @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions src/usb_moded.c
Expand Up @@ -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:
Expand Down

0 comments on commit 58c11bc

Please sign in to comment.