]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: avoid PATH_MAX-sized array
authorEric Blake <eblake@redhat.com>
Wed, 22 Jun 2011 20:03:30 +0000 (14:03 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 22 Jun 2011 23:13:58 +0000 (17:13 -0600)
See previous patch for why this is good...

* src/test/test_driver.c (struct _testConn, testOpenFromFile)
(testClose): Manage path dynamically.

src/test/test_driver.c

index 6c8b9cf80195622bd3c8bc3dcbe58cb48a4797ac..18f6a52c14d58c7e15d20eaf4db8e53c07956706 100644 (file)
@@ -77,7 +77,7 @@ typedef struct _testCell *testCellPtr;
 struct _testConn {
     virMutex lock;
 
-    char path[PATH_MAX];
+    char *path;
     int nextDomID;
     virCapsPtr caps;
     virNodeInfo nodeInfo;
@@ -790,9 +790,8 @@ static int testOpenFromFile(virConnectPtr conn,
 
     privconn->nextDomID = 1;
     privconn->numCells = 0;
-    if (virStrcpyStatic(privconn->path, file) == NULL) {
-        testError(VIR_ERR_INTERNAL_ERROR,
-                  _("Path %s too big for destination"), file);
+    if ((privconn->path = strdup(file)) == NULL) {
+        virReportOOMError();
         goto error;
     }
     memmove(&privconn->nodeInfo, &defaultNodeInfo, sizeof(defaultNodeInfo));
@@ -1090,6 +1089,7 @@ static int testOpenFromFile(virConnectPtr conn,
     virNetworkObjListFree(&privconn->networks);
     virInterfaceObjListFree(&privconn->ifaces);
     virStoragePoolObjListFree(&privconn->pools);
+    VIR_FREE(privconn->path);
     testDriverUnlock(privconn);
     VIR_FREE(privconn);
     conn->privateData = NULL;
@@ -1161,6 +1161,7 @@ static int testClose(virConnectPtr conn)
     virInterfaceObjListFree(&privconn->ifaces);
     virStoragePoolObjListFree(&privconn->pools);
     virDomainEventStateFree(privconn->domainEventState);
+    VIR_FREE(privconn->path);
 
     testDriverUnlock(privconn);
     virMutexDestroy(&privconn->lock);