提交 0867a877 编写于 作者: E Eric Blake

build: detect all improper uses of _("%s")

The only useful translation of "%s" as a format string is "%s" (I
suppose you could claim "%1$s" 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.  This makes
the fix of commit 097da1ab more generic, as well as ensuring no
future regressions.

* 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 (qemuSetupCgroupForVcpu): Likewise.
* src/qemu/qemu_driver.c (qemuSetVcpusBWLive): Likewise.
* src/xenapi/xenapi_utils.c (xenapiSessionErrorHandle): Likewise.
上级 4036aa91
...@@ -622,6 +622,12 @@ sc_prohibit_newline_at_end_of_diagnostic: ...@@ -622,6 +622,12 @@ sc_prohibit_newline_at_end_of_diagnostic:
&& { echo '$(ME): newline at end of message(s)' 1>&2; \ && { echo '$(ME): newline at end of message(s)' 1>&2; \
exit 1; } || : 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. # Enforce recommended preprocessor indentation style.
sc_preprocessor_indentation: sc_preprocessor_indentation:
@if cppi --version >/dev/null 2>&1; then \ @if cppi --version >/dev/null 2>&1; then \
......
...@@ -2965,9 +2965,8 @@ cleanup: ...@@ -2965,9 +2965,8 @@ cleanup:
if (period) { if (period) {
rc = virCgroupSetCpuCfsPeriod(cgroup, old_period); rc = virCgroupSetCpuCfsPeriod(cgroup, old_period);
if (rc < 0) if (rc < 0)
virReportSystemError(-rc, virReportSystemError(-rc, "%s",
_("%s"), _("Unable to rollback cpu bandwidth period"));
"Unable to rollback cpu bandwidth period");
} }
return -1; return -1;
......
...@@ -457,9 +457,8 @@ openvzReadFSConf(virDomainDefPtr def, ...@@ -457,9 +457,8 @@ openvzReadFSConf(virDomainDefPtr def,
/* Ensure that we can multiply by 1024 without overflowing. */ /* Ensure that we can multiply by 1024 without overflowing. */
if (barrier > ULLONG_MAX / 1024 || if (barrier > ULLONG_MAX / 1024 ||
limit > ULLONG_MAX / 1024 ) { limit > ULLONG_MAX / 1024 ) {
virReportSystemError(VIR_ERR_OVERFLOW, virReportSystemError(VIR_ERR_OVERFLOW, "%s",
_("%s"), _("Unable to parse quota"));
"Unable to parse quota");
goto error; goto error;
} }
fs->space_soft_limit = barrier * 1024; /* unit is bytes */ fs->space_soft_limit = barrier * 1024; /* unit is bytes */
......
/* /*
* qemu_cgroup.c: QEMU cgroup management * 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 * Copyright (C) 2006 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -472,8 +472,7 @@ cleanup: ...@@ -472,8 +472,7 @@ cleanup:
if (period) { if (period) {
rc = virCgroupSetCpuCfsPeriod(cgroup, old_period); rc = virCgroupSetCpuCfsPeriod(cgroup, old_period);
if (rc < 0) if (rc < 0)
virReportSystemError(-rc, virReportSystemError(-rc, "%s",
"%s",
_("Unable to rollback cpu bandwidth period")); _("Unable to rollback cpu bandwidth period"));
} }
...@@ -507,9 +506,8 @@ int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm) ...@@ -507,9 +506,8 @@ int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm)
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) { if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) {
/* Ensure that we can multiply by vcpus without overflowing. */ /* Ensure that we can multiply by vcpus without overflowing. */
if (quota > LLONG_MAX / vm->def->vcpus) { if (quota > LLONG_MAX / vm->def->vcpus) {
virReportSystemError(EINVAL, virReportSystemError(EINVAL, "%s",
_("%s"), _("Unable to set cpu bandwidth quota"));
"Unable to set cpu bandwidth quota");
goto cleanup; goto cleanup;
} }
......
...@@ -7134,9 +7134,8 @@ qemuSetVcpusBWLive(virDomainObjPtr vm, virCgroupPtr cgroup, ...@@ -7134,9 +7134,8 @@ qemuSetVcpusBWLive(virDomainObjPtr vm, virCgroupPtr cgroup,
/* Ensure that we can multiply by vcpus without overflowing. */ /* Ensure that we can multiply by vcpus without overflowing. */
if (quota > LLONG_MAX / vm->def->vcpus) { if (quota > LLONG_MAX / vm->def->vcpus) {
virReportSystemError(EINVAL, virReportSystemError(EINVAL, "%s",
_("%s"), _("Unable to set cpu bandwidth quota"));
"Unable to set cpu bandwidth quota");
goto cleanup; goto cleanup;
} }
......
/* /*
* xenapi_utils.c: Xen API driver -- utils parts. * 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. * Copyright (C) 2009, 2010 Citrix Ltd.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -372,11 +372,13 @@ xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum, ...@@ -372,11 +372,13 @@ xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum,
if (buf == NULL && priv != NULL && priv->session != NULL) { if (buf == NULL && priv != NULL && priv->session != NULL) {
char *ret = returnErrorFromSession(priv->session); 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); xen_session_clear_error(priv->session);
VIR_FREE(ret); VIR_FREE(ret);
} else { } else {
virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), buf); virReportErrorHelper(VIR_FROM_XENAPI, errNum, filename, func, lineno,
"%s", buf);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册