]> xenbits.xensource.com Git - libvirt.git/commitdiff
lib: Annotate more function as NULL terminated
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 5 Jun 2024 13:50:16 +0000 (15:50 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 6 Jun 2024 07:29:58 +0000 (09:29 +0200)
While __attribute((sentinel)) (exposed by glib under
G_GNUC_NULL_TERMINATED macro) is a gcc extension, it's supported
by clang too. It's already being used throughout our code but
some functions that take variadic arguments and expect NULL at
the end were lacking such annotation. Fill them in.

After this, there are still some functions left untouched because
they expect a different sentinel than NULL. Unfortunately, glib
does not provide macro for different sentinels. We may come up
with our own, but let's save that for future work.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
tests/qemumigrationcookiexmltest.c
tests/testutils.h
tests/testutilsqemuschema.h
tools/vsh.c

index 6e819452010f33de1033d6de176e2c89573bf9ba..b78f539c8503bf3decdcf6fcbcefe5f97cf63b01 100644 (file)
@@ -947,7 +947,8 @@ int qemuMonitorDelDevice(qemuMonitor *mon,
 int qemuMonitorCreateObjectProps(virJSONValue **propsret,
                                  const char *type,
                                  const char *alias,
-                                 ...);
+                                 ...)
+    G_GNUC_NULL_TERMINATED;
 
 int qemuMonitorAddObject(qemuMonitor *mon,
                          virJSONValue **props,
index eb84a3d9384ae89a8aea75179b399dfea861cafa..c5e758e7f86d39455cab5c5568571b58a8c18208 100644 (file)
@@ -468,7 +468,7 @@ qemuMonitorJSONHasError(virJSONValue *reply,
  *
  * Returns 0 on success and -1 on error.
  */
-static int
+static int G_GNUC_NULL_TERMINATED
 qemuMonitorJSONTransactionAdd(virJSONValue *actions,
                               const char *cmdname,
                               ...)
index 5270e3a7e7372de37ba286498f77f1bde5a67d29..bc0f68b8c5cb2f28b449ddb794ff030b6bda4228 100644 (file)
@@ -39,7 +39,7 @@ static virQEMUDriver driver;
 
 static virBuffer testnamebuf = VIR_BUFFER_INITIALIZER;
 
-static const char *
+static const char * G_GNUC_NULL_TERMINATED
 tn(const char *str, ...)
 {
     va_list ap;
index e5469c5aa0f164d41f2c17288bea17bcc8211dc9..e22324e06d214a1d32c04583dc983b0f160877ec 100644 (file)
@@ -113,7 +113,8 @@ void virTestFakeRootDirCleanup(char *fakerootdir);
 int virTestMain(int argc,
                 char **argv,
                 int (*func)(void),
-                ...);
+                ...)
+    G_GNUC_NULL_TERMINATED;
 
 /* Setup, then call func() */
 #define VIR_TEST_MAIN(func) \
index cb1e6da69eaa91298eb5df6416c5879bf408fe1a..191e7639366da84a05847d16325e952e431cfc36 100644 (file)
@@ -40,7 +40,8 @@ testQEMUSchemaValidateCommand(const char *command,
 
 int
 testQEMUSchemaEntryMatchTemplate(virJSONValue *schemaentry,
-                                 ...);
+                                 ...)
+    G_GNUC_NULL_TERMINATED;
 
 
 virJSONValue *
index 6cc1f60d87cfba9c137d62c9fdde0da53c96c544..9fbb1f9349ca9917b7b6a6f642f8dbfc40018317 100644 (file)
@@ -2418,7 +2418,7 @@ vshCloseLogFile(vshControl *ctl)
 }
 
 #ifndef WIN32
-static void
+static void G_GNUC_NULL_TERMINATED
 vshPrintRaw(vshControl *ctl, ...)
 {
     va_list ap;