blobstore: Defer to memcpy after all xattr mallocs are finished.
This confirms that the error path can return more efficient without memcpy such as xattr->name. Signed-off-by: Dong Yi <dongx.yi@intel.com> Change-Id: Ic2ed28121ed76eda9d7b24ed6c4c95b0588817de Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11654 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
parent
0270fc322f
commit
742d818e29
@ -537,8 +537,6 @@ blob_deserialize_xattr(struct spdk_blob *blob,
|
||||
free(xattr);
|
||||
return -ENOMEM;
|
||||
}
|
||||
memcpy(xattr->name, desc_xattr->name, desc_xattr->name_length);
|
||||
xattr->name[desc_xattr->name_length] = '\0';
|
||||
|
||||
xattr->value = malloc(desc_xattr->value_length);
|
||||
if (xattr->value == NULL) {
|
||||
@ -546,6 +544,9 @@ blob_deserialize_xattr(struct spdk_blob *blob,
|
||||
free(xattr);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memcpy(xattr->name, desc_xattr->name, desc_xattr->name_length);
|
||||
xattr->name[desc_xattr->name_length] = '\0';
|
||||
xattr->value_len = desc_xattr->value_length;
|
||||
memcpy(xattr->value,
|
||||
(void *)((uintptr_t)desc_xattr->name + desc_xattr->name_length),
|
||||
|
Loading…
Reference in New Issue
Block a user