The only useful translation of "%s" as a format string is "%s" (I suppose you could claim "%$1s" is also valid, but why bother). So it is not worth translating; fixing this exposes some instances where we were failing to translate real error messages. * cfg.mk (sc_prohibit_useless_translation): New rule. * src/lxc/lxc_driver.c (lxcSetVcpuBWLive): Fix offender. * src/openvz/openvz_conf.c (openvzReadFSConf): Likewise. * src/qemu/qemu_cgroup.c (qemuSetupCgroupVcpuBW) (qemuSetupCgroupForVcpu): Likewise. * src/qemu/qemu_driver.c (qemuSetVcpusBWLive): Likewise. * src/xenapi/xenapi_utils.c (xenapiSessionErrorHandle): Likewise. --- This is a followup to: https://www.redhat.com/archives/libvir-list/2012-July/msg00403.html cfg.mk | 6 ++++++ src/lxc/lxc_driver.c | 5 ++--- src/openvz/openvz_conf.c | 5 ++--- src/qemu/qemu_cgroup.c | 12 +++++------- src/qemu/qemu_driver.c | 5 ++--- src/xenapi/xenapi_utils.c | 8 +++++--- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/cfg.mk b/cfg.mk index 7664d5d..6dfe799 100644 --- a/cfg.mk +++ b/cfg.mk @@ -622,6 +622,12 @@ sc_prohibit_newline_at_end_of_diagnostic: && { echo '$(ME): newline at end of message(s)' 1>&2; \ exit 1; } || : +# The strings "" and "%s" should never be marked for translation. +sc_prohibit_useless_translation: + @prohibit='_\("(%s)?"\)' \ + halt='$(ME): found useless translation' \ + $(_sc_search_regexp) + # Enforce recommended preprocessor indentation style. sc_preprocessor_indentation: @if cppi --version >/dev/null 2>&1; then \ diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b58aeae..ae024fe 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2965,9 +2965,8 @@ cleanup: if (period) { rc = virCgroupSetCpuCfsPeriod(cgroup, old_period); if (rc < 0) - virReportSystemError(-rc, - _("%s"), - "Unable to rollback cpu bandwidth period"); + virReportSystemError(-rc, "%s", + _("Unable to rollback cpu bandwidth period")); } return -1; diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index ad27d37..7b66299 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -457,9 +457,8 @@ openvzReadFSConf(virDomainDefPtr def, /* Ensure that we can multiply by 1024 without overflowing. */ if (barrier > ULLONG_MAX / 1024 || limit > ULLONG_MAX / 1024 ) { - virReportSystemError(VIR_ERR_OVERFLOW, - _("%s"), - "Unable to parse quota"); + virReportSystemError(VIR_ERR_OVERFLOW, "%s", + _("Unable to parse quota")); goto error; } fs->space_soft_limit = barrier * 1024; /* unit is bytes */ diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index f8f375f..e39f5e1 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -1,7 +1,7 @@ /* * qemu_cgroup.c: QEMU cgroup management * - * Copyright (C) 2006-2011 Red Hat, Inc. + * Copyright (C) 2006-2012 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -472,9 +472,8 @@ cleanup: if (period) { rc = virCgroupSetCpuCfsPeriod(cgroup, old_period); if (rc < 0) - virReportSystemError(-rc, - _("%s"), - "Unable to rollback cpu bandwidth period"); + virReportSystemError(-rc, "%s", + _("Unable to rollback cpu bandwidth period")); } return -1; @@ -507,9 +506,8 @@ int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm) if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) { /* Ensure that we can multiply by vcpus without overflowing. */ if (quota > LLONG_MAX / vm->def->vcpus) { - virReportSystemError(EINVAL, - _("%s"), - "Unable to set cpu bandwidth quota"); + virReportSystemError(EINVAL, "%s", + _("Unable to set cpu bandwidth quota")); goto cleanup; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3410535..377be9f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7134,9 +7134,8 @@ qemuSetVcpusBWLive(virDomainObjPtr vm, virCgroupPtr cgroup, /* Ensure that we can multiply by vcpus without overflowing. */ if (quota > LLONG_MAX / vm->def->vcpus) { - virReportSystemError(EINVAL, - _("%s"), - "Unable to set cpu bandwidth quota"); + virReportSystemError(EINVAL, "%s", + _("Unable to set cpu bandwidth quota")); goto cleanup; } diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index 3471b6a..e5a9cc5 100644 --- a/src/xenapi/xenapi_utils.c +++ b/src/xenapi/xenapi_utils.c @@ -1,6 +1,6 @@ /* * xenapi_utils.c: Xen API driver -- utils parts. - * Copyright (C) 2011 Red Hat, Inc. + * Copyright (C) 2011-2012 Red Hat, Inc. * Copyright (C) 2009, 2010 Citrix Ltd. * * This library is free software; you can redistribute it and/or @@ -372,11 +372,13 @@ xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum, if (buf == NULL && priv != NULL && priv->session != NULL) { char *ret = returnErrorFromSession(priv->session); - virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret); + virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno, + "%s", ret); xen_session_clear_error(priv->session); VIR_FREE(ret); } else { - virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), buf); + virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno, + "%s", buf); } } -- 1.7.10.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list