summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/basic/extract-word.c7
-rw-r--r--src/basic/extract-word.h2
-rw-r--r--src/test/test-sizeof.c11
3 files changed, 18 insertions, 2 deletions
diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c
index f8cac3e911..804f14c44c 100644
--- a/src/basic/extract-word.c
+++ b/src/basic/extract-word.c
@@ -241,7 +241,12 @@ int extract_first_word_and_warn(
return log_syntax(unit, LOG_ERR, filename, line, r, "Unable to decode word \"%s\", ignoring: %m", rvalue);
}
-int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) {
+/* We pass ExtractFlags as unsigned int (to avoid undefined behaviour when passing
+ * an object that undergoes default argument promotion as an argument to va_start).
+ * Let's make sure that ExtractFlags fits into an unsigned int. */
+assert_cc(sizeof(enum ExtractFlags) <= sizeof(unsigned));
+
+int extract_many_words(const char **p, const char *separators, unsigned flags, ...) {
va_list ap;
char **l;
int n = 0, i, c, r;
diff --git a/src/basic/extract-word.h b/src/basic/extract-word.h
index 21db5ef33f..04746c6d08 100644
--- a/src/basic/extract-word.h
+++ b/src/basic/extract-word.h
@@ -32,4 +32,4 @@ typedef enum ExtractFlags {
int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags);
int extract_first_word_and_warn(const char **p, char **ret, const char *separators, ExtractFlags flags, const char *unit, const char *filename, unsigned line, const char *rvalue);
-int extract_many_words(const char **p, const char *separators, ExtractFlags flags, ...) _sentinel_;
+int extract_many_words(const char **p, const char *separators, unsigned flags, ...) _sentinel_;
diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c
index 36389b7710..269adfd18f 100644
--- a/src/test/test-sizeof.c
+++ b/src/test/test-sizeof.c
@@ -32,6 +32,14 @@
strstr(STRINGIFY(t), "signed") ? "" : \
((t)-1 < (t)0 ? ", signed" : ", unsigned"));
+enum Enum {
+ enum_value,
+};
+
+enum BigEnum {
+ big_enum_value = UINT64_C(-1),
+};
+
int main(void) {
info(char);
info(signed char);
@@ -53,5 +61,8 @@ int main(void) {
info(usec_t);
info(__time_t);
+ info(enum Enum);
+ info(enum BigEnum);
+
return 0;
}