X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fargpar%2Fargpar.c;h=21edec0ab7a85b23c26ab38ee2956c00450a1626;hb=3afa94aeca5a0daae40fd7b6cc96b7e4c150c7d8;hp=bf19808c54715657330d926268a3f04dd17a350c;hpb=4624dad0d79b63be45c5c6d7eb2920ba09746f06;p=lttng-tools.git diff --git a/src/common/argpar/argpar.c b/src/common/argpar/argpar.c index bf19808c5..21edec0ab 100644 --- a/src/common/argpar/argpar.c +++ b/src/common/argpar/argpar.c @@ -4,7 +4,6 @@ * Copyright 2019 Philippe Proulx */ -#include #include #include #include @@ -17,7 +16,7 @@ #define argpar_calloc(_type, _nmemb) ((_type *) calloc((_nmemb), sizeof(_type))) #define argpar_zalloc(_type) argpar_calloc(_type, 1) -#define ARGPAR_ASSERT(_cond) assert(_cond) +#define ARGPAR_ASSERT(_cond) ((void) sizeof((void) (_cond), 0)) #ifdef __MINGW_PRINTF_FORMAT # define ARGPAR_PRINTF_FORMAT __MINGW_PRINTF_FORMAT @@ -477,6 +476,15 @@ enum parse_orig_arg_opt_ret parse_long_opt(const char * const long_opt_arg, opt_arg = next_orig_arg; used_next_orig_arg = true; } + } else if (eq_pos) { + /* + * Unexpected `--opt=arg` style for a long option which + * doesn't accept an argument. + */ + argpar_string_append_printf(error, + "Unexpected argument for option `--%s`", + long_opt_name); + goto error; } /* Create and append option argument */