Enable more checks for unmarked messages; fix violators.

* Makefile.maint (sc_unmarked_diagnostics): Check for more functions.
* src/conf.c (virConfParseValue): Remove trailing space in diagnostic.
* src/libvirt.c (do_open, virDomainMigrate): Mark diagnostics.
* src/xend_internal.c (do_connect, xenDaemonDomainDumpXMLByID): Likewise.
(xenDaemonDomainDumpXMLByName, xenDaemonCreateLinux): Likewise.
(xenDaemonDomainMigratePerform, xenDaemonDomainDefineXML): Likewise.
* src/xml.c (virXPathString, virXPathNumber, virXPathLong): Likewise.
(virXPathBoolean, virXPathNode, virXPathNodeSet): Likewise.
(virDomainParseXMLOSDescHVM): Likewise.
* src/xmlrpc.c (xmlRpcValueNew): Likewise.
(xmlRpcValueUnmarshalDictElement): Likewise.
This commit is contained in:
Jim Meyering 2008-02-04 19:31:30 +00:00
parent e99570fc77
commit ecaa696250
7 changed files with 67 additions and 36 deletions

View File

@ -1,5 +1,18 @@
Mon Feb 2 15:56:45 CET 2008 Jim Meyering <meyering@redhat.com> Mon Feb 2 15:56:45 CET 2008 Jim Meyering <meyering@redhat.com>
Enable more checks for unmarked messages; fix violators.
* Makefile.maint (sc_unmarked_diagnostics): Check for more functions.
* src/conf.c (virConfParseValue): Remove trailing space in diagnostic.
* src/libvirt.c (do_open, virDomainMigrate): Mark diagnostics.
* src/xend_internal.c (do_connect, xenDaemonDomainDumpXMLByID): Likewise.
(xenDaemonDomainDumpXMLByName, xenDaemonCreateLinux): Likewise.
(xenDaemonDomainMigratePerform, xenDaemonDomainDefineXML): Likewise.
* src/xml.c (virXPathString, virXPathNumber, virXPathLong): Likewise.
(virXPathBoolean, virXPathNode, virXPathNodeSet): Likewise.
(virDomainParseXMLOSDescHVM): Likewise.
* src/xmlrpc.c (xmlRpcValueNew): Likewise.
(xmlRpcValueUnmarshalDictElement): Likewise.
Mark a string for translation. Mark a string for translation.
* src/virsh.c: Add a "%s" and wrap with _(...). * src/virsh.c: Add a "%s" and wrap with _(...).

View File

@ -287,14 +287,22 @@ sc_two_space_separator_in_usage:
echo "$(ME): an option and its description"; \ echo "$(ME): an option and its description"; \
1>&2; exit 1; } || : 1>&2; exit 1; } || :
err_func_re = \
(DISABLE_fprintf|(xmlRpc|vir(Xend|XML|Hash|Conf|Test|LibConn))Error)
# Look for diagnostics that aren't marked for translation. # Look for diagnostics that aren't marked for translation.
# This won't find any for which error's format string is on a separate line. # This won't find any for which error's format string is on a separate line.
sc_unmarked_diagnostics: sc_unmarked_diagnostics:
@grep -nE \ @grep -nE \
'\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \ '\<(vshError|error) \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \
| grep -v '_''(' && \ | grep -v '_''(' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \ { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || : exit 1; } || :
@{ grep -nE '\<$(err_func_re) *\(.*;$$' $$($(CVS_LIST_EXCEPT)); \
grep -A1 -nE '\<$(err_func_re) *\(.*,$$' $$($(CVS_LIST_EXCEPT)); } \
| grep '[ ]"' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
# Avoid useless parentheses like those in this example: # Avoid useless parentheses like those in this example:
# #if defined (SYMBOL) || defined (SYM2) # #if defined (SYMBOL) || defined (SYM2)

View File

@ -1,7 +1,7 @@
/** /**
* conf.c: parser for a subset of the Python encoded Xen configuration files * conf.c: parser for a subset of the Python encoded Xen configuration files
* *
* Copyright (C) 2006, 2007 Red Hat, Inc. * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
* *
* See COPYING.LIB for the License of this software * See COPYING.LIB for the License of this software
* *
@ -473,7 +473,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
NEXT; NEXT;
} else { } else {
virConfError(NULL, VIR_ERR_CONF_SYNTAX, virConfError(NULL, VIR_ERR_CONF_SYNTAX,
_("list is not closed with ] "), ctxt->line); _("list is not closed with ]"), ctxt->line);
virConfFreeList(lst); virConfFreeList(lst);
return(NULL); return(NULL);
} }

View File

@ -2,7 +2,7 @@
* libvirt.c: Main interfaces for the libvirt library to handle virtualization * libvirt.c: Main interfaces for the libvirt library to handle virtualization
* domains from a process running in domain 0 * domains from a process running in domain 0
* *
* Copyright (C) 2005,2006 Red Hat, Inc. * Copyright (C) 2005,2006,2008 Red Hat, Inc.
* *
* See COPYING.LIB for the License of this software * See COPYING.LIB for the License of this software
* *
@ -562,7 +562,7 @@ do_open (const char *name,
ret->name = strdup (name); ret->name = strdup (name);
if (!ret->name) { if (!ret->name) {
virLibConnError (ret, VIR_ERR_NO_MEMORY, "allocating conn->name"); virLibConnError (ret, VIR_ERR_NO_MEMORY, _("allocating conn->name"));
goto failed; goto failed;
} }
@ -1946,7 +1946,7 @@ virDomainMigrate (virDomainPtr domain,
if (ret == -1) goto done; if (ret == -1) goto done;
if (uri == NULL && uri_out == NULL) { if (uri == NULL && uri_out == NULL) {
virLibConnError (conn, VIR_ERR_INTERNAL_ERROR, virLibConnError (conn, VIR_ERR_INTERNAL_ERROR,
"domainMigratePrepare did not set uri"); _("domainMigratePrepare did not set uri"));
goto done; goto done;
} }
if (uri_out) uri = uri_out; /* Did domainMigratePrepare change URI? */ if (uri_out) uri = uri_out; /* Did domainMigratePrepare change URI? */

View File

@ -217,7 +217,7 @@ do_connect(virConnectPtr xend)
s = socket(priv->type, SOCK_STREAM, 0); s = socket(priv->type, SOCK_STREAM, 0);
if (s == -1) { if (s == -1) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR, virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"failed to create a socket"); _("failed to create a socket"));
return -1; return -1;
} }
@ -240,7 +240,7 @@ do_connect(virConnectPtr xend)
*/ */
if ((getuid() == 0) || (xend->flags & VIR_CONNECT_RO)) { if ((getuid() == 0) || (xend->flags & VIR_CONNECT_RO)) {
virXendError(xend, VIR_ERR_INTERNAL_ERROR, virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"failed to connect to xend"); _("failed to connect to xend"));
} }
} }
@ -2512,7 +2512,8 @@ xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid, int flags,
root = sexpr_get(conn, "/xend/domain/%d?detail=1", domid); root = sexpr_get(conn, "/xend/domain/%d?detail=1", domid);
if (root == NULL) { if (root == NULL) {
virXendError (conn, VIR_ERR_XEN_CALL, virXendError (conn, VIR_ERR_XEN_CALL,
"xenDaemonDomainDumpXMLByID failed to find this domain"); _("xenDaemonDomainDumpXMLByID failed to"
" find this domain"));
return (NULL); return (NULL);
} }
@ -2536,7 +2537,8 @@ xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name, int flags,
root = sexpr_get(conn, "/xend/domain/%s?detail=1", name); root = sexpr_get(conn, "/xend/domain/%s?detail=1", name);
if (root == NULL) { if (root == NULL) {
virXendError (conn, VIR_ERR_XEN_CALL, virXendError (conn, VIR_ERR_XEN_CALL,
"xenDaemonDomainDumpXMLByName failed to find this domain"); _("xenDaemonDomainDumpXMLByName failed to"
" find this domain"));
return (NULL); return (NULL);
} }
@ -3144,7 +3146,8 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion); sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) { if ((sexpr == NULL) || (name == NULL)) {
virXendError(conn, VIR_ERR_XML_ERROR, "domain"); virXendError(conn, VIR_ERR_XML_ERROR,
_("failed to parse domain description"));
free(sexpr); free(sexpr);
free(name); free(name);
@ -3323,7 +3326,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
/* Xen doesn't support renaming domains during migration. */ /* Xen doesn't support renaming domains during migration. */
if (dname) { if (dname) {
virXendError (conn, VIR_ERR_NO_SUPPORT, virXendError (conn, VIR_ERR_NO_SUPPORT,
"xenDaemonDomainMigrate: Xen does not support renaming domains during migration"); _("xenDaemonDomainMigrate: Xen does not support"
" renaming domains during migration"));
return -1; return -1;
} }
@ -3332,7 +3336,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
*/ */
if (bandwidth) { if (bandwidth) {
virXendError (conn, VIR_ERR_NO_SUPPORT, virXendError (conn, VIR_ERR_NO_SUPPORT,
"xenDaemonDomainMigrate: Xen does not support bandwidth limits during migration"); _("xenDaemonDomainMigrate: Xen does not support"
" bandwidth limits during migration"));
return -1; return -1;
} }
@ -3343,7 +3348,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
} }
if (flags != 0) { if (flags != 0) {
virXendError (conn, VIR_ERR_NO_SUPPORT, virXendError (conn, VIR_ERR_NO_SUPPORT,
"xenDaemonDomainMigrate: unsupported flag"); _("xenDaemonDomainMigrate: unsupported flag"));
return -1; return -1;
} }
@ -3356,24 +3361,26 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
xmlURIPtr uriptr = xmlParseURI (uri); xmlURIPtr uriptr = xmlParseURI (uri);
if (!uriptr) { if (!uriptr) {
virXendError (conn, VIR_ERR_INVALID_ARG, virXendError (conn, VIR_ERR_INVALID_ARG,
"xenDaemonDomainMigrate: invalid URI"); _("xenDaemonDomainMigrate: invalid URI"));
return -1; return -1;
} }
if (uriptr->scheme && STRCASENEQ (uriptr->scheme, "xenmigr")) { if (uriptr->scheme && STRCASENEQ (uriptr->scheme, "xenmigr")) {
virXendError (conn, VIR_ERR_INVALID_ARG, virXendError (conn, VIR_ERR_INVALID_ARG,
"xenDaemonDomainMigrate: only xenmigr:// migrations are supported by Xen"); _("xenDaemonDomainMigrate: only xenmigr://"
" migrations are supported by Xen"));
xmlFreeURI (uriptr); xmlFreeURI (uriptr);
return -1; return -1;
} }
if (!uriptr->server) { if (!uriptr->server) {
virXendError (conn, VIR_ERR_INVALID_ARG, virXendError (conn, VIR_ERR_INVALID_ARG,
"xenDaemonDomainMigrate: a hostname must be specified in the URI"); _("xenDaemonDomainMigrate: a hostname must be"
" specified in the URI"));
xmlFreeURI (uriptr); xmlFreeURI (uriptr);
return -1; return -1;
} }
hostname = strdup (uriptr->server); hostname = strdup (uriptr->server);
if (!hostname) { if (!hostname) {
virXendError (conn, VIR_ERR_NO_MEMORY, "strdup"); virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
xmlFreeURI (uriptr); xmlFreeURI (uriptr);
return -1; return -1;
} }
@ -3386,7 +3393,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
if (sscanf (p+1, "%d", &port_nr) != 1) { if (sscanf (p+1, "%d", &port_nr) != 1) {
virXendError (conn, VIR_ERR_INVALID_ARG, virXendError (conn, VIR_ERR_INVALID_ARG,
"xenDaemonDomainMigrate: invalid port number"); _("xenDaemonDomainMigrate: invalid port number"));
return -1; return -1;
} }
snprintf (port, sizeof port, "%d", port_nr); snprintf (port, sizeof port, "%d", port_nr);
@ -3395,7 +3402,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
n = p - uri; /* n = Length of hostname in bytes. */ n = p - uri; /* n = Length of hostname in bytes. */
hostname = strdup (uri); hostname = strdup (uri);
if (!hostname) { if (!hostname) {
virXendError (conn, VIR_ERR_NO_MEMORY, "strdup"); virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
return -1; return -1;
} }
hostname[n] = '\0'; hostname[n] = '\0';
@ -3403,7 +3410,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
else { /* "hostname" (or IP address) */ else { /* "hostname" (or IP address) */
hostname = strdup (uri); hostname = strdup (uri);
if (!hostname) { if (!hostname) {
virXendError (conn, VIR_ERR_NO_MEMORY, "strdup"); virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
return -1; return -1;
} }
} }
@ -3448,7 +3455,8 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion); sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) { if ((sexpr == NULL) || (name == NULL)) {
virXendError(conn, VIR_ERR_XML_ERROR, "domain"); virXendError(conn, VIR_ERR_XML_ERROR,
_("failed to parse domain description"));
free(sexpr); free(sexpr);
free(name); free(name);

View File

@ -1,7 +1,7 @@
/* /*
* xml.c: XML based interfaces for the libvir library * xml.c: XML based interfaces for the libvir library
* *
* Copyright (C) 2005, 2007 Red Hat, Inc. * Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
* *
* See COPYING.LIB for the License of this software * See COPYING.LIB for the License of this software
* *
@ -473,7 +473,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) { if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR, virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
"Invalid parameter to virXPathString()", 0); _("Invalid parameter to virXPathString()"), 0);
return (NULL); return (NULL);
} }
obj = xmlXPathEval(BAD_CAST xpath, ctxt); obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@ -486,7 +486,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
ret = strdup((char *) obj->stringval); ret = strdup((char *) obj->stringval);
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
if (ret == NULL) { if (ret == NULL) {
virXMLError(NULL, VIR_ERR_NO_MEMORY, "strdup", 0); virXMLError(NULL, VIR_ERR_NO_MEMORY, _("strdup failed"), 0);
} }
return (ret); return (ret);
} }
@ -509,7 +509,7 @@ virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value)
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR, virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
"Invalid parameter to virXPathNumber()", 0); _("Invalid parameter to virXPathNumber()"), 0);
return (-1); return (-1);
} }
obj = xmlXPathEval(BAD_CAST xpath, ctxt); obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@ -544,7 +544,7 @@ virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value)
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) { if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR, virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
"Invalid parameter to virXPathNumber()", 0); _("Invalid parameter to virXPathNumber()"), 0);
return (-1); return (-1);
} }
obj = xmlXPathEval(BAD_CAST xpath, ctxt); obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@ -590,7 +590,7 @@ virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) { if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR, virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
"Invalid parameter to virXPathBoolean()", 0); _("Invalid parameter to virXPathBoolean()"), 0);
return (-1); return (-1);
} }
obj = xmlXPathEval(BAD_CAST xpath, ctxt); obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@ -623,7 +623,7 @@ virXPathNode(const char *xpath, xmlXPathContextPtr ctxt)
if ((ctxt == NULL) || (xpath == NULL)) { if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR, virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
"Invalid parameter to virXPathNode()", 0); _("Invalid parameter to virXPathNode()"), 0);
return (NULL); return (NULL);
} }
obj = xmlXPathEval(BAD_CAST xpath, ctxt); obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@ -659,7 +659,7 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt,
if ((ctxt == NULL) || (xpath == NULL)) { if ((ctxt == NULL) || (xpath == NULL)) {
virXMLError(NULL, VIR_ERR_INTERNAL_ERROR, virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
"Invalid parameter to virXPathNodeSet()", 0); _("Invalid parameter to virXPathNodeSet()"), 0);
return (-1); return (-1);
} }
obj = xmlXPathEval(BAD_CAST xpath, ctxt); obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@ -882,7 +882,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (nbootorder == if (nbootorder ==
((sizeof(bootorder) / sizeof(bootorder[0])) - 1)) { ((sizeof(bootorder) / sizeof(bootorder[0])) - 1)) {
virXMLError(conn, VIR_ERR_XML_ERROR, virXMLError(conn, VIR_ERR_XML_ERROR,
"too many boot devices", 0); _("too many boot devices"), 0);
return (-1); return (-1);
} }
if (xmlStrEqual(boot_dev, BAD_CAST "fd")) { if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
@ -1004,7 +1004,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
isMouse = 0; isMouse = 0;
else if (strcmp((const char *) itype, "mouse")) { else if (strcmp((const char *) itype, "mouse")) {
xmlFree(itype); xmlFree(itype);
virXMLError(conn, VIR_ERR_XML_ERROR, "input", 0); virXMLError(conn, VIR_ERR_XML_ERROR,
_("invalid input device"), 0);
goto error; goto error;
} }
xmlFree(itype); xmlFree(itype);
@ -1020,7 +1021,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (!strcmp((const char *) bus, "ps2")) { if (!strcmp((const char *) bus, "ps2")) {
if (!isMouse) { if (!isMouse) {
xmlFree(bus); xmlFree(bus);
virXMLError(conn, VIR_ERR_XML_ERROR, "input", 0); virXMLError(conn, VIR_ERR_XML_ERROR,
_("invalid input device"), 0);
goto error; goto error;
} }
/* Nothing - implicit ps2 */ /* Nothing - implicit ps2 */

View File

@ -50,9 +50,9 @@ static xmlRpcValuePtr xmlRpcValueNew(xmlRpcValueType type)
xmlRpcValuePtr ret = malloc(sizeof(*ret)); xmlRpcValuePtr ret = malloc(sizeof(*ret));
if (!ret) if (!ret)
xmlRpcError(VIR_ERR_NO_MEMORY, "allocate value", sizeof(*ret)); xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value"), sizeof(*ret));
else else
ret->kind = type; ret->kind = type;
return ret; return ret;
} }
@ -183,7 +183,7 @@ static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node
xmlNodePtr cur; xmlNodePtr cur;
if (!ret) { if (!ret) {
xmlRpcError(VIR_ERR_NO_MEMORY, "allocate dict", sizeof(*ret)); xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate dict"), sizeof(*ret));
return NULL; return NULL;
} }
memset(ret, 0, sizeof(*ret)); memset(ret, 0, sizeof(*ret));