Minor whitespace and comment cleanup

- Comments preferably at beginning of func/sect
  - Reorder code slightly, add whitespace for readability
  - Drop useless comment

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2022-02-25 07:15:03 +01:00
1 parent b83fdea49b
commit 85b29d9407
3 files changed
+12 -13

No files matched your search

+3 -2
View File
@@ -131,7 +131,7 @@ static int do_signal_svc(svc_t *svc, void *user_data)
static int do_signal(char *buf, size_t len, int sig) static int do_signal(char *buf, size_t len, int sig)
{ {
/* Sanity check: Do we know this signal!? */ /* Sanity check: do we know this signal? */
if (!*sig2str(sig)) if (!*sig2str(sig))
return 1; return 1;
@@ -468,9 +468,10 @@ static void api_cb(uev_t *w, void *arg, int events)
goto leave; goto leave;
case INIT_CMD_SIGNAL: case INIT_CMD_SIGNAL:
/* runlevel is reused for signal */
_d("svc signal %d: %s", rq.runlevel, rq.data); _d("svc signal %d: %s", rq.runlevel, rq.data);
strterm(rq.data, sizeof(rq.data)); strterm(rq.data, sizeof(rq.data));
result = do_signal(rq.data, sizeof(rq.data), rq.runlevel /* runlevel is reused for signal! */); result = do_signal(rq.data, sizeof(rq.data), rq.runlevel);
break; break;
default: default:
+8 -6
View File
@@ -278,10 +278,10 @@ static int do_restart(char *arg)
/** /**
* do_signal - Ask finit to send a signal to a service. * do_signal - Ask finit to send a signal to a service.
* @argv: must point to an array of strings, containing a service * @argv: must point to an array of strings, containing a service
* and signal name, in that order. * and signal name, in that order.
* @argc: must be 2. * @argc: must be 2.
* *
* A signal can be a complete signal name such as "SIGHUP", or * A signal can be a complete signal name such as "SIGHUP", or
* it can be the shortest unique name, such as "HUP" (no SIG prefix). * it can be the shortest unique name, such as "HUP" (no SIG prefix).
* It can also be a raw signal number, such as "9" (SIGKILL). * It can also be a raw signal number, such as "9" (SIGKILL).
@@ -297,7 +297,7 @@ int do_signal(int argc, char **argv)
if (argc != 2) if (argc != 2)
errx(1, "invalid number of arguments to signal"); errx(1, "invalid number of arguments to signal");
/* Validate service name */ /* Validate service name */
strlcpy(rq.data, argv[0], sizeof(rq.data)); strlcpy(rq.data, argv[0], sizeof(rq.data));
if (client_send(&rq, sizeof(rq))) { if (client_send(&rq, sizeof(rq))) {
@@ -319,10 +319,12 @@ int do_signal(int argc, char **argv)
} }
} }
rq.magic = INIT_MAGIC; /* Reuse runlevel for signal number. */
rq.cmd = INIT_CMD_SIGNAL; rq.magic = INIT_MAGIC;
rq.cmd = INIT_CMD_SIGNAL;
rq.runlevel = signo;
strlcpy(rq.data, argv[0], sizeof(rq.data)); strlcpy(rq.data, argv[0], sizeof(rq.data));
rq.runlevel = signum; /* Reuse runlevel for signal number. */
return client_send(&rq, sizeof(rq)); return client_send(&rq, sizeof(rq));
show_usage: show_usage:
+1 -5
View File
@@ -278,7 +278,7 @@ char *sig2str(int sig)
/** /**
* str2sig - Translate signal name to the corresponding signal number. * str2sig - Translate signal name to the corresponding signal number.
* @sig: The name of the signal * @sig: The name of the signal
* *
* A signal can be a complete signal name such as "SIGHUP", or * A signal can be a complete signal name such as "SIGHUP", or
* it can be the shortest unique name, such as "HUP" (no SIG prefix). * it can be the shortest unique name, such as "HUP" (no SIG prefix).
*/ */
@@ -287,10 +287,6 @@ int str2sig(char *sig)
int name_offset = 0; int name_offset = 0;
size_t i; size_t i;
/* if sig name starts with "SIG", then skip the first
* three characters. signames holds the names without
* the "SIG" prefix.
*/
if (strncasecmp(sig, "SIG", 3) == 0) { if (strncasecmp(sig, "SIG", 3) == 0) {
name_offset = 3; name_offset = 3;
} }