From ec2011a785f45813d020c52fb77a779e060d8e04 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Fri, 8 Sep 2017 10:14:32 -0700 Subject: [PATCH] optparse: avoid enum in optparse_get/set Change prototype of optparse_get() and optparse_set() to avoid passing an enum as the argument to va_start() in these variadic functions. Use of enum causes newer compiler to issue warnings of the form: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs] Change the enum argument in these functions to an integer to suppress the warning and avoid potential undefined behavior. --- src/common/liboptparse/optparse.c | 4 ++-- src/common/liboptparse/optparse.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/liboptparse/optparse.c b/src/common/liboptparse/optparse.c index 79cc1f91f773..601ebdb33e31 100644 --- a/src/common/liboptparse/optparse.c +++ b/src/common/liboptparse/optparse.c @@ -995,7 +995,7 @@ optparse_err_t optparse_add_doc (optparse_t *p, const char *doc, int group) return optparse_add_option (p, &o); } -optparse_err_t optparse_set (optparse_t *p, optparse_item_t item, ...) +optparse_err_t optparse_set (optparse_t *p, int item, ...) { optparse_err_t e = OPTPARSE_SUCCESS; va_list vargs; @@ -1074,7 +1074,7 @@ static void * lookup_recursive (optparse_t *p, const char *key) } -optparse_err_t optparse_get (optparse_t *p, optparse_item_t item, ...) +optparse_err_t optparse_get (optparse_t *p, int item, ...) { optparse_err_t e = OPTPARSE_SUCCESS; va_list vargs; diff --git a/src/common/liboptparse/optparse.h b/src/common/liboptparse/optparse.h index 49ebab82a5f7..edfa99010da5 100644 --- a/src/common/liboptparse/optparse.h +++ b/src/common/liboptparse/optparse.h @@ -243,9 +243,9 @@ optparse_err_t optparse_add_option_table (optparse_t *p, */ optparse_err_t optparse_add_doc (optparse_t *p, const char *doc, int group); -optparse_err_t optparse_set (optparse_t *p, optparse_item_t item, ...); +optparse_err_t optparse_set (optparse_t *p, int item, ...); -optparse_err_t optparse_get (optparse_t *p, optparse_item_t item, ...); +optparse_err_t optparse_get (optparse_t *p, int item, ...); /* Set and get arbitrary ancillary data associated with an optparse * object. optparse_get_data () returns NULL if data not found.