[PATCH 4/4] vsh-table: Ensure NULL terminated arguments to vshTable*()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tests/vshtabletest.c | 4 ++--
 tools/vsh-table.h    | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c
index 2b997753ff..83d7f9b5ab 100644
--- a/tests/vshtabletest.c
+++ b/tests/vshtabletest.c
@@ -33,7 +33,7 @@
 static int
 testVshTableNew(const void *opaque G_GNUC_UNUSED)
 {
-    g_autoptr(vshTable) table = vshTableNew(NULL);
+    g_autoptr(vshTable) table = vshTableNew(NULL, NULL);
 
     if (table) {
         fprintf(stderr, "expected failure when passing null to vshTableNew\n");
@@ -85,7 +85,7 @@ testVshTableRowAppend(const void *opaque G_GNUC_UNUSED)
     if (!table)
         return -1;
 
-    if (vshTableRowAppend(table, NULL) >= 0) {
+    if (vshTableRowAppend(table, NULL, NULL) >= 0) {
         fprintf(stderr, "Appending NULL shouldn't work\n");
         return -1;
     }
diff --git a/tools/vsh-table.h b/tools/vsh-table.h
index df647e3ba9..18d5139aa6 100644
--- a/tools/vsh-table.h
+++ b/tools/vsh-table.h
@@ -29,10 +29,12 @@ vshTableFree(vshTable *table);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(vshTable, vshTableFree);
 
 vshTable *
-vshTableNew(const char *format, ...);
+vshTableNew(const char *format, ...)
+    G_GNUC_NULL_TERMINATED;
 
 int
-vshTableRowAppend(vshTable *table, const char *arg, ...);
+vshTableRowAppend(vshTable *table, const char *arg, ...)
+    G_GNUC_NULL_TERMINATED;
 
 void
 vshTablePrintToStdout(vshTable *table, vshControl *ctl);
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux