[libvirt] [PATCH 3/3] build: avoid frame size error when building without -O2

Laine Stump laine at laine.org
Mon Mar 26 18:53:50 UTC 2012


libvirt always adds -Werror-frame-larger-than=4096 to the flags when
it builds. When building on Fedora 17, two functions with multiple
1024 buffers declared inside if {} blocks would generate frame size
errors; apparently the version of gcc on Fedora 16 will merge these
multiple buffers into a single buffer even when optimization is off,
but Fedora 17 won't.

The fix is to declare a single 1024 buffer at the top of the two
offending functions, and reuse the single buffer throughout the
functions.
---
 src/libxl/libxl_driver.c |    5 +----
 src/qemu/qemu_driver.c   |   10 ++--------
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index eccd198..fb18948 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -833,6 +833,7 @@ libxlStartup(int privileged) {
     char *log_file = NULL;
     virCommandPtr cmd;
     int status, ret = 0;
+    char ebuf[1024];
 
     /* Disable libxl driver if non-root */
     if (!privileged) {
@@ -893,25 +894,21 @@ libxlStartup(int privileged) {
         goto out_of_memory;
 
     if (virFileMakePath(libxl_driver->logDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create log dir '%s': %s"),
                   libxl_driver->logDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(libxl_driver->stateDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create state dir '%s': %s"),
                   libxl_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(libxl_driver->libDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create lib dir '%s': %s"),
                   libxl_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(libxl_driver->saveDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create save dir '%s': %s"),
                   libxl_driver->saveDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e574126..f4aea61 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -455,6 +455,7 @@ qemudStartup(int privileged) {
     char *driverConf = NULL;
     int rc;
     virConnectPtr conn = NULL;
+    char ebuf[1024];
 
     if (VIR_ALLOC(qemu_driver) < 0)
         return -1;
@@ -548,37 +549,31 @@ qemudStartup(int privileged) {
     }
 
     if (virFileMakePath(qemu_driver->stateDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create state dir '%s': %s"),
                   qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->libDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create lib dir '%s': %s"),
                   qemu_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->cacheDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create cache dir '%s': %s"),
                   qemu_driver->cacheDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->saveDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create save dir '%s': %s"),
                   qemu_driver->saveDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->snapshotDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create save dir '%s': %s"),
                   qemu_driver->snapshotDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->autoDumpPath) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create dump dir '%s': %s"),
                   qemu_driver->autoDumpPath, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
@@ -596,9 +591,8 @@ qemudStartup(int privileged) {
 
     rc = virCgroupForDriver("qemu", &qemu_driver->cgroup, privileged, 1);
     if (rc < 0) {
-        char buf[1024];
         VIR_INFO("Unable to create cgroup for driver: %s",
-                 virStrerror(-rc, buf, sizeof(buf)));
+                 virStrerror(-rc, ebuf, sizeof(ebuf)));
     }
 
     if (qemudLoadDriverConfig(qemu_driver, driverConf) < 0) {
-- 
1.7.7.6




More information about the libvir-list mailing list