[LEDE-DEV,1/2] firewall3: Replace strerror(errno) with %m

Message ID 1514242524-4319-1-git-send-email-rosenp@gmail.com
State Changes Requested
Delegated to: John Crispin
Headers show
Series
  • [LEDE-DEV,1/2] firewall3: Replace strerror(errno) with %m
Related show

Commit Message

Rosen Penev Dec. 25, 2017, 10:55 p.m.
Size reductiom in resulting binaries. No functional difference.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 defaults.c |  2 +-
 includes.c |  4 ++--
 utils.c    | 14 +++++++-------
 3 files changed, 10 insertions(+), 10 deletions(-)

Patch

diff --git a/defaults.c b/defaults.c
index 85a3750..f1be1dd 100644
--- a/defaults.c
+++ b/defaults.c
@@ -327,7 +327,7 @@  set_default(const char *name, int set)
 
 	if (!(f = fopen(path, "w")))
 	{
-		info("   ! Unable to write value: %s", strerror(errno));
+		info("   ! Unable to write value: %m");
 		return;
 	}
 
diff --git a/includes.c b/includes.c
index 8639210..bea380c 100644
--- a/includes.c
+++ b/includes.c
@@ -135,7 +135,7 @@  print_include(struct fw3_include *include)
 
 	if (!(f = fopen(include->path, "r")))
 	{
-		info("   ! Skipping due to open error: %s", strerror(errno));
+		info("   ! Skipping due to open error: %m");
 		return;
 	}
 
@@ -200,7 +200,7 @@  run_include(struct fw3_include *include)
 
 	if (stat(include->path, &s))
 	{
-		info("   ! Skipping due to path error: %s", strerror(errno));
+		info("   ! Skipping due to path error: %m");
 		return;
 	}
 
diff --git a/utils.c b/utils.c
index 024f95e..a66de74 100644
--- a/utils.c
+++ b/utils.c
@@ -346,13 +346,13 @@  fw3_lock(void)
 
 	if (lock_fd < 0)
 	{
-		warn("Cannot create lock file %s: %s", FW3_LOCKFILE, strerror(errno));
+		warn("Cannot create lock file %s: %m", FW3_LOCKFILE);
 		return false;
 	}
 
 	if (flock(lock_fd, LOCK_EX))
 	{
-		warn("Cannot acquire exclusive lock: %s", strerror(errno));
+		warn("Cannot acquire exclusive lock: %m");
 		return false;
 	}
 
@@ -366,7 +366,7 @@  fw3_unlock(void)
 		return;
 
 	if (flock(lock_fd, LOCK_UN))
-		warn("Cannot release exclusive lock: %s", strerror(errno));
+		warn("Cannot release exclusive lock: %m");
 
 	close(lock_fd);
 	unlink(FW3_LOCKFILE);
@@ -633,13 +633,13 @@  fw3_write_statefile(void *state)
 
 		if (!sf)
 		{
-			warn("Cannot create state %s: %s", FW3_STATEFILE, strerror(errno));
+			warn("Cannot create state %s: %m", FW3_STATEFILE);
 			return;
 		}
 
 		if (getifaddrs(&ifaddr))
 		{
-			warn("Cannot get interface addresses: %s", strerror(errno));
+			warn("Cannot get interface addresses: %m");
 			ifaddr = NULL;
 		}
 
@@ -722,7 +722,7 @@  fw3_hotplug(bool add, void *zone, void *device)
 	switch (fork())
 	{
 	case -1:
-		warn("Unable to fork(): %s\n", strerror(errno));
+		warn("Unable to fork(): %m\n");
 		return false;
 
 	case 0:
@@ -839,7 +839,7 @@  fw3_flush_conntrack(void *state)
 
 	if (getifaddrs(&ifaddr))
 	{
-		warn("Cannot get interface addresses: %s", strerror(errno));
+		warn("Cannot get interface addresses: %m");
 		return;
 	}