summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-04-08 11:16:04 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-04-11 11:49:23 +0200
commitf4a1d32c82489d2b734a3c266aa47ba697100312 (patch)
treecf503aba8d92274fbf4e6911c40c4faeb3c69e93 /src
parentos-util: invert order of arguments in extension release parser (diff)
downloadsystemd-f4a1d32c82489d2b734a3c266aa47ba697100312.tar.xz
systemd-f4a1d32c82489d2b734a3c266aa47ba697100312.zip
os-util: merge parse_{extension,os}_release()
Diffstat (limited to 'src')
-rw-r--r--src/basic/os-util.c33
-rw-r--r--src/basic/os-util.h9
2 files changed, 14 insertions, 28 deletions
diff --git a/src/basic/os-util.c b/src/basic/os-util.c
index ff31a48d3e..16fe123ce6 100644
--- a/src/basic/os-util.c
+++ b/src/basic/os-util.c
@@ -242,40 +242,25 @@ int open_extension_release(
return 0;
}
-static int parse_release_internal(const char *root, ImageClass image_class, bool relax_extension_release_check, const char *extension, va_list ap) {
+int parse_extension_release_sentinel(
+ const char *root,
+ ImageClass image_class,
+ bool relax_extension_release_check,
+ const char *extension,
+ ...) {
+
_cleanup_close_ int fd = -EBADF;
_cleanup_free_ char *p = NULL;
+ va_list ap;
int r;
r = open_extension_release(root, image_class, extension, relax_extension_release_check, &p, &fd);
if (r < 0)
return r;
- return parse_env_file_fdv(fd, p, ap);
-}
-
-int _parse_extension_release(const char *root, ImageClass image_class, bool relax_extension_release_check, const char *extension, ...) {
- va_list ap;
- int r;
-
- assert(image_class >= 0);
- assert(image_class < _IMAGE_CLASS_MAX);
-
va_start(ap, extension);
- r = parse_release_internal(root, image_class, relax_extension_release_check, extension, ap);
- va_end(ap);
-
- return r;
-}
-
-int _parse_os_release(const char *root, ...) {
- va_list ap;
- int r;
-
- va_start(ap, root);
- r = parse_release_internal(root, _IMAGE_CLASS_INVALID, /* relax_extension_release_check= */ false, NULL, ap);
+ r = parse_env_file_fdv(fd, p, ap);
va_end(ap);
-
return r;
}
diff --git a/src/basic/os-util.h b/src/basic/os-util.h
index e6acf21195..243d3c58ea 100644
--- a/src/basic/os-util.h
+++ b/src/basic/os-util.h
@@ -31,10 +31,11 @@ static inline int path_is_os_tree(const char *path) {
int open_extension_release(const char *root, ImageClass image_class, const char *extension, bool relax_extension_release_check, char **ret_path, int *ret_fd);
int open_os_release(const char *root, char **ret_path, int *ret_fd);
-int _parse_extension_release(const char *root, ImageClass image_class, bool relax_extension_release_check, const char *extension, ...) _sentinel_;
-int _parse_os_release(const char *root, ...) _sentinel_;
-#define parse_extension_release(root, image_class, extension, relax_extension_release_check, ...) _parse_extension_release(root, image_class, relax_extension_release_check, extension, __VA_ARGS__, NULL)
-#define parse_os_release(root, ...) _parse_os_release(root, __VA_ARGS__, NULL)
+int parse_extension_release_sentinel(const char *root, ImageClass image_class, bool relax_extension_release_check, const char *extension, ...) _sentinel_;
+#define parse_extension_release(root, image_class, extension, relax_extension_release_check, ...) \
+ parse_extension_release_sentinel(root, image_class, relax_extension_release_check, extension, __VA_ARGS__, NULL)
+#define parse_os_release(root, ...) \
+ parse_extension_release_sentinel(root, _IMAGE_CLASS_INVALID, false, NULL, __VA_ARGS__, NULL)
int load_extension_release_pairs(const char *root, ImageClass image_class, const char *extension, bool relax_extension_release_check, char ***ret);
static inline int load_os_release_pairs(const char *root, char ***ret) {