lib: Annotate more function as NULL terminated

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>
This commit is contained in:
Michal Privoznik 2024-06-05 15:50:16 +02:00
parent 9d0c8618db
commit 86e511fafb
6 changed files with 9 additions and 6 deletions

View 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,

View 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,
...)

View 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;

View 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) \

View File

@ -40,7 +40,8 @@ testQEMUSchemaValidateCommand(const char *command,
int
testQEMUSchemaEntryMatchTemplate(virJSONValue *schemaentry,
...);
...)
G_GNUC_NULL_TERMINATED;
virJSONValue *

View File

@ -2418,7 +2418,7 @@ vshCloseLogFile(vshControl *ctl)
}
#ifndef WIN32
static void
static void G_GNUC_NULL_TERMINATED
vshPrintRaw(vshControl *ctl, ...)
{
va_list ap;