[LEDE-DEV] [PATCH] luci: treewide: Replace strerror(errno) with %m.
Rosen Penev
rosenp at gmail.com
Tue Jan 2 13:54:30 PST 2018
On Tue, Dec 26, 2017 at 12:25 AM, Karl Palsson <karlp at tweak.net.au> wrote:
>
> Rosen Penev <rosenp at gmail.com> wrote:
>> Saves a few bytes. No functional difference.
>
> Except that it now requires gnu extensions to compile. That seems
> like a pretty poor tradeoff.
>
BSDs such as FreeBSD and macOS print only m when %m is specified. That
and I don't see LuCI being compiled for those platforms.
> Sincerely,
> Karl P
>
>
>>
>> Signed-off-by: Rosen Penev <rosenp at gmail.com>
>> ---
>> contrib/package/freifunk-watchdog/src/watchdog.c | 6 ++---
>> contrib/package/freifunk-watchdog/src/watchdog.h | 6 ++---
>> modules/luci-mod-admin-full/src/luci-bwc.c | 31 ++++++++++++------------
>> 3 files changed, 19 insertions(+), 24 deletions(-)
>>
>> diff --git a/contrib/package/freifunk-watchdog/src/watchdog.c
>> b/contrib/package/freifunk-watchdog/src/watchdog.c index
>> f546985..3e46668 100644
>> --- a/contrib/package/freifunk-watchdog/src/watchdog.c
>> +++ b/contrib/package/freifunk-watchdog/src/watchdog.c
>> @@ -153,8 +153,7 @@ static int find_process(const char *name)
>> return pid;
>> }
>>
>> - syslog(LOG_CRIT, "Unable to open /proc: %s",
>> - strerror(errno));
>> + syslog(LOG_CRIT, "Unable to open /proc: %m");
>>
>> return -1;
>> }
>> @@ -381,8 +380,7 @@ static int do_daemon(void)
>>
>> if( (iwfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1 )
>> {
>> - syslog(LOG_ERR, "Can not open wireless control socket: %s",
>> - strerror(errno));
>> + syslog(LOG_ERR, "Can not open wireless control socket: %m");
>>
>> return 1;
>> }
>> diff --git a/contrib/package/freifunk-watchdog/src/watchdog.h
>> b/contrib/package/freifunk-watchdog/src/watchdog.h index
>> 6f2382d..d13bbd9 100644
>> --- a/contrib/package/freifunk-watchdog/src/watchdog.h
>> +++ b/contrib/package/freifunk-watchdog/src/watchdog.h
>> @@ -128,14 +128,12 @@ iw_ioctl(int skfd, /* Socket to the kernel */
>> switch(fork()) \
>> { \
>> case -1: \
>> - syslog(LOG_CRIT, "Unable to fork child: %s", \
>> - strerror(errno)); \
>> + syslog(LOG_CRIT, "Unable to fork child: %m"); \
>> break; \
>> \
>> case 0: \
>> execl(x, NULL); \
>> - syslog(LOG_CRIT, "Unable to execute action: %s", \
>> - strerror(errno)); \
>> + syslog(LOG_CRIT, "Unable to execute action: %m"); \
>> return 1; \
>> } \
>> } while(0)
>> diff --git a/modules/luci-mod-admin-full/src/luci-bwc.c
>> b/modules/luci-mod-admin-full/src/luci-bwc.c index
>> 8ddd917..2d1cc6d 100644
>> --- a/modules/luci-mod-admin-full/src/luci-bwc.c
>> +++ b/modules/luci-mod-admin-full/src/luci-bwc.c
>> @@ -309,8 +309,8 @@ static int update_ifstat(
>> {
>> if (init_file(path, sizeof(struct traffic_entry)))
>> {
>> - fprintf(stderr, "Failed to init %s: %s\n",
>> - path, strerror(errno));
>> + fprintf(stderr, "Failed to init %s: %m\n",
>> + path);
>>
>> return -1;
>> }
>> @@ -339,8 +339,8 @@ static int update_radiostat(
>> {
>> if (init_file(path, sizeof(struct radio_entry)))
>> {
>> - fprintf(stderr, "Failed to init %s: %s\n",
>> - path, strerror(errno));
>> + fprintf(stderr, "Failed to init %s: %m\n",
>> + path);
>>
>> return -1;
>> }
>> @@ -367,8 +367,8 @@ static int update_cnstat(uint32_t udp, uint32_t tcp, uint32_t other)
>> {
>> if (init_file(path, sizeof(struct conn_entry)))
>> {
>> - fprintf(stderr, "Failed to init %s: %s\n",
>> - path, strerror(errno));
>> + fprintf(stderr, "Failed to init %s: %m\n",
>> + path);
>>
>> return -1;
>> }
>> @@ -395,8 +395,8 @@ static int update_ldstat(uint16_t load1, uint16_t load5, uint16_t load15)
>> {
>> if (init_file(path, sizeof(struct load_entry)))
>> {
>> - fprintf(stderr, "Failed to init %s: %s\n",
>> - path, strerror(errno));
>> + fprintf(stderr, "Failed to init %s: %m\n",
>> + path);
>>
>> return -1;
>> }
>> @@ -459,7 +459,7 @@ static int run_daemon(void)
>> /* write pid */
>> if (writepid())
>> {
>> - fprintf(stderr, "Failed to write pid file: %s\n", strerror(errno));
>> + fprintf(stderr, "Failed to write pid file: %m\n");
>> return 1;
>> }
>>
>> @@ -574,15 +574,14 @@ static void check_daemon(void)
>> if (run_daemon())
>> {
>> fprintf(stderr,
>> - "Failed to ping daemon and unable to start it up: %s\n",
>> - strerror(errno));
>> + "Failed to ping daemon and unable to start it up: %m\n");
>>
>> exit(1);
>> }
>> }
>> else if (kill(pid, SIGUSR1))
>> {
>> - fprintf(stderr, "Failed to send signal: %s\n", strerror(errno));
>> + fprintf(stderr, "Failed to send signal: %m\n");
>> exit(2);
>> }
>> }
>> @@ -599,7 +598,7 @@ static int run_dump_ifname(const char *ifname)
>>
>> if (mmap_file(path, sizeof(struct traffic_entry), &m))
>> {
>> - fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
>> + fprintf(stderr, "Failed to open %s: %m\n", path);
>> return 1;
>> }
>>
>> @@ -635,7 +634,7 @@ static int run_dump_radio(const char *ifname)
>>
>> if (mmap_file(path, sizeof(struct radio_entry), &m))
>> {
>> - fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
>> + fprintf(stderr, "Failed to open %s: %m\n", path);
>> return 1;
>> }
>>
>> @@ -669,7 +668,7 @@ static int run_dump_conns(void)
>>
>> if (mmap_file(path, sizeof(struct conn_entry), &m))
>> {
>> - fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
>> + fprintf(stderr, "Failed to open %s: %m\n", path);
>> return 1;
>> }
>>
>> @@ -703,7 +702,7 @@ static int run_dump_load(void)
>>
>> if (mmap_file(path, sizeof(struct load_entry), &m))
>> {
>> - fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno));
>> + fprintf(stderr, "Failed to open %s: %m\n", path);
>> return 1;
>> }
>>
>> --
>> 2.7.4
>>
>>
>> _______________________________________________
>> Lede-dev mailing list
>> Lede-dev at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/lede-dev
More information about the Lede-dev
mailing list