[libvirt] [PATCH 0/2] gnulib update

The latest gnulib update accidentally reintroduced -Wformat-nonliteral (by virtue of adding -Wformat=2, understood only by newer gcc), I almost got sucked into the rathole of fixing all our problems before I realized the real issue, but by then, I had already written patch 1. I'd like to get this in before the freeze, and then (hopefully) not touch .gnulib until after the release (we've been burned too many times by a .gnulib update after rc1). Eric Blake (2): error: drop old-style error reporting build: import latest gnulib, for mingw and syntax-check fixes .gnulib | 2 +- gnulib/local/lib/openpty.c.diff | 26 ------ gnulib/local/lib/pty.in.h.diff | 13 --- m4/virt-compile-warnings.m4 | 8 ++- src/fdstream.c | 2 +- src/libvirt_private.syms | 1 - src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor_json.c | 2 +- src/util/conf.c | 22 ++--- src/util/virterror.c | 2 +- src/util/virterror_internal.h | 8 -- src/xen/xen_hypervisor.c | 170 ++++++++++++++++----------------------- src/xenapi/xenapi_utils.c | 2 +- tests/testutils.c | 4 +- tools/virsh.c | 12 ++-- 15 files changed, 98 insertions(+), 178 deletions(-) delete mode 100644 gnulib/local/lib/openpty.c.diff delete mode 100644 gnulib/local/lib/pty.in.h.diff -- 1.7.7.3

While we still don't want to enable gcc's new -Wformat-literal warning, I found a rather easy case where the warning could be reduced, by getting rid of obsolete error-reporting practices. This is the last place where we were passing the (unused) net and conn arguments for constructing an error. * src/util/virterror_internal.h (virErrorMsg): Delete prototype. (virReportError): Delete macro. * src/util/virterror.c (virErrorMsg): Make static. * src/libvirt_private.syms (virterror_internal.h): Drop export. * src/util/conf.c (virConfError): Convert to macro. (virConfErrorHelper): New function, and adjust error calls. * src/xen/xen_hypervisor.c (virXenErrorFunc): Delete. (xenHypervisorGetSchedulerType) (xenHypervisorGetSchedulerParameters) (xenHypervisorSetSchedulerParameters) (xenHypervisorDomainBlockStats) (xenHypervisorDomainInterfaceStats) (xenHypervisorDomainGetOSType) (xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus): Update callers. --- src/libvirt_private.syms | 1 - src/util/conf.c | 22 ++--- src/util/virterror.c | 2 +- src/util/virterror_internal.h | 8 -- src/xen/xen_hypervisor.c | 170 +++++++++++++++++------------------------ 5 files changed, 79 insertions(+), 124 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9f2a224..74412b0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1370,7 +1370,6 @@ virSocketAddrSetPort; # virterror_internal.h virDispatchError; -virErrorMsg; virRaiseErrorFull; virReportErrorHelper; virReportOOMErrorFull; diff --git a/src/util/conf.c b/src/util/conf.c index c8dcc7f..92bc84a 100644 --- a/src/util/conf.c +++ b/src/util/conf.c @@ -89,27 +89,23 @@ struct _virConf { * * Handle an error at the xend daemon interface */ +#define virConfError(ctxt, error, info) \ + virConfErrorHelper(__FILE__, __FUNCTION__, __LINE__, ctxt, error, info) static void -virConfError(virConfParserCtxtPtr ctxt, - virErrorNumber error, const char *info) +virConfErrorHelper(const char *file, const char *func, size_t line, + virConfParserCtxtPtr ctxt, + virErrorNumber error, const char *info) { - const char *format; - if (error == VIR_ERR_OK) return; /* Construct the string 'filename:line: info' if we have that. */ if (ctxt && ctxt->filename) { - virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR, - info, ctxt->filename, NULL, - ctxt->line, 0, - "%s:%d: %s", ctxt->filename, ctxt->line, info); + virReportErrorHelper(VIR_FROM_CONF, error, file, func, line, + _("%s:%d: %s"), ctxt->filename, ctxt->line, info); } else { - format = virErrorMsg(error, info); - virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR, - info, NULL, NULL, - ctxt ? ctxt->line : 0, 0, - format, info); + virReportErrorHelper(VIR_FROM_CONF, error, file, func, line, + "%s", info); } } diff --git a/src/util/virterror.c b/src/util/virterror.c index 44a276a..e2a0f3a 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -755,7 +755,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED, * * Returns the constant string associated to @error */ -const char * +static const char * virErrorMsg(virErrorNumber error, const char *info) { const char *errmsg = NULL; diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h index d61ea0d..b8cb279 100644 --- a/src/util/virterror_internal.h +++ b/src/util/virterror_internal.h @@ -47,14 +47,6 @@ void virRaiseErrorFull(const char *filename, const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(12, 13); -/* Includes 'dom' and 'net' for compatbility, but they're ignored */ -# define virRaiseError(dom, net, domain, code, level, \ - str1, str2, str3, int1, int2, msg, ...) \ - virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__, \ - domain, code, level, str1, str2, str3, int1, int2, \ - msg, __VA_ARGS__) - -const char *virErrorMsg(virErrorNumber error, const char *info); void virReportErrorHelper(int domcode, int errcode, const char *filename, const char *funcname, diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 870bc4f..ef64177 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -827,40 +827,6 @@ struct xenUnifiedDriver xenHypervisorDriver = { __FUNCTION__, __LINE__, __VA_ARGS__) /** - * virXenErrorFunc: - * @error: the error number - * @func: the function failing - * @info: extra information string - * @value: extra information number - * - * Handle an error at the xend daemon interface - */ -static void -virXenErrorFunc(virErrorNumber error, const char *func, const char *info, - int value) -{ - char fullinfo[1000]; - const char *errmsg; - - if ((error == VIR_ERR_OK) || (in_init != 0)) - return; - - - errmsg =virErrorMsg(error, info); - if (func != NULL) { - snprintf(fullinfo, 999, "%s: %s", func, info); - fullinfo[999] = 0; - virRaiseError(NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, - errmsg, fullinfo, NULL, value, 0, errmsg, fullinfo, - value); - } else { - virRaiseError(NULL, NULL, VIR_FROM_XEN, error, VIR_ERR_ERROR, - errmsg, info, NULL, value, 0, errmsg, info, - value); - } -} - -/** * xenHypervisorDoV0Op: * @handle: the handle to the Xen hypervisor * @op: pointer to the hypervisor operation structure @@ -1142,15 +1108,15 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams) xenUnifiedPrivatePtr priv; if (domain->conn == NULL) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "domain or conn is NULL", 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domain or conn is NULL")); return NULL; } priv = (xenUnifiedPrivatePtr) domain->conn->privateData; if (priv->handle < 0) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "priv->handle invalid", 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("priv->handle invalid")); return NULL; } if (domain->id < 0) { @@ -1165,8 +1131,8 @@ xenHypervisorGetSchedulerType(virDomainPtr domain, int *nparams) * TODO: check on Xen 3.0.3 */ if (hv_versions.dom_interface < 5) { - virXenErrorFunc(VIR_ERR_NO_XEN, __FUNCTION__, - "unsupported in dom interface < 5", 0); + virXenError(VIR_ERR_NO_XEN, "%s", + _("unsupported in dom interface < 5")); return NULL; } @@ -1223,15 +1189,15 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain, xenUnifiedPrivatePtr priv; if (domain->conn == NULL) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "domain or conn is NULL", 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domain or conn is NULL")); return -1; } priv = (xenUnifiedPrivatePtr) domain->conn->privateData; if (priv->handle < 0) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "priv->handle invalid", 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("priv->handle invalid")); return -1; } if (domain->id < 0) { @@ -1246,8 +1212,8 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain, * TODO: check on Xen 3.0.3 */ if (hv_versions.dom_interface < 5) { - virXenErrorFunc(VIR_ERR_NO_XEN, __FUNCTION__, - "unsupported in dom interface < 5", 0); + virXenError(VIR_ERR_NO_XEN, "%s", + _("unsupported in dom interface < 5")); return -1; } @@ -1309,8 +1275,9 @@ xenHypervisorGetSchedulerParameters(virDomainPtr domain, *nparams = XEN_SCHED_CRED_NPARAM; break; default: - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, - "Unknown scheduler", op_sys.u.getschedulerid.sched_id); + virXenError(VIR_ERR_INVALID_ARG, + _("Unknown scheduler %d"), + op_sys.u.getschedulerid.sched_id); return -1; } } @@ -1337,8 +1304,8 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain, char buf[256]; if (domain->conn == NULL) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "domain or conn is NULL", 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domain or conn is NULL")); return -1; } @@ -1349,8 +1316,8 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain, priv = (xenUnifiedPrivatePtr) domain->conn->privateData; if (priv->handle < 0) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "priv->handle invalid", 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("priv->handle invalid")); return -1; } if (domain->id < 0) { @@ -1365,8 +1332,8 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain, * TODO: check on Xen 3.0.3 */ if (hv_versions.dom_interface < 5) { - virXenErrorFunc(VIR_ERR_NO_XEN, __FUNCTION__, - "unsupported in dom interface < 5", 0); + virXenError(VIR_ERR_NO_XEN, "%s", + _("unsupported in dom interface < 5")); return -1; } @@ -1405,8 +1372,9 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain, params[i].type == VIR_TYPED_PARAM_UINT) { val = params[i].value.ui; if ((val < 1) || (val > USHRT_MAX)) { - snprintf(buf, sizeof(buf), _("Credit scheduler weight parameter (%d) is out of range (1-65535)"), val); - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, buf, val); + virXenError(VIR_ERR_INVALID_ARG, + _("Credit scheduler weight parameter (%d) " + "is out of range (1-65535)"), val); return(-1); } op_dom.u.getschedinfo.u.credit.weight = val; @@ -1414,15 +1382,16 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain, params[i].type == VIR_TYPED_PARAM_UINT) { val = params[i].value.ui; if (val >= USHRT_MAX) { - snprintf(buf, sizeof(buf), _("Credit scheduler cap parameter (%d) is out of range (0-65534)"), val); - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, buf, val); + virXenError(VIR_ERR_INVALID_ARG, + _("Credit scheduler cap parameter (%d) is " + "out of range (0-65534)"), val); return(-1); } op_dom.u.getschedinfo.u.credit.cap = val; } else { - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, - "Credit scheduler accepts 'cap' and 'weight' integer parameters", - 0); + virXenError(VIR_ERR_INVALID_ARG, "%s", + _("Credit scheduler accepts 'cap' and " + "'weight' integer parameters")); return(-1); } } @@ -1433,8 +1402,9 @@ xenHypervisorSetSchedulerParameters(virDomainPtr domain, break; } default: - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, - "Unknown scheduler", op_sys.u.getschedulerid.sched_id); + virXenError(VIR_ERR_INVALID_ARG, + _("Unknown scheduler %d"), + op_sys.u.getschedulerid.sched_id); return -1; } } @@ -1459,9 +1429,8 @@ xenHypervisorDomainBlockStats (virDomainPtr dom, xenUnifiedUnlock(priv); return ret; #else - virXenErrorFunc(VIR_ERR_OPERATION_INVALID, __FUNCTION__, - "block statistics not supported on this platform", - dom->id); + virXenError(VIR_ERR_OPERATION_INVALID, "%s", + _("block statistics not supported on this platform")); return -1; #endif } @@ -1484,21 +1453,21 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom, /* Verify that the vif requested is one belonging to the current * domain. */ - if (sscanf (path, "vif%d.%d", &rqdomid, &device) != 2) { - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, - "invalid path, should be vif<domid>.<n>.", 0); + if (sscanf(path, "vif%d.%d", &rqdomid, &device) != 2) { + virXenError(VIR_ERR_INVALID_ARG, "%s", + _("invalid path, should be vif<domid>.<n>.")); return -1; } if (rqdomid != dom->id) { - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, - "invalid path, vif<domid> should match this domain ID", 0); + virXenError(VIR_ERR_INVALID_ARG, "%s", + _("invalid path, vif<domid> should match this domain ID")); return -1; } return linuxDomainInterfaceStats(path, stats); #else - virXenErrorFunc(VIR_ERR_OPERATION_INVALID, __FUNCTION__, - "/proc/net/dev: Interface not found", 0); + virXenError(VIR_ERR_OPERATION_INVALID, "%s", + _("/proc/net/dev: Interface not found")); return -1; #endif } @@ -2897,30 +2866,30 @@ xenHypervisorDomainGetOSType (virDomainPtr dom) priv = (xenUnifiedPrivatePtr) dom->conn->privateData; if (priv->handle < 0) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - _("domain shut off or invalid"), 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domain shut off or invalid")); return (NULL); } /* HV's earlier than 3.1.0 don't include the HVM flags in guests status*/ if (hv_versions.hypervisor < 2 || hv_versions.dom_interface < 4) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - _("unsupported in dom interface < 4"), 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("unsupported in dom interface < 4")); return (NULL); } XEN_GETDOMAININFO_CLEAR(dominfo); if (virXen_getdomaininfo(priv->handle, dom->id, &dominfo) < 0) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - _("cannot get domain details"), 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get domain details")); return (NULL); } if (XEN_GETDOMAININFO_DOMAIN(dominfo) != dom->id) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - _("cannot get domain details"), 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get domain details")); return (NULL); } @@ -3319,22 +3288,21 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *free xenUnifiedPrivatePtr priv; if (conn == NULL) { - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, - "invalid argument", 0); + virXenError(VIR_ERR_INVALID_ARG, "%s", _("invalid argument")); return -1; } priv = conn->privateData; if (priv->nbNodeCells < 0) { - virXenErrorFunc(VIR_ERR_XEN_CALL, __FUNCTION__, - "cannot determine actual number of cells",0); + virXenError(VIR_ERR_XEN_CALL, "%s", + _("cannot determine actual number of cells")); return(-1); } if ((maxCells < 1) || (startCell >= priv->nbNodeCells)) { - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, - "invalid argument", 0); + virXenError(VIR_ERR_INVALID_ARG, "%s", + _("invalid argument")); return -1; } @@ -3342,14 +3310,14 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn, unsigned long long *free * Support only hv_versions.sys_interface >=4 */ if (hv_versions.sys_interface < SYS_IFACE_MIN_VERS_NUMA) { - virXenErrorFunc(VIR_ERR_XEN_CALL, __FUNCTION__, - "unsupported in sys interface < 4", 0); + virXenError(VIR_ERR_XEN_CALL, "%s", + _("unsupported in sys interface < 4")); return -1; } if (priv->handle < 0) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - "priv->handle invalid", 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("priv->handle invalid")); return -1; } @@ -3590,13 +3558,13 @@ xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo, if (priv->handle < 0 || (domain->id < 0) || (info == NULL) || (maxinfo < 1) || (sizeof(cpumap_t) & 7)) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - _("domain shut off or invalid"), 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("domain shut off or invalid")); return (-1); } if ((cpumaps != NULL) && (maplen < 1)) { - virXenErrorFunc(VIR_ERR_INVALID_ARG, __FUNCTION__, - "invalid argument", 0); + virXenError(VIR_ERR_INVALID_ARG, "%s", + _("invalid argument")); return -1; } /* first get the number of virtual CPUs in this domain */ @@ -3605,8 +3573,8 @@ xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo, &dominfo); if ((ret < 0) || (XEN_GETDOMAININFO_DOMAIN(dominfo) != domain->id)) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - _("cannot get domain details"), 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get domain details")); return (-1); } nbinfo = XEN_GETDOMAININFO_CPUCOUNT(dominfo) + 1; @@ -3622,16 +3590,16 @@ xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo, (unsigned char *)VIR_GET_CPUMAP(cpumaps, maplen, i), maplen); if (ret < 0) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - _("cannot get VCPUs info"), 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get VCPUs info")); return(-1); } } else { ret = virXen_getvcpusinfo(priv->handle, domain->id, i, ipt, NULL, 0); if (ret < 0) { - virXenErrorFunc(VIR_ERR_INTERNAL_ERROR, __FUNCTION__, - _("cannot get VCPUs info"), 0); + virXenError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get VCPUs info")); return(-1); } } -- 1.7.7.3

Gnulib has picked up our fixes for openpty on mingw. It has also added support for a new gcc warning option, -Wunsuffixed-float-constants, which was pretty easy to silence (sometimes, using 'float' is more efficient than the default of 'double' that you get for an unsuffixed constant). * .gnulib: Update to latest, for openpty fixes, and improved 'make syntax-check' and compiler warnings. * gnulib/local/lib/pty.in.h.diff: Delete, no longer needed. * gnulib/local/lib/openpty.c.diff: Likewise. * m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Re-silence -Wformat-nonliteral. * src/fdstream.c (virFDStreamConnectUNIX): Suffix floating point constants. * src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise. * src/qemu/qemu_monitor.c (qemuMonitorOpenUnix): Likewise. * src/qemu/qemu_monitor_json.c (qemuMonitorJSONSetMigrationDowntime): Likewise. * tools/virsh.c (cmdDomControl, cmdDominfo, cmdVcpuinfo) (print_job_progress, DIFF_MSEC): Likewise. * tests/testutils.c (DIFF_MSEC): Likewise. --- * .gnulib e56e96f...908690c (79):
hash: mark compute_bucket_size with the pure attribute quotearg, propername: correct pragma guard expression propername: do not mark proper_name with the const attribute propername: mark one more function as const mark functions with const and pure attributes Remove unused macros from !_LIBC code in glibc-borrowed files. getcwd: Fix link error on MSVC 9. Don't set REPLACE_FOO to 1 if HAVE_FOO is 0. getcwd: Fix bug from 2011-08-17. binary-io tests: Avoid test failure on mingw when libtool is used. Fix conflict between two instantiations of module 'unistd'. pagealign_alloc: Doc and comments. test-update-copyright.sh: avoid false-positive failure valgrind-tests.m4: Avoid breakage if valgrind on bash fails. test-stdalign.c: comment out long double tests init.sh: make "compare /dev/null FILE" output more readable init.sh: work around OSF/1 5.1's mishandling of /dev/null gnulib-common: Silence warnings against config.h code. autoupdate getcwd: Work around getcwd bug on AIX 5..7. getcwd: Fix bug from 2009-09-10. manywarnings: More warnings. fma tests: Avoid shadowing local variables. copysignf tests: Fix. fma: Remove unused code. sethostname: Fix doc about AIX. sethostname: Mention more portability problems. Depend on module fcntl-h when AT_FDCWD is used. euidaccess: Update a comment. openat: Fix file list. fstatat: Simplify. Ensure 'inline' can be used in tests/test-utimens-common.h. hash: Don't refer to deprecated interfaces. readline: Check for readline/history.h. test-getcwd: disambiguate exit status fstatat: fix configuration bug on mingw, OpenBSD 4, Solaris 8 hash: deprecate poorly-named hash_insert0: use hash_insert_if_absent openat: avoid compilation failure due to lack of <errno.h> inclusion * modules/getcwd (Depends-on): Add fdopendir. modules/crypto/gc-*: simplify dependencies and fix stdalign.h bug tests: factor out st_ctime-comparison code (a dozen uses) test-getcwd: don't leave behind a confdir3/ directory upon interrupt gitlog-to-changelog: support multi-author commits. Fix some modules' file list. maint.mk: fix tight-scope.mk generation in VPATH builds. Silence successful tests that use 'compare' on AIX, HP-UX, Solaris. Makefile: Tweak indentation. Syntax check for copyright statements. Fix for last commit. git-version-gen: Add --prefix. git-version: Improve command line handling. revamp the other test-exclude?.sh scripts to use init.sh, too test-exclude2.sh, test-exclude5.sh: fail if test-exclude fails test-exclude: fix a typo autoupdate obstack: Fix compilation error on MSVC 9. test-exclude: skip tests rather than failing on deficient systems ptsname_r test: Avoid gcc warning on glibc systems. ptsname_r: Avoid compilation error on OSF/1 5.1. fstatat: Make cross-compilation guess succeed everywhere except on AIX. ptsname_r tests: Fix bugs. fstatat: work with cross-compilation Improve MODULES.html output. ptsname_r-tests: new test module update from texinfo ptsname_r: new module announce-gen: be more concise when there's only one URL+tarball openpty: provide a stub on mingw raise: fix mingw handling of SIGPIPE More conditional dependencies. faccessat: Move AC_LIBOBJ invocation to module description. faccessat: Simplify autoconf macro. renameat: Fix dependencies. mkfifoat: Fix module description. fstatat: Remove unused dependency. GNUmakefile: behave when Makefile is missing. openat: Conditionalize dependencies. maint.mk: extract GPG key ID without using a temporary file grantpt: fix typo
.gnulib | 2 +- gnulib/local/lib/openpty.c.diff | 26 -------------------------- gnulib/local/lib/pty.in.h.diff | 13 ------------- m4/virt-compile-warnings.m4 | 8 ++++++-- src/fdstream.c | 2 +- src/qemu/qemu_monitor.c | 2 +- src/qemu/qemu_monitor_json.c | 2 +- src/xenapi/xenapi_utils.c | 2 +- tests/testutils.c | 4 ++-- tools/virsh.c | 12 ++++++------ 10 files changed, 19 insertions(+), 54 deletions(-) delete mode 100644 gnulib/local/lib/openpty.c.diff delete mode 100644 gnulib/local/lib/pty.in.h.diff diff --git a/.gnulib b/.gnulib index e56e96f..908690c 160000 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit e56e96fe20f72586e9ec5c528b9a9a06daa2ecc6 +Subproject commit 908690cb743e69c73b42ae310807b29800c8764b diff --git a/gnulib/local/lib/openpty.c.diff b/gnulib/local/lib/openpty.c.diff deleted file mode 100644 index f17e566..0000000 --- a/gnulib/local/lib/openpty.c.diff +++ /dev/null @@ -1,26 +0,0 @@ -diff --git c/lib/openpty.c i/lib/openpty.c -index c398db5..d61d5ba 100644 ---- c/lib/openpty.c -+++ i/lib/openpty.c -@@ -32,6 +32,21 @@ rpl_openpty (int *amaster, int *aslave, char *name, - (struct winsize *) winp); - } - -+#elif (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ /* mingw */ -+ -+# include <errno.h> -+ -+int -+openpty (int *amaster _GL_UNUSED, int *aslave _GL_UNUSED, -+ char *name _GL_UNUSED, -+ struct termios const *termp _GL_UNUSED, -+ struct winsize const *winp _GL_UNUSED) -+{ -+ /* Mingw lacks pseudo-terminals altogether. */ -+ errno = ENOSYS; -+ return -1; -+} -+ - #else /* AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, mingw */ - - # include <fcntl.h> diff --git a/gnulib/local/lib/pty.in.h.diff b/gnulib/local/lib/pty.in.h.diff deleted file mode 100644 index 9470700..0000000 --- a/gnulib/local/lib/pty.in.h.diff +++ /dev/null @@ -1,13 +0,0 @@ -diff --git c/lib/pty.in.h i/lib/pty.in.h -index aff989c..00eecc6 100644 ---- c/lib/pty.in.h -+++ i/lib/pty.in.h -@@ -92,6 +92,8 @@ _GL_WARN_ON_USE (forkpty, "forkpty is not declared consistently - " - /* Create pseudo tty master slave pair and set terminal attributes - according to TERMP and WINP. Return handles for both ends in - *AMASTER and *ASLAVE, and return the name of the slave end in NAME. */ -+struct termios; -+struct winsize; - # if @REPLACE_OPENPTY@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef openpty diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 305036f..213b3db 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -55,8 +55,8 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # Things like virAsprintf mean we can't use this dontwarn="$dontwarn -Wformat-nonliteral" - # We might fundamentally need some of these disabled forever, but ideally - # we'd turn many of them on + # We might fundamentally need some of these disabled forever, but + # ideally we'd turn many of them on dontwarn="$dontwarn -Wfloat-equal" dontwarn="$dontwarn -Wdeclaration-after-statement" dontwarn="$dontwarn -Wcast-qual" @@ -88,6 +88,10 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # that one off, so we need to manually enable this again gl_WARN_ADD([-Wjump-misses-init]) + # GNULIB turns on -Wformat=2 which implies -Wformat-nonliteral, + # so we need to manually re-exclude it. + gl_WARN_ADD([-Wno-format-nonliteral]) + # This should be < 256 really. Currently we're down to 4096, # but using 1024 bytes sized buffers (mostly for virStrerror) # stops us from going down further diff --git a/src/fdstream.c b/src/fdstream.c index 841f979..1471c65 100644 --- a/src/fdstream.c +++ b/src/fdstream.c @@ -482,7 +482,7 @@ int virFDStreamConnectUNIX(virStreamPtr st, } goto error; - } while ((++i <= timeout*5) && (usleep(.2 * 1000000) <= 0)); + } while ((++i <= timeout*5) && (usleep(.2F * 1000000) <= 0)); if (virFDStreamOpenInternal(st, fd, NULL, -1, 0) < 0) goto error; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 73e5ea9..1a5b7d8 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -252,7 +252,7 @@ qemuMonitorOpenUnix(const char *monitor, pid_t cpid) _("failed to connect to monitor socket")); goto error; - } while ((++i <= timeout*5) && (usleep(.2 * 1000000) <= 0)); + } while ((++i <= timeout*5) && (usleep(.2F * 1000000) <= 0)); if (ret != 0) { virReportSystemError(errno, "%s", diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 56a62db..9187ab0 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2083,7 +2083,7 @@ int qemuMonitorJSONSetMigrationDowntime(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; cmd = qemuMonitorJSONMakeCommand("migrate_set_downtime", - "d:value", downtime / 1000.0, + "d:value", downtime / 1000.0D, NULL); if (!cmd) return -1; diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index 79fd946..888497b 100644 --- a/src/xenapi/xenapi_utils.c +++ b/src/xenapi/xenapi_utils.c @@ -548,7 +548,7 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def, (*record)->other_config = xen_string_string_map_alloc(0); (*record)->last_boot_cpu_flags = xen_string_string_map_alloc(0); (*record)->xenstore_data = xen_string_string_map_alloc(0); - (*record)->hvm_shadow_multiplier = 1.000; + (*record)->hvm_shadow_multiplier = 1; if (!xen_vm_create(((struct _xenapiPrivate *)(conn->privateData))->session, vm, *record)) { xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL); diff --git a/tests/testutils.c b/tests/testutils.c index acdfdc1..bac47a1 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -45,8 +45,8 @@ #define GETTIMEOFDAY(T) gettimeofday(T, NULL) #define DIFF_MSEC(T, U) \ - ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \ - ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0) + ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0D + \ + ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0D) #include "virfile.h" diff --git a/tools/virsh.c b/tools/virsh.c index d8e5dae..e1303fa 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -73,8 +73,8 @@ static char *progname; #define GETTIMEOFDAY(T) gettimeofday(T, NULL) #define DIFF_MSEC(T, U) \ - ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \ - ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0) + ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0D + \ + ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0D) /** * The log configuration @@ -1037,7 +1037,7 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd) info.state != VIR_DOMAIN_CONTROL_ERROR) { vshPrint(ctl, "%s (%0.3fs)\n", _(vshDomainControlStateToString(info.state)), - info.stateTime / 1000.0); + info.stateTime / 1000.0D); } else { vshPrint(ctl, "%s\n", _(vshDomainControlStateToString(info.state))); @@ -3337,7 +3337,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) if (info.cpuTime != 0) { double cpuUsed = info.cpuTime; - cpuUsed /= 1000000000.0; + cpuUsed /= 1000000000; vshPrint(ctl, "%-15s %.1lfs\n", _("CPU time:"), cpuUsed); } @@ -3964,7 +3964,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) if (cpuinfo[n].cpuTime != 0) { double cpuUsed = cpuinfo[n].cpuTime; - cpuUsed /= 1000000000.0; + cpuUsed /= 1000000000; vshPrint(ctl, "%-15s %.1lfs\n", _("CPU time:"), cpuUsed); } @@ -5692,7 +5692,7 @@ print_job_progress(const char *label, unsigned long long remaining, progress = 100; } else { /* use float to avoid overflow */ - progress = (int)(100.0 - remaining * 100.0 / total); + progress = (int)(100.0F - remaining * 100.0F / total); if (progress >= 100) { /* migration has not completed, do not print [100 %] */ progress = 99; -- 1.7.7.3

On 11/29/2011 06:53 AM, Eric Blake wrote:
Gnulib has picked up our fixes for openpty on mingw. It has also added support for a new gcc warning option, -Wunsuffixed-float-constants, which was pretty easy to silence (sometimes, using 'float' is more efficient than the default of 'double' that you get for an unsuffixed constant).
Upstream gnulib is debating this still; the only way to silence -Wunsuffixed-float-constants is to use non-portable code (C99 requires 1.0F, but not 1.0D), so it will likely be pulled, rendering half of this commit pointless. I'll post a v2 once the upstream gnulib dust settles. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

* .gnulib: Update to latest, for improved 'make syntax-check' and compiler warnings. * m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Re-silence -Wformat-nonliteral. * cfg.mk (_test_script_regex): Recognize our test scripts. * gnulib/local/lib/*.diff: Drop, now that gnulib has this. * tests/virsh-optparse: Fix use of compare. * tests/virsh-schedinfo: Likewise. --- v2: slightly newer gnulib; drop changes for unsuffixed float warning, and add fixes for misuse of 'compare' in tests. .gnulib | 2 +- cfg.mk | 3 +++ gnulib/local/lib/openpty.c.diff | 26 -------------------------- gnulib/local/lib/pty.in.h.diff | 13 ------------- m4/virt-compile-warnings.m4 | 8 ++++++-- tests/virsh-optparse | 10 +++++----- tests/virsh-schedinfo | 6 +++--- 7 files changed, 18 insertions(+), 50 deletions(-) delete mode 100644 gnulib/local/lib/openpty.c.diff delete mode 100644 gnulib/local/lib/pty.in.h.diff diff --git a/.gnulib b/.gnulib index e56e96f..a5f6df2 160000 --- a/.gnulib +++ b/.gnulib @@ -1 +1 @@ -Subproject commit e56e96fe20f72586e9ec5c528b9a9a06daa2ecc6 +Subproject commit a5f6df2b1f3f0fdc73635de3ad285d21703dab18 diff --git a/cfg.mk b/cfg.mk index 574c7a4..817b5f3 100644 --- a/cfg.mk +++ b/cfg.mk @@ -36,6 +36,9 @@ generated_files = \ $(srcdir)/src/remote/*_protocol.[ch] \ $(srcdir)/gnulib/lib/*.[ch] +# We haven't converted all scripts to using gnulib's init.sh yet. +_test_script_regex = \<\(init\|test-lib\)\.sh\> + # Tests not to run as part of "make distcheck". local-checks-to-skip = \ changelog-check \ diff --git a/gnulib/local/lib/openpty.c.diff b/gnulib/local/lib/openpty.c.diff deleted file mode 100644 index f17e566..0000000 --- a/gnulib/local/lib/openpty.c.diff +++ /dev/null @@ -1,26 +0,0 @@ -diff --git c/lib/openpty.c i/lib/openpty.c -index c398db5..d61d5ba 100644 ---- c/lib/openpty.c -+++ i/lib/openpty.c -@@ -32,6 +32,21 @@ rpl_openpty (int *amaster, int *aslave, char *name, - (struct winsize *) winp); - } - -+#elif (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ /* mingw */ -+ -+# include <errno.h> -+ -+int -+openpty (int *amaster _GL_UNUSED, int *aslave _GL_UNUSED, -+ char *name _GL_UNUSED, -+ struct termios const *termp _GL_UNUSED, -+ struct winsize const *winp _GL_UNUSED) -+{ -+ /* Mingw lacks pseudo-terminals altogether. */ -+ errno = ENOSYS; -+ return -1; -+} -+ - #else /* AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, mingw */ - - # include <fcntl.h> diff --git a/gnulib/local/lib/pty.in.h.diff b/gnulib/local/lib/pty.in.h.diff deleted file mode 100644 index 9470700..0000000 --- a/gnulib/local/lib/pty.in.h.diff +++ /dev/null @@ -1,13 +0,0 @@ -diff --git c/lib/pty.in.h i/lib/pty.in.h -index aff989c..00eecc6 100644 ---- c/lib/pty.in.h -+++ i/lib/pty.in.h -@@ -92,6 +92,8 @@ _GL_WARN_ON_USE (forkpty, "forkpty is not declared consistently - " - /* Create pseudo tty master slave pair and set terminal attributes - according to TERMP and WINP. Return handles for both ends in - *AMASTER and *ASLAVE, and return the name of the slave end in NAME. */ -+struct termios; -+struct winsize; - # if @REPLACE_OPENPTY@ - # if !(defined __cplusplus && defined GNULIB_NAMESPACE) - # undef openpty diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 305036f..213b3db 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -55,8 +55,8 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # Things like virAsprintf mean we can't use this dontwarn="$dontwarn -Wformat-nonliteral" - # We might fundamentally need some of these disabled forever, but ideally - # we'd turn many of them on + # We might fundamentally need some of these disabled forever, but + # ideally we'd turn many of them on dontwarn="$dontwarn -Wfloat-equal" dontwarn="$dontwarn -Wdeclaration-after-statement" dontwarn="$dontwarn -Wcast-qual" @@ -88,6 +88,10 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # that one off, so we need to manually enable this again gl_WARN_ADD([-Wjump-misses-init]) + # GNULIB turns on -Wformat=2 which implies -Wformat-nonliteral, + # so we need to manually re-exclude it. + gl_WARN_ADD([-Wno-format-nonliteral]) + # This should be < 256 really. Currently we're down to 4096, # but using 1024 bytes sized buffers (mostly for virStrerror) # stops us from going down further diff --git a/tests/virsh-optparse b/tests/virsh-optparse index d0d4329..fc2279f 100755 --- a/tests/virsh-optparse +++ b/tests/virsh-optparse @@ -65,7 +65,7 @@ for args in \ '--count=2 test' \ ; do virsh -d0 -c $test_url setvcpus $args >out 2>>err || fail=1 - LC_ALL=C sort out | compare - exp-out || fail=1 + LC_ALL=C sort out | compare exp-out - || fail=1 done # Another complex parsing example @@ -84,7 +84,7 @@ EOF virsh -q -c $test_url snapshot-create-as --print-xml test \ --diskspec 'vda,file=a&b,,c,snapshot=external' --description '1<2' \ --diskspec vdb >out 2>>err || fail=1 -compare out exp-out || fail=1 +compare exp-out out || fail=1 cat <<\EOF > exp-out || framework_failure <domainsnapshot> @@ -98,7 +98,7 @@ cat <<\EOF > exp-out || framework_failure EOF virsh -q -c $test_url snapshot-create-as --print-xml test name vda vdb \
out 2>>err || fail=1 -compare out exp-out || fail=1 +compare exp-out out || fail=1
cat <<\EOF > exp-out || framework_failure <domainsnapshot> @@ -122,7 +122,7 @@ for args in \ ; do virsh -q -c $test_url snapshot-create-as --print-xml $args \ >out 2>>err || fail=1 - compare out exp-out || fail=1 + compare exp-out out || fail=1 done test -s err && fail=1 @@ -133,6 +133,6 @@ error: this function is not supported by the connection driver: virDomainQemuMon EOF virsh -q -c $test_url qemu-monitor-command test a >out 2>err && fail=1 test -s out && fail=1 -compare err exp-err || fail=1 +compare exp-err err || fail=1 (exit $fail); exit $fail diff --git a/tests/virsh-schedinfo b/tests/virsh-schedinfo index 9d885ee..8ea4ce4 100755 --- a/tests/virsh-schedinfo +++ b/tests/virsh-schedinfo @@ -1,7 +1,7 @@ #!/bin/sh # Ensure that virsh schedinfo --set invalid=val fails -# Copyright (C) 2010 Red Hat, Inc. +# Copyright (C) 2010-2011 Red Hat, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,7 +43,7 @@ fail=0 test_url=test:///default virsh -c $test_url schedinfo 1 --set j=k >out 2>err && fail=1 -compare out exp-out || fail=1 -compare err exp-err || fail=1 +compare exp-out out || fail=1 +compare exp-err err || fail=1 (exit $fail); exit $fail -- 1.7.7.3

On 11/29/2011 04:54 PM, Eric Blake wrote:
* .gnulib: Update to latest, for improved 'make syntax-check' and compiler warnings. * m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Re-silence -Wformat-nonliteral. * cfg.mk (_test_script_regex): Recognize our test scripts. * gnulib/local/lib/*.diff: Drop, now that gnulib has this. * tests/virsh-optparse: Fix use of compare. * tests/virsh-schedinfo: Likewise. ---
v2: slightly newer gnulib; drop changes for unsuffixed float warning, and add fixes for misuse of 'compare' in tests.
I'm pushing this now, per: https://www.redhat.com/archives/libvir-list/2011-December/msg00098.html Patch 1/2 still needs a review before it gets pushed, and I don't care if that one slips post-release. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (1)
-
Eric Blake