diff options
| author | Gleb Smirnoff <glebius@FreeBSD.org> | 2025-09-25 08:18:29 +0000 |
|---|---|---|
| committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2025-09-25 08:18:29 +0000 |
| commit | b00e65ff70a4613b3bf2fd2781d174fa437fbfbe (patch) | |
| tree | 6e37754dfd33d8d9383d2b8ae25a39cb3144e150 | |
| parent | e43fbf27976df17991d32c72c41e43fda66fb262 (diff) | |
newsyslog: use str2sig() instead of own implementation
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D52697
| -rw-r--r-- | usr.sbin/newsyslog/newsyslog.c | 29 |
1 files changed, 1 insertions, 28 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index 0c8c2c85b893..e24e2db1155d 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -309,7 +309,6 @@ static int age_old_log(const char *file); static void savelog(char *from, char *to); static void createdir(const struct conf_entry *ent, char *dirpart); static void createlog(const struct conf_entry *ent); -static int parse_signal(const char *str); /* * All the following take a parameter of 'int', but expect values in the @@ -1485,8 +1484,7 @@ no_trimat: working->sig = SIGHUP; if (q && *q) { got_sig: - working->sig = parse_signal(q); - if (working->sig < 1 || working->sig >= sys_nsig) { + if (str2sig(q, &working->sig) != 0) { badline( "illegal signal in config file:\n%s", errline); @@ -2884,28 +2882,3 @@ change_attrs(const char *fname, const struct conf_entry *ent) warn("can't chflags %s NODUMP", fname); } } - -/* - * Parse a signal number or signal name. Returns the signal number parsed or -1 - * on failure. - */ -static int -parse_signal(const char *str) -{ - int sig, i; - const char *errstr; - - sig = strtonum(str, 1, sys_nsig - 1, &errstr); - - if (errstr == NULL) - return (sig); - if (strncasecmp(str, "SIG", 3) == 0) - str += 3; - - for (i = 1; i < sys_nsig; i++) { - if (strcasecmp(str, sys_signame[i]) == 0) - return (i); - } - - return (-1); -} |
