summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2021-10-01 14:10:39 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2021-10-06 15:43:31 +0200
commit79e65a3596dc4fef1d7ac74fe727e9c24a539afb (patch)
treea0dde419030ebec8345203ab882414eee6af6f34
parent5ccb373d869ca23afc10416c2319331eb108e16b (diff)
downloadlvm2-79e65a3596dc4fef1d7ac74fe727e9c24a539afb.tar.gz
cleanup: all lvmcache_add users pass char with 0
No local copy needed, both users submit zero-end string as pv/vgid.
-rw-r--r--lib/cache/lvmcache.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 7a7634074..e04f00f2d 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -2166,8 +2166,8 @@ struct lvmcache_info *lvmcache_add(struct cmd_context *cmd, struct labeller *lab
const char *vgname, const char *vgid_arg, uint32_t vgstatus,
int *is_duplicate)
{
- char pvid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
- char vgid[ID_LEN + 1] __attribute__((aligned(8))) = { 0 };
+ const char *pvid = pvid_arg;
+ const char *vgid = vgid_arg;
char pvid_dashed[64] __attribute__((aligned(8)));
struct lvmcache_vgsummary vgsummary = { 0 };
struct lvmcache_info *info;
@@ -2175,12 +2175,6 @@ struct lvmcache_info *lvmcache_add(struct cmd_context *cmd, struct labeller *lab
struct device_list *devl;
int created = 0;
- /* pvid_arg and vgid_arg may not be null terminated */
- memcpy(pvid, pvid_arg, ID_LEN);
-
- if (vgid_arg)
- memcpy(vgid, vgid_arg, ID_LEN);
-
if (!id_write_format((const struct id *)&pvid, pvid_dashed, sizeof(pvid_dashed)))
stack;
@@ -2282,7 +2276,7 @@ struct lvmcache_info *lvmcache_add(struct cmd_context *cmd, struct labeller *lab
update_vginfo:
vgsummary.vgstatus = vgstatus;
vgsummary.vgname = vgname;
- if (vgid[0])
+ if (vgid && vgid[0])
memcpy(vgsummary.vgid, vgid, ID_LEN);
if (!lvmcache_update_vgname_and_id(cmd, info, &vgsummary)) {