mirror of https://gitee.com/openkylin/libvirt.git
vsh-table: Ensure NULL terminated arguments to vshTable*()
There are two functions that take variable arguments: vshTableNew() and vshTableRowAppend(). Both expect the list of arguments to be NULL terminated. Annotate them with G_GNUC_NULL_TERMINATED to enable compile time check for this. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2ac0e4c347
commit
5ce184f33c
|
@ -33,7 +33,7 @@
|
||||||
static int
|
static int
|
||||||
testVshTableNew(const void *opaque G_GNUC_UNUSED)
|
testVshTableNew(const void *opaque G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
g_autoptr(vshTable) table = vshTableNew(NULL);
|
g_autoptr(vshTable) table = vshTableNew(NULL, NULL);
|
||||||
|
|
||||||
if (table) {
|
if (table) {
|
||||||
fprintf(stderr, "expected failure when passing null to vshTableNew\n");
|
fprintf(stderr, "expected failure when passing null to vshTableNew\n");
|
||||||
|
@ -85,7 +85,7 @@ testVshTableRowAppend(const void *opaque G_GNUC_UNUSED)
|
||||||
if (!table)
|
if (!table)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (vshTableRowAppend(table, NULL) >= 0) {
|
if (vshTableRowAppend(table, NULL, NULL) >= 0) {
|
||||||
fprintf(stderr, "Appending NULL shouldn't work\n");
|
fprintf(stderr, "Appending NULL shouldn't work\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,12 @@ vshTableFree(vshTable *table);
|
||||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(vshTable, vshTableFree);
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(vshTable, vshTableFree);
|
||||||
|
|
||||||
vshTable *
|
vshTable *
|
||||||
vshTableNew(const char *format, ...);
|
vshTableNew(const char *format, ...)
|
||||||
|
G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
int
|
int
|
||||||
vshTableRowAppend(vshTable *table, const char *arg, ...);
|
vshTableRowAppend(vshTable *table, const char *arg, ...)
|
||||||
|
G_GNUC_NULL_TERMINATED;
|
||||||
|
|
||||||
void
|
void
|
||||||
vshTablePrintToStdout(vshTable *table, vshControl *ctl);
|
vshTablePrintToStdout(vshTable *table, vshControl *ctl);
|
||||||
|
|
Loading…
Reference in New Issue