git: b00e65ff70a4 - main - newsyslog: use str2sig() instead of own implementation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 25 Sep 2025 08:19:00 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=b00e65ff70a4613b3bf2fd2781d174fa437fbfbe
commit b00e65ff70a4613b3bf2fd2781d174fa437fbfbe
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-09-25 08:18:29 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-09-25 08:18:29 +0000
newsyslog: use str2sig() instead of own implementation
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D52697
---
usr.sbin/newsyslog/newsyslog.c | 29 +----------------------------
1 file changed, 1 insertion(+), 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);
-}