proc-cmdline: add some explanatory comments

This commit is contained in:
Lennart Poettering 2020-05-14 09:37:27 +02:00
parent b2d1ad757c
commit 3931056767
2 changed files with 6 additions and 6 deletions

View File

@ -268,17 +268,17 @@ int proc_cmdline_get_bool(const char *key, bool *ret) {
r = proc_cmdline_get_key(key, PROC_CMDLINE_VALUE_OPTIONAL, &v);
if (r < 0)
return r;
if (r == 0) {
if (r == 0) { /* key not specified at all */
*ret = false;
return 0;
}
if (v) { /* parameter passed */
if (v) { /* key with parameter passed */
r = parse_boolean(v);
if (r < 0)
return r;
*ret = r;
} else /* no parameter passed */
} else /* key without parameter passed */
*ret = true;
return 1;

View File

@ -6,9 +6,9 @@
#include "log.h"
typedef enum ProcCmdlineFlags {
PROC_CMDLINE_STRIP_RD_PREFIX = 1 << 0,
PROC_CMDLINE_VALUE_OPTIONAL = 1 << 1,
PROC_CMDLINE_RD_STRICT = 1 << 2,
PROC_CMDLINE_STRIP_RD_PREFIX = 1 << 0, /* automatically strip "rd." prefix if it is set (and we are in the initrd, since otherwise we'd not consider it anyway) */
PROC_CMDLINE_VALUE_OPTIONAL = 1 << 1, /* the value is optional (for boolean switches that can omit the value) */
PROC_CMDLINE_RD_STRICT = 1 << 2, /* ignore this in the initrd */
} ProcCmdlineFlags;
typedef int (*proc_cmdline_parse_t)(const char *key, const char *value, void *data);