From cf57d345b585c1e3914642b950f7041a7aeb853e Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Mon, 26 Mar 2012 14:42:22 -0400 Subject: [PATCH] build: avoid frame size error when building without -O2 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 eccd198bcd..fb18948d4f 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 ea772cf594..d503debcc0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -426,6 +426,7 @@ qemudStartup(int privileged) { char *driverConf = NULL; int rc; virConnectPtr conn = NULL; + char ebuf[1024]; if (VIR_ALLOC(qemu_driver) < 0) return -1; @@ -519,37 +520,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; @@ -567,9 +562,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) {