[libvirt] [PATCH 17/17] avoid compiler warning when all storage backends are disabled

Jim Meyering jim at meyering.net
Tue Oct 28 11:21:34 UTC 2008


From: Jim Meyering <meyering at redhat.com>

* src/storage_backend.c (backends): Add a NULL terminator.
(virStorageBackendForType): Use NULL terminator rather than
warning-provoking (possibly 0) array size.
---
 src/storage_backend.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/storage_backend.c b/src/storage_backend.c
index e33f98c..1f4ed10 100644
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -82,13 +82,14 @@ static virStorageBackendPtr backends[] = {
 #if WITH_STORAGE_DISK
     &virStorageBackendDisk,
 #endif
+    NULL
 };


 virStorageBackendPtr
 virStorageBackendForType(int type) {
     unsigned int i;
-    for (i = 0 ; i < ARRAY_CARDINALITY(backends); i++)
+    for (i = 0; backends[i]; i++)
         if (backends[i]->type == type)
             return backends[i];

-- 
1.6.0.3.756.gb776d




More information about the libvir-list mailing list