For some reason GCC 14.1.1 on Fedora 41 assumes that format can
be NULL and emits a warning:

 lib/util.c: In function 'xvasprintf':
 lib/util.c:229:14: error: null format string
   229 |     needed = vsnprintf(NULL, 0, format, args);
       |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I didn't find any users where this can be true.  Adding an
assertion to silence the warning.  In the worst case we'll
find out where it is being called incorrectly.

Signed-off-by: Ilya Maximets <[email protected]>
---
 lib/util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/util.c b/lib/util.c
index 5253921b2..bdd6408b2 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -225,6 +225,8 @@ xvasprintf(const char *format, va_list args)
     size_t needed;
     char *s;
 
+    ovs_assert(format);
+
     va_copy(args2, args);
     needed = vsnprintf(NULL, 0, format, args);
 
-- 
2.45.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to