提交 dcf30d9c 编写于 作者: J Jim Meyering

initialize "meta" in virStorageFileGetMetadata, not in each caller

Do not require each caller of virStorageFileGetMetadata and
virStorageFileGetMetadataFromFD to first clear the storage of the
"meta" buffer.  Instead, initialize that storage in
virStorageFileGetMetadataFromFD.
* src/util/storage_file.c (virStorageFileGetMetadataFromFD): Clear
"meta" here, not before each of the following callers.
* src/qemu/qemu_driver.c (qemuSetupDiskCgroup): Don't clear "meta" here.
(qemuTeardownDiskCgroup): Likewise.
* src/qemu/qemu_security_dac.c (qemuSecurityDACSetSecurityImageLabel):
Likewise.
* src/security/security_selinux.c (SELinuxSetSecurityImageLabel):
Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.
上级 e638a246
...@@ -2982,8 +2982,6 @@ static int qemuSetupDiskCgroup(virCgroupPtr cgroup, ...@@ -2982,8 +2982,6 @@ static int qemuSetupDiskCgroup(virCgroupPtr cgroup,
} }
} }
memset(&meta, 0, sizeof(meta));
rc = virStorageFileGetMetadata(path, &meta); rc = virStorageFileGetMetadata(path, &meta);
if (path != disk->src) if (path != disk->src)
...@@ -3030,8 +3028,6 @@ static int qemuTeardownDiskCgroup(virCgroupPtr cgroup, ...@@ -3030,8 +3028,6 @@ static int qemuTeardownDiskCgroup(virCgroupPtr cgroup,
} }
} }
memset(&meta, 0, sizeof(meta));
rc = virStorageFileGetMetadata(path, &meta); rc = virStorageFileGetMetadata(path, &meta);
if (path != disk->src) if (path != disk->src)
...@@ -9386,7 +9382,6 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom, ...@@ -9386,7 +9382,6 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
} }
/* Probe for magic formats */ /* Probe for magic formats */
memset(&meta, 0, sizeof(meta));
if (virStorageFileGetMetadataFromFD(path, fd, &meta) < 0) if (virStorageFileGetMetadataFromFD(path, fd, &meta) < 0)
goto cleanup; goto cleanup;
......
...@@ -115,8 +115,6 @@ qemuSecurityDACSetSecurityImageLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED, ...@@ -115,8 +115,6 @@ qemuSecurityDACSetSecurityImageLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED,
virStorageFileMetadata meta; virStorageFileMetadata meta;
int ret; int ret;
memset(&meta, 0, sizeof(meta));
ret = virStorageFileGetMetadata(path, &meta); ret = virStorageFileGetMetadata(path, &meta);
if (path != disk->src) if (path != disk->src)
......
...@@ -454,8 +454,6 @@ SELinuxSetSecurityImageLabel(virDomainObjPtr vm, ...@@ -454,8 +454,6 @@ SELinuxSetSecurityImageLabel(virDomainObjPtr vm,
virStorageFileMetadata meta; virStorageFileMetadata meta;
int ret; int ret;
memset(&meta, 0, sizeof(meta));
ret = virStorageFileGetMetadata(path, &meta); ret = virStorageFileGetMetadata(path, &meta);
if (path != disk->src) if (path != disk->src)
......
...@@ -830,8 +830,6 @@ get_files(vahControl * ctl) ...@@ -830,8 +830,6 @@ get_files(vahControl * ctl)
do { do {
virStorageFileMetadata meta; virStorageFileMetadata meta;
memset(&meta, 0, sizeof(meta));
ret = virStorageFileGetMetadata(path, &meta); ret = virStorageFileGetMetadata(path, &meta);
if (path != ctl->def->disks[i]->src) if (path != ctl->def->disks[i]->src)
......
...@@ -275,6 +275,8 @@ virStorageFileGetMetadataFromFD(const char *path, ...@@ -275,6 +275,8 @@ virStorageFileGetMetadataFromFD(const char *path,
unsigned char head[20*512]; /* vmdk4GetBackingStore needs this much. */ unsigned char head[20*512]; /* vmdk4GetBackingStore needs this much. */
int len, i; int len, i;
memset(meta, 0, sizeof (*meta));
/* If all else fails, call it a raw file */ /* If all else fails, call it a raw file */
meta->format = VIR_STORAGE_FILE_RAW; meta->format = VIR_STORAGE_FILE_RAW;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册