1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-23 17:34:00 +03:00

basic/os-util: make the sentinel implicit

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-02-19 17:06:18 +01:00
parent 6ef06723b1
commit 209c14705d
8 changed files with 13 additions and 14 deletions

View File

@ -136,7 +136,7 @@ static int parse_release_internal(const char *root, const char *extension, va_li
return parse_env_filev(f, p, ap);
}
int parse_extension_release(const char *root, const char *extension, ...) {
int _parse_extension_release(const char *root, const char *extension, ...) {
va_list ap;
int r;
@ -147,7 +147,7 @@ int parse_extension_release(const char *root, const char *extension, ...) {
return r;
}
int parse_os_release(const char *root, ...) {
int _parse_os_release(const char *root, ...) {
va_list ap;
int r;

View File

@ -23,8 +23,11 @@ static inline int fopen_os_release(const char *root, char **ret_path, FILE **ret
return fopen_extension_release(root, NULL, ret_path, ret_file);
}
int parse_extension_release(const char *root, const char *extension, ...) _sentinel_;
int parse_os_release(const char *root, ...) _sentinel_;
int _parse_extension_release(const char *root, const char *extension, ...) _sentinel_;
int _parse_os_release(const char *root, ...) _sentinel_;
#define parse_extension_release(root, extension, ...) _parse_extension_release(root, extension, __VA_ARGS__, NULL)
#define parse_os_release(root, ...) _parse_os_release(root, __VA_ARGS__, NULL)
int load_extension_release_pairs(const char *root, const char *extension, char ***ret);
int load_os_release_pairs(const char *root, char ***ret);
int load_os_release_pairs_with_prefix(const char *root, const char *prefix, char ***ret);

View File

@ -1352,8 +1352,7 @@ static int status_welcome(void) {
r = parse_os_release(NULL,
"PRETTY_NAME", &pretty_name,
"ANSI_COLOR", &ansi_color,
NULL);
"ANSI_COLOR", &ansi_color);
if (r < 0)
log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
"Failed to read os-release file, ignoring: %m");

View File

@ -106,8 +106,7 @@ static void print_welcome(void) {
r = parse_os_release(
arg_root,
"PRETTY_NAME", &pretty_name,
"ANSI_COLOR", &ansi_color,
NULL);
"ANSI_COLOR", &ansi_color);
if (r < 0)
log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
"Failed to read os-release file, ignoring: %m");

View File

@ -159,8 +159,7 @@ static void context_read_os_release(Context *c) {
r = parse_os_release(NULL,
"PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
"CPE_NAME", &c->data[PROP_OS_CPE_NAME],
"HOME_URL", &c->data[PROP_OS_HOME_URL],
NULL);
"HOME_URL", &c->data[PROP_OS_HOME_URL]);
if (r < 0 && r != -ENOENT)
log_warning_errno(r, "Failed to read os-release file, ignoring: %m");

View File

@ -755,7 +755,7 @@ static int request_handler_machine(
if (r < 0)
return mhd_respondf(connection, r, MHD_HTTP_INTERNAL_SERVER_ERROR, "Failed to determine disk usage: %m");
(void) parse_os_release(NULL, "PRETTY_NAME", &os_name, NULL);
(void) parse_os_release(NULL, "PRETTY_NAME", &os_name);
(void) get_virtualization(&v);
r = asprintf(&json,

View File

@ -203,7 +203,7 @@ static int specifier_os_release_common(const char *field, char **ret) {
char *t = NULL;
int r;
r = parse_os_release(NULL, field, &t, NULL);
r = parse_os_release(NULL, field, &t);
if (r < 0)
return r;
if (!t) {

View File

@ -473,8 +473,7 @@ static int merge_subprocess(Hashmap *images, const char *workspace) {
arg_root,
"ID", &host_os_release_id,
"VERSION_ID", &host_os_release_version_id,
"SYSEXT_LEVEL", &host_os_release_sysext_level,
NULL);
"SYSEXT_LEVEL", &host_os_release_sysext_level);
if (r < 0)
return log_error_errno(r, "Failed to acquire 'os-release' data of OS tree '%s': %m", empty_to_root(arg_root));