From 80de5d439f2cb353893084bb18f292e629633cf0 Mon Sep 17 00:00:00 2001 From: KusaReMKN <48670724+KusaReMKN@users.noreply.github.com> Date: Thu, 31 Mar 2022 23:54:21 +0900 Subject: [PATCH] del warn(NULL) The message displayed by `warn(NULL)` makes no one happy. --- configure.ac | 2 +- sendwol.1 | 2 +- sendwol.c | 18 ++++++++---------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 0173fb0..fb579db 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([sendwol], [0.10], [https://github.com/KusaReMKN/sendwol/issue]) +AC_INIT([sendwol], [0.11], [https://github.com/KusaReMKN/sendwol/issue]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([sendwol.c]) AC_CONFIG_HEADERS([config.h]) diff --git a/sendwol.1 b/sendwol.1 index ae62fb3..63539ba 100644 --- a/sendwol.1 +++ b/sendwol.1 @@ -53,7 +53,7 @@ By default, .Pa $HOME/.sendwol and .Pa /etc/ethers -are looked up in this order. +are looked up in this order if they exist. The specified file is looked up before them. If this option is specified more than once, those specified later will be looked up first. diff --git a/sendwol.c b/sendwol.c index 09330a2..02a67eb 100644 --- a/sendwol.c +++ b/sendwol.c @@ -103,17 +103,12 @@ main(int argc, char *argv[]) goto dberror; homesendwol = home_sendwol(); - if (homesendwol != NULL) { + if (homesendwol != NULL) if (push_dblist(&list, homesendwol) == -1) { -dberror: warn(NULL); - warnx("database files are not available"); +dberror: warnx("database files are not available"); free_dblist(list); list = NULL; } - } else { - warn(NULL); - warnx("~/.sendwol is not available"); - } forcev4 = 0; forcev6 = 0; @@ -140,7 +135,6 @@ dberror: warn(NULL); if (list == NULL) break; if (push_dblist(&list, optarg) == -1) { - warn(NULL); warnx("database files are not available"); free_dblist(list); list = NULL; @@ -308,8 +302,10 @@ home_sendwol(void) length = snprintf(NULL, 0, HOME_SENDWOL, home) + 1; buffer = (char *)malloc(length); - if (buffer == NULL) + if (buffer == NULL) { + warn("malloc"); return NULL; + } snprintf(buffer, length, HOME_SENDWOL, home); @@ -403,8 +399,10 @@ push_dblist(struct dblist **restrict headp, const char *restrict path) struct dblist *temp; temp = (struct dblist *)malloc(sizeof(*temp)); - if (temp == NULL) + if (temp == NULL) { + warn("malloc"); return -1; + } temp->dbl_next = *headp; temp->dbl_path = path;