提交 5b8e64f0 编写于 作者: P Peter Krempa

util: storage: Clean up label use in virStorageFileGetMetadataInternal

The function does not do any cleanup, so replace the 'cleanup' label
with return of -1 and the 'done' label with return of 0.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 112174b2
...@@ -973,7 +973,6 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, ...@@ -973,7 +973,6 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
int *backingFormat) int *backingFormat)
{ {
int dummy; int dummy;
int ret = -1;
size_t i; size_t i;
if (!backingFormat) if (!backingFormat)
...@@ -989,7 +988,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, ...@@ -989,7 +988,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
meta->format >= VIR_STORAGE_FILE_LAST) { meta->format >= VIR_STORAGE_FILE_LAST) {
virReportSystemError(EINVAL, _("unknown storage file meta->format %d"), virReportSystemError(EINVAL, _("unknown storage file meta->format %d"),
meta->format); meta->format);
goto cleanup; return -1;
} }
if (fileTypeInfo[meta->format].cryptInfo != NULL) { if (fileTypeInfo[meta->format].cryptInfo != NULL) {
...@@ -999,7 +998,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, ...@@ -999,7 +998,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
int expt_fmt = fileTypeInfo[meta->format].cryptInfo[i].format; int expt_fmt = fileTypeInfo[meta->format].cryptInfo[i].format;
if (!meta->encryption) { if (!meta->encryption) {
if (VIR_ALLOC(meta->encryption) < 0) if (VIR_ALLOC(meta->encryption) < 0)
goto cleanup; return -1;
meta->encryption->format = expt_fmt; meta->encryption->format = expt_fmt;
} else { } else {
...@@ -1008,7 +1007,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, ...@@ -1008,7 +1007,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
_("encryption format %d doesn't match " _("encryption format %d doesn't match "
"expected format %d"), "expected format %d"),
meta->encryption->format, expt_fmt); meta->encryption->format, expt_fmt);
goto cleanup; return -1;
} }
} }
meta->encryption->payload_offset = meta->encryption->payload_offset =
...@@ -1021,12 +1020,12 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, ...@@ -1021,12 +1020,12 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
* code into this method, for non-magic files * code into this method, for non-magic files
*/ */
if (!fileTypeInfo[meta->format].magic) if (!fileTypeInfo[meta->format].magic)
goto done; return 0;
/* Optionally extract capacity from file */ /* Optionally extract capacity from file */
if (fileTypeInfo[meta->format].sizeOffset != -1) { if (fileTypeInfo[meta->format].sizeOffset != -1) {
if ((fileTypeInfo[meta->format].sizeOffset + 8) > len) if ((fileTypeInfo[meta->format].sizeOffset + 8) > len)
goto done; return 0;
if (fileTypeInfo[meta->format].endian == LV_LITTLE_ENDIAN) if (fileTypeInfo[meta->format].endian == LV_LITTLE_ENDIAN)
meta->capacity = virReadBufInt64LE(buf + meta->capacity = virReadBufInt64LE(buf +
...@@ -1037,7 +1036,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, ...@@ -1037,7 +1036,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
/* Avoid unlikely, but theoretically possible overflow */ /* Avoid unlikely, but theoretically possible overflow */
if (meta->capacity > (ULLONG_MAX / if (meta->capacity > (ULLONG_MAX /
fileTypeInfo[meta->format].sizeMultiplier)) fileTypeInfo[meta->format].sizeMultiplier))
goto done; return 0;
meta->capacity *= fileTypeInfo[meta->format].sizeMultiplier; meta->capacity *= fileTypeInfo[meta->format].sizeMultiplier;
} }
...@@ -1047,25 +1046,21 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, ...@@ -1047,25 +1046,21 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
backingFormat, backingFormat,
buf, len); buf, len);
if (store == BACKING_STORE_INVALID) if (store == BACKING_STORE_INVALID)
goto done; return 0;
if (store == BACKING_STORE_ERROR) if (store == BACKING_STORE_ERROR)
goto cleanup; return -1;
} }
if (fileTypeInfo[meta->format].getFeatures != NULL && if (fileTypeInfo[meta->format].getFeatures != NULL &&
fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0) fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0)
goto cleanup; return -1;
if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features && if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features &&
VIR_STRDUP(meta->compat, "1.1") < 0) VIR_STRDUP(meta->compat, "1.1") < 0)
goto cleanup; return -1;
done:
ret = 0;
cleanup: return 0;
return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册