serialization: revert va_args_commaprefix usage
What changed, and why it matters
This commit removes a recently added C preprocessor helper that automatically inserted commas before extra macro arguments. It reverts two serialization macros back to older, simpler forms that no longer accept extra trailing arguments. The change likely fixes build or compatibility problems caused by the new helper, especially on compilers that handle variadic macros differently. There is no direct evidence in the commit that this fixes an exploitable security vulnerability.
Treat as a code-quality/portability fix unless independent analysis shows the macro bug caused exploitable behavior. Review any code that may have started relying on the extra variadic arguments in BEGIN_SERIALIZE_OBJECT_FN, FIELD_N, or FIELD_F, and verify serialization round-trip tests still pass across supported compilers.
Security signals we found
Macro preprocessor behavior change in serialization code
Revert of recently introduced variadic-macro helper
Potential for subtle serialization signature mismatches if extra arguments were being silently dropped or mis-expanded
Evidence from the diff
The patch deletes VA_ARGS_COMMAPREFIX from src/common/va_args.h and removes its use in BEGIN_SERIALIZE_OBJECT_FN, FIELD_N, and FIELD_F in src/serialization/serialization.h. Those macros are restored to fixed-arity signatures without variadic trailing arguments. The original helper tried to use VA_OPT when available and fall back to GCC’s ,##VA_ARGS otherwise. Reverting it suggests the helper produced incorrect expansions or portability issues on some toolchains, which could affect serialization behavior or compilation. The diff itself does not show a memory-safety bug, input validation flaw, or cryptographic weakness.
Changed components
src/common/va_args.hsrc/serialization/serialization.hInspect captured patch +6 / −16
diff --git a/src/common/va_args.h b/src/common/va_args.h
index 3389b1c..65aa4e0 100644
--- a/src/common/va_args.h
+++ b/src/common/va_args.h
@@ -33,13 +33,3 @@
#define PP_THIRD_ARG(a,b,c,...) c
#define VA_OPT_SUPPORTED_I(...) PP_THIRD_ARG(__VA_OPT__(,),true,false,)
#define VA_OPT_SUPPORTED VA_OPT_SUPPORTED_I(?)
-
-// VA_ARGS_COMMAPREFIX(): VA_ARGS_COMMAPREFIX(__VA_ARGS__) expands to __VA_ARGS__ with a comma in
-// front if more than one argument, else nothing.
-// If __VA_OPT__ supported, use that. Else, use GCC's ,## hack
-#if VA_OPT_SUPPORTED
-# define VA_ARGS_COMMAPREFIX(...) __VA_OPT__(,) __VA_ARGS__
-#else
-# define VA_ARGS_COMMAPREFIX(...) , ## __VA_ARGS__
-#endif
-
diff --git a/src/serialization/serialization.h b/src/serialization/serialization.h
index 7ee9213..4287bb2 100644
--- a/src/serialization/serialization.h
+++ b/src/serialization/serialization.h
@@ -191,9 +191,9 @@ inline auto do_serialize(Archive &ar, T &v, Args&&... args)
* VARINT_FIELD_F(). Otherwise, this macro is similar to
* BEGIN_SERIALIZE_OBJECT(), as you should list only field serializations.
*/
-#define BEGIN_SERIALIZE_OBJECT_FN(stype, ...) \
- template <bool W, template <bool> class Archive> \
- bool do_serialize_object(Archive<W> &ar, stype &v VA_ARGS_COMMAPREFIX(__VA_ARGS__)) {
+#define BEGIN_SERIALIZE_OBJECT_FN(stype) \
+ template <bool W, template <bool> class Archive> \
+ bool do_serialize_object(Archive<W> &ar, stype &v) {
/*! \macro PREPARE_CUSTOM_VECTOR_SERIALIZATION
*/
@@ -211,10 +211,10 @@ inline auto do_serialize(Archive &ar, T &v, Args&&... args)
*
* \brief serializes a field \a f tagged \a t
*/
-#define FIELD_N(t, f, ...) \
+#define FIELD_N(t, f) \
do { \
ar.tag(t); \
- bool r = do_serialize(ar, f VA_ARGS_COMMAPREFIX(__VA_ARGS__)); \
+ bool r = do_serialize(ar, f); \
if (!r || !ar.good()) return false; \
} while(0);
@@ -233,7 +233,7 @@ inline auto do_serialize(Archive &ar, T &v, Args&&... args)
*
* \brief tags the field with the variable name and then serializes it (for use in a free function)
*/
-#define FIELD_F(f, ...) FIELD_N(#f, v.f VA_ARGS_COMMAPREFIX(__VA_ARGS__))
+#define FIELD_F(f) FIELD_N(#f, v.f)
/*! \macro FIELDS(f)
*
Why this scored 31/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.