Fix misuse of VIR_ERR_INVALID_* error code

VIR_ERR_INVALID_* is meant for invalid pointers only.
This commit is contained in:
Matthias Bolte 2011-01-15 16:31:29 +01:00
parent 2c0db5b5dc
commit 8c6d61162f
8 changed files with 40 additions and 40 deletions

View File

@ -2366,7 +2366,7 @@ virNWFilterObjAssignDef(virConnectPtr conn,
if (nwfilter) { if (nwfilter) {
if (!STREQ(def->name, nwfilter->def->name)) { if (!STREQ(def->name, nwfilter->def->name)) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
_("filter with same UUID but different name " _("filter with same UUID but different name "
"('%s') already exists"), "('%s') already exists"),
nwfilter->def->name); nwfilter->def->name);
@ -2377,7 +2377,7 @@ virNWFilterObjAssignDef(virConnectPtr conn,
} }
if (virNWFilterDefLoopDetect(conn, nwfilters, def)) { if (virNWFilterDefLoopDetect(conn, nwfilters, def)) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("filter would introduce a loop")); "%s", _("filter would introduce a loop"));
return NULL; return NULL;
} }
@ -2442,7 +2442,7 @@ virNWFilterObjLoad(virConnectPtr conn,
} }
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) { if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_XML_ERROR,
_("network filter config filename '%s' does not match name '%s'"), _("network filter config filename '%s' does not match name '%s'"),
path, def->name); path, def->name);
virNWFilterDefFree(def); virNWFilterDefFree(def);

View File

@ -1423,7 +1423,7 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools,
} }
if (!virFileMatchesNameSuffix(file, def->name, ".xml")) { if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
virStorageReportError(VIR_ERR_INVALID_STORAGE_POOL, virStorageReportError(VIR_ERR_XML_ERROR,
_("Storage pool config filename '%s' does not match pool name '%s'"), _("Storage pool config filename '%s' does not match pool name '%s'"),
path, def->name); path, def->name);
virStoragePoolDefFree(def); virStoragePoolDefFree(def);

View File

@ -2059,13 +2059,13 @@ static int networkUndefine(virNetworkPtr net) {
network = virNetworkFindByUUID(&driver->networks, net->uuid); network = virNetworkFindByUUID(&driver->networks, net->uuid);
if (!network) { if (!network) {
networkReportError(VIR_ERR_INVALID_NETWORK, networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid")); "%s", _("no network with matching uuid"));
goto cleanup; goto cleanup;
} }
if (virNetworkObjIsActive(network)) { if (virNetworkObjIsActive(network)) {
networkReportError(VIR_ERR_INTERNAL_ERROR, networkReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("network is still active")); "%s", _("network is still active"));
goto cleanup; goto cleanup;
} }
@ -2138,7 +2138,7 @@ static int networkStart(virNetworkPtr net) {
network = virNetworkFindByUUID(&driver->networks, net->uuid); network = virNetworkFindByUUID(&driver->networks, net->uuid);
if (!network) { if (!network) {
networkReportError(VIR_ERR_INVALID_NETWORK, networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid")); "%s", _("no network with matching uuid"));
goto cleanup; goto cleanup;
} }
@ -2161,13 +2161,13 @@ static int networkDestroy(virNetworkPtr net) {
network = virNetworkFindByUUID(&driver->networks, net->uuid); network = virNetworkFindByUUID(&driver->networks, net->uuid);
if (!network) { if (!network) {
networkReportError(VIR_ERR_INVALID_NETWORK, networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid")); "%s", _("no network with matching uuid"));
goto cleanup; goto cleanup;
} }
if (!virNetworkObjIsActive(network)) { if (!virNetworkObjIsActive(network)) {
networkReportError(VIR_ERR_INTERNAL_ERROR, networkReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("network is not active")); "%s", _("network is not active"));
goto cleanup; goto cleanup;
} }
@ -2196,7 +2196,7 @@ static char *networkDumpXML(virNetworkPtr net, int flags ATTRIBUTE_UNUSED) {
networkDriverUnlock(driver); networkDriverUnlock(driver);
if (!network) { if (!network) {
networkReportError(VIR_ERR_INVALID_NETWORK, networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid")); "%s", _("no network with matching uuid"));
goto cleanup; goto cleanup;
} }
@ -2219,7 +2219,7 @@ static char *networkGetBridgeName(virNetworkPtr net) {
networkDriverUnlock(driver); networkDriverUnlock(driver);
if (!network) { if (!network) {
networkReportError(VIR_ERR_INVALID_NETWORK, networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching id")); "%s", _("no network with matching id"));
goto cleanup; goto cleanup;
} }
@ -2251,7 +2251,7 @@ static int networkGetAutostart(virNetworkPtr net,
network = virNetworkFindByUUID(&driver->networks, net->uuid); network = virNetworkFindByUUID(&driver->networks, net->uuid);
networkDriverUnlock(driver); networkDriverUnlock(driver);
if (!network) { if (!network) {
networkReportError(VIR_ERR_INVALID_NETWORK, networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid")); "%s", _("no network with matching uuid"));
goto cleanup; goto cleanup;
} }
@ -2276,13 +2276,13 @@ static int networkSetAutostart(virNetworkPtr net,
network = virNetworkFindByUUID(&driver->networks, net->uuid); network = virNetworkFindByUUID(&driver->networks, net->uuid);
if (!network) { if (!network) {
networkReportError(VIR_ERR_INVALID_NETWORK, networkReportError(VIR_ERR_NO_NETWORK,
"%s", _("no network with matching uuid")); "%s", _("no network with matching uuid"));
goto cleanup; goto cleanup;
} }
if (!network->persistent) { if (!network->persistent) {
networkReportError(VIR_ERR_INTERNAL_ERROR, networkReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot set autostart for transient network")); "%s", _("cannot set autostart for transient network"));
goto cleanup; goto cleanup;
} }

View File

@ -372,13 +372,13 @@ nwfilterUndefine(virNWFilterPtr obj) {
nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid); nwfilter = virNWFilterObjFindByUUID(&driver->nwfilters, obj->uuid);
if (!nwfilter) { if (!nwfilter) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_NO_NWFILTER,
"%s", _("no nwfilter with matching uuid")); "%s", _("no nwfilter with matching uuid"));
goto cleanup; goto cleanup;
} }
if (virNWFilterTestUnassignDef(obj->conn, nwfilter)) { if (virNWFilterTestUnassignDef(obj->conn, nwfilter)) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_OPERATION_INVALID,
"%s", "%s",
_("nwfilter is in use")); _("nwfilter is in use"));
goto cleanup; goto cleanup;
@ -417,7 +417,7 @@ nwfilterDumpXML(virNWFilterPtr obj,
nwfilterDriverUnlock(driver); nwfilterDriverUnlock(driver);
if (!nwfilter) { if (!nwfilter) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_NO_NWFILTER,
"%s", _("no nwfilter with matching uuid")); "%s", _("no nwfilter with matching uuid"));
goto cleanup; goto cleanup;
} }

View File

@ -157,14 +157,14 @@ printVar(virNWFilterHashTablePtr vars,
if ((item->flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) { if ((item->flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) {
char *val = (char *)virHashLookup(vars->hashTable, item->var); char *val = (char *)virHashLookup(vars->hashTable, item->var);
if (!val) { if (!val) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find value for '%s'"), _("cannot find value for '%s'"),
item->var); item->var);
return 1; return 1;
} }
if (!virStrcpy(buf, val, bufsize)) { if (!virStrcpy(buf, val, bufsize)) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Buffer to small to print MAC address " _("Buffer to small to print MAC address "
"'%s' into"), "'%s' into"),
item->var); item->var);
@ -223,7 +223,7 @@ _printDataType(virNWFilterHashTablePtr vars,
case DATATYPE_MACADDR: case DATATYPE_MACADDR:
case DATATYPE_MACMASK: case DATATYPE_MACMASK:
if (bufsize < VIR_MAC_STRING_BUFLEN) { if (bufsize < VIR_MAC_STRING_BUFLEN) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s", virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for MAC address")); _("Buffer too small for MAC address"));
return 1; return 1;
} }
@ -235,7 +235,7 @@ _printDataType(virNWFilterHashTablePtr vars,
case DATATYPE_IPMASK: case DATATYPE_IPMASK:
if (snprintf(buf, bufsize, "%d", if (snprintf(buf, bufsize, "%d",
item->u.u8) >= bufsize) { item->u.u8) >= bufsize) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s", virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint8 type")); _("Buffer too small for uint8 type"));
return 1; return 1;
} }
@ -245,7 +245,7 @@ _printDataType(virNWFilterHashTablePtr vars,
case DATATYPE_UINT16_HEX: case DATATYPE_UINT16_HEX:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d", if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
item->u.u16) >= bufsize) { item->u.u16) >= bufsize) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s", virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint16 type")); _("Buffer too small for uint16 type"));
return 1; return 1;
} }
@ -255,14 +255,14 @@ _printDataType(virNWFilterHashTablePtr vars,
case DATATYPE_UINT8_HEX: case DATATYPE_UINT8_HEX:
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d", if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
item->u.u8) >= bufsize) { item->u.u8) >= bufsize) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, "%s", virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint8 type")); _("Buffer too small for uint8 type"));
return 1; return 1;
} }
break; break;
default: default:
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("Unhandled datatype %x"), item->datatype); _("Unhandled datatype %x"), item->datatype);
return 1; return 1;
break; break;
@ -2356,7 +2356,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
case VIR_NWFILTER_RULE_PROTOCOL_IGMP: case VIR_NWFILTER_RULE_PROTOCOL_IGMP:
case VIR_NWFILTER_RULE_PROTOCOL_ALL: case VIR_NWFILTER_RULE_PROTOCOL_ALL:
if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) { if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
_("'%s' protocol not support for net type '%s'"), _("'%s' protocol not support for net type '%s'"),
virNWFilterRuleProtocolTypeToString(rule->prtclType), virNWFilterRuleProtocolTypeToString(rule->prtclType),
virDomainNetTypeToString(nettype)); virDomainNetTypeToString(nettype));
@ -2380,7 +2380,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
case VIR_NWFILTER_RULE_PROTOCOL_ICMPV6: case VIR_NWFILTER_RULE_PROTOCOL_ICMPV6:
case VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6: case VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6:
if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) { if (nettype == VIR_DOMAIN_NET_TYPE_DIRECT) {
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
_("'%s' protocol not support for net type '%s'"), _("'%s' protocol not support for net type '%s'"),
virNWFilterRuleProtocolTypeToString(rule->prtclType), virNWFilterRuleProtocolTypeToString(rule->prtclType),
virDomainNetTypeToString(nettype)); virDomainNetTypeToString(nettype));
@ -2396,7 +2396,7 @@ ebiptablesCreateRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
break; break;
case VIR_NWFILTER_RULE_PROTOCOL_LAST: case VIR_NWFILTER_RULE_PROTOCOL_LAST:
virNWFilterReportError(VIR_ERR_INVALID_NWFILTER, virNWFilterReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("illegal protocol type")); "%s", _("illegal protocol type"));
rc = 1; rc = 1;
break; break;

View File

@ -467,7 +467,7 @@ getVolumeQcowPassphrase(virConnectPtr conn,
enc->nsecrets != 1 || enc->nsecrets != 1 ||
enc->secrets[0]->type != enc->secrets[0]->type !=
VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE) { VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE) {
qemuReportError(VIR_ERR_INVALID_DOMAIN, qemuReportError(VIR_ERR_XML_ERROR,
_("invalid <encryption> for volume %s"), disk->src); _("invalid <encryption> for volume %s"), disk->src);
goto cleanup; goto cleanup;
} }
@ -485,7 +485,7 @@ getVolumeQcowPassphrase(virConnectPtr conn,
if (memchr(data, '\0', size) != NULL) { if (memchr(data, '\0', size) != NULL) {
memset(data, 0, size); memset(data, 0, size);
VIR_FREE(data); VIR_FREE(data);
qemuReportError(VIR_ERR_INVALID_SECRET, qemuReportError(VIR_ERR_XML_ERROR,
_("format='qcow' passphrase for %s must not contain a " _("format='qcow' passphrase for %s must not contain a "
"'\\0'"), disk->src); "'\\0'"), disk->src);
goto cleanup; goto cleanup;

View File

@ -713,7 +713,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
return -1; return -1;
} }
if (enc->nsecrets > 1) { if (enc->nsecrets > 1) {
virStorageReportError(VIR_ERR_INVALID_STORAGE_VOL, "%s", virStorageReportError(VIR_ERR_XML_ERROR, "%s",
_("too many secrets for qcow encryption")); _("too many secrets for qcow encryption"));
return -1; return -1;
} }

View File

@ -4356,7 +4356,7 @@ testStorageVolumeLookupByName(virStoragePoolPtr pool,
privvol = virStorageVolDefFindByName(privpool, name); privvol = virStorageVolDefFindByName(privpool, name);
if (!privvol) { if (!privvol) {
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"), name); _("no storage vol with matching name '%s'"), name);
goto cleanup; goto cleanup;
} }
@ -4399,7 +4399,7 @@ testStorageVolumeLookupByKey(virConnectPtr conn,
testDriverUnlock(privconn); testDriverUnlock(privconn);
if (!ret) if (!ret)
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching key '%s'"), key); _("no storage vol with matching key '%s'"), key);
return ret; return ret;
@ -4433,7 +4433,7 @@ testStorageVolumeLookupByPath(virConnectPtr conn,
testDriverUnlock(privconn); testDriverUnlock(privconn);
if (!ret) if (!ret)
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching path '%s'"), path); _("no storage vol with matching path '%s'"), path);
return ret; return ret;
@ -4469,7 +4469,7 @@ testStorageVolumeCreateXML(virStoragePoolPtr pool,
goto cleanup; goto cleanup;
if (virStorageVolDefFindByName(privpool, privvol->name)) { if (virStorageVolDefFindByName(privpool, privvol->name)) {
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_OPERATION_FAILED,
"%s", _("storage vol already exists")); "%s", _("storage vol already exists"));
goto cleanup; goto cleanup;
} }
@ -4550,14 +4550,14 @@ testStorageVolumeCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup; goto cleanup;
if (virStorageVolDefFindByName(privpool, privvol->name)) { if (virStorageVolDefFindByName(privpool, privvol->name)) {
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_OPERATION_FAILED,
"%s", _("storage vol already exists")); "%s", _("storage vol already exists"));
goto cleanup; goto cleanup;
} }
origvol = virStorageVolDefFindByName(privpool, clonevol->name); origvol = virStorageVolDefFindByName(privpool, clonevol->name);
if (!origvol) { if (!origvol) {
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"), _("no storage vol with matching name '%s'"),
clonevol->name); clonevol->name);
goto cleanup; goto cleanup;
@ -4633,7 +4633,7 @@ testStorageVolumeDelete(virStorageVolPtr vol,
privvol = virStorageVolDefFindByName(privpool, vol->name); privvol = virStorageVolDefFindByName(privpool, vol->name);
if (privvol == NULL) { if (privvol == NULL) {
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"), _("no storage vol with matching name '%s'"),
vol->name); vol->name);
goto cleanup; goto cleanup;
@ -4711,7 +4711,7 @@ testStorageVolumeGetInfo(virStorageVolPtr vol,
privvol = virStorageVolDefFindByName(privpool, vol->name); privvol = virStorageVolDefFindByName(privpool, vol->name);
if (privvol == NULL) { if (privvol == NULL) {
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"), _("no storage vol with matching name '%s'"),
vol->name); vol->name);
goto cleanup; goto cleanup;
@ -4756,7 +4756,7 @@ testStorageVolumeGetXMLDesc(virStorageVolPtr vol,
privvol = virStorageVolDefFindByName(privpool, vol->name); privvol = virStorageVolDefFindByName(privpool, vol->name);
if (privvol == NULL) { if (privvol == NULL) {
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"), _("no storage vol with matching name '%s'"),
vol->name); vol->name);
goto cleanup; goto cleanup;
@ -4796,7 +4796,7 @@ testStorageVolumeGetPath(virStorageVolPtr vol) {
privvol = virStorageVolDefFindByName(privpool, vol->name); privvol = virStorageVolDefFindByName(privpool, vol->name);
if (privvol == NULL) { if (privvol == NULL) {
testError(VIR_ERR_INVALID_STORAGE_VOL, testError(VIR_ERR_NO_STORAGE_VOL,
_("no storage vol with matching name '%s'"), _("no storage vol with matching name '%s'"),
vol->name); vol->name);
goto cleanup; goto cleanup;