Original commit message: Currently, a semicolon after a DEFINE_VECTOR_TYPE(...) macro invocation is not needed, nor does our documentation in "common/utils/vector.h" prescribe one. Furthermore, it breaks ISO C, which gcc reports with "-Wpedantic":
> warning: ISO C does not allow extra ‘;’ outside of a function > [-Wpedantic] Our current usage is inconsistent; a proper subset of all our DEFINE_VECTOR_TYPE() invocations is succeeded by a semicolon. We could remove these semicolons, but that doesn't play nicely with Emacs's C language parser. Thus, force the semicolon instead. Porting notes: - The call sites needing an update in nbdkit are distinct from those updated in libnbd commit f3bc106dbc17 ("force semicolon after DEFINE_VECTOR_TYPE() macro invocations", 2023-02-28). Thus, "cherry-picking f3bc106dbc17" only applies to "common/utils/vector.h"; the rest has to be reimplemented from zero. Signed-off-by: Laszlo Ersek <ler...@redhat.com> (cherry picked from libnbd commit f3bc106dbc178a993db0e2006469da9ae0bf8db2) --- common/utils/vector.h | 4 +++- common/replacements/open_memstream.c | 2 +- plugins/vddk/vddk.h | 2 +- plugins/blkio/blkio.c | 2 +- plugins/curl/pool.c | 2 +- plugins/vddk/stats.c | 2 +- filters/protect/protect.c | 2 +- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/common/utils/vector.h b/common/utils/vector.h index 90bbabd64c56..5f5f96e97ab2 100644 --- a/common/utils/vector.h +++ b/common/utils/vector.h @@ -52,7 +52,7 @@ /* Use of this macro defines a new type called ‘name’ containing an * extensible vector of ‘type’ elements. For example: * - * DEFINE_VECTOR_TYPE (string_vector, char *) + * DEFINE_VECTOR_TYPE (string_vector, char *); * * defines a new type called ‘string_vector’ as a vector of ‘char *’. * You can create variables of this type: @@ -195,6 +195,8 @@ return 0; \ } \ \ + /* End with duplicate declaration, so callers must supply ';'. */ \ + struct name #define empty_vector { .ptr = NULL, .len = 0, .cap = 0 } diff --git a/common/replacements/open_memstream.c b/common/replacements/open_memstream.c index e2d556e59fa2..bff880d3d9ae 100644 --- a/common/replacements/open_memstream.c +++ b/common/replacements/open_memstream.c @@ -62,7 +62,7 @@ struct file_to_memstream { char **ptr; size_t *size; }; -DEFINE_VECTOR_TYPE (file_vector, struct file_to_memstream) +DEFINE_VECTOR_TYPE (file_vector, struct file_to_memstream); static file_vector files = empty_vector; FILE * diff --git a/plugins/vddk/vddk.h b/plugins/vddk/vddk.h index e8cd4bfde1f8..1f33a1e179e1 100644 --- a/plugins/vddk/vddk.h +++ b/plugins/vddk/vddk.h @@ -146,7 +146,7 @@ struct command { enum { SUBMITTED, SUCCEEDED, FAILED } status; }; -DEFINE_VECTOR_TYPE (command_queue, struct command *) +DEFINE_VECTOR_TYPE (command_queue, struct command *); /* The per-connection handle. */ struct vddk_handle { diff --git a/plugins/blkio/blkio.c b/plugins/blkio/blkio.c index 68430d222650..6eafa2877e50 100644 --- a/plugins/blkio/blkio.c +++ b/plugins/blkio/blkio.c @@ -57,7 +57,7 @@ struct property { char *value; bool value_needs_free; }; -DEFINE_VECTOR_TYPE (properties, struct property) +DEFINE_VECTOR_TYPE (properties, struct property); static const char *driver = NULL; /* driver name - required */ static properties props = empty_vector; /* other command line params */ diff --git a/plugins/curl/pool.c b/plugins/curl/pool.c index 1eb4db6404bf..b903cdc07d3e 100644 --- a/plugins/curl/pool.c +++ b/plugins/curl/pool.c @@ -84,7 +84,7 @@ static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; * handles are requested. Currently it does not shrink. It may grow * up to 'connections' in length. */ -DEFINE_VECTOR_TYPE (curl_handle_list, struct curl_handle *) +DEFINE_VECTOR_TYPE (curl_handle_list, struct curl_handle *); static curl_handle_list curl_handles = empty_vector; /* The condition is used when the curl handles vector is full and diff --git a/plugins/vddk/stats.c b/plugins/vddk/stats.c index fb23c6a5bbfe..c16338b1e774 100644 --- a/plugins/vddk/stats.c +++ b/plugins/vddk/stats.c @@ -60,7 +60,7 @@ pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER; #undef STUB #undef OPTIONAL_STUB -DEFINE_VECTOR_TYPE (statlist, struct vddk_stat) +DEFINE_VECTOR_TYPE (statlist, struct vddk_stat); static int stat_compare (const void *vp1, const void *vp2) diff --git a/filters/protect/protect.c b/filters/protect/protect.c index 4e22a24bbcc9..b9edd062a367 100644 --- a/filters/protect/protect.c +++ b/filters/protect/protect.c @@ -57,7 +57,7 @@ * 'range_list' stores the list of protected ranges, unsorted. */ struct range { uint64_t start, end; const char *description; }; -DEFINE_VECTOR_TYPE (ranges, struct range) +DEFINE_VECTOR_TYPE (ranges, struct range); static ranges range_list; /* region_list covers the whole address space with protected and _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://listman.redhat.com/mailman/listinfo/libguestfs