summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2014-06-16 12:39:32 +0200
committerZdenek Kabelac <zkabelac@redhat.com>2014-06-17 13:43:04 +0200
commit0558b1a0869f9a68d78e80140500874756c70e4d (patch)
tree1fa116f5d71310fccaf8e4f027d6a5e6c6ca44c5
parent7aef45f9bb8620e194d086ebeeaca0312e8aee04 (diff)
downloadlvm2-0558b1a0869f9a68d78e80140500874756c70e4d.tar.gz
cleanup: we already know max device name size
Use NAME_LEN constant to simplify creation of device name. Since the max size should be already tested in validation, throw INTERNAL_ERROR if the size of vg/lv is bigger then NAME_LEN.
-rw-r--r--tools/lvconvert.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 731d4c812..75eb56510 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -884,15 +884,13 @@ int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv,
* the polldaemon, lvconvert, pvmove code that a comprehensive
* audit/rework is needed
*/
- int len = strlen(lv->vg->name) + strlen(lv->name) + 2;
- char *uuid = alloca(sizeof(lv->lvid));
- char *lv_full_name = alloca(len);
+ char uuid[sizeof(lv->lvid)];
+ char lv_full_name[NAME_LEN];
- if (!uuid || !lv_full_name)
- return_0;
-
- if (dm_snprintf(lv_full_name, len, "%s/%s", lv->vg->name, lv->name) < 0)
- return_0;
+ if (dm_snprintf(lv_full_name, sizeof(lv_full_name), "%s/%s", lv->vg->name, lv->name) < 0) {
+ log_error(INTERNAL_ERROR "Name \"%s/%s\" is too long.", lv->vg->name, lv->name);
+ return 0;
+ }
memcpy(uuid, &lv->lvid, sizeof(lv->lvid));