1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-30 17:18:21 +03:00

cleanup: futher code reduction

Just like everywhere else - use single if() for major:minor setup
(it basically can't fail as of today anyway)

Always leave funtion with correctly set pointers even on error path.
This commit is contained in:
Zdenek Kabelac 2017-12-04 10:38:39 +01:00
parent 2a22576b2d
commit 7379a2624b

View File

@ -803,13 +803,11 @@ static int _deps(struct dm_task **dmt, struct dm_pool *mem, uint32_t major, uint
struct dm_info *info, struct dm_deps **deps)
{
memset(info, 0, sizeof(*info));
if (!dm_is_dm_major(major)) {
if (name)
*name = "";
if (uuid)
*uuid = "";
*deps = NULL;
if (!dm_is_dm_major(major)) {
info->major = major;
info->minor = minor;
return 1;
@ -820,14 +818,8 @@ static int _deps(struct dm_task **dmt, struct dm_pool *mem, uint32_t major, uint
return 0;
}
if (!dm_task_set_major(*dmt, major)) {
log_error("_deps: failed to set major for (%" PRIu32 ":%" PRIu32 ")",
major, minor);
goto failed;
}
if (!dm_task_set_minor(*dmt, minor)) {
log_error("_deps: failed to set minor for (%" PRIu32 ":%" PRIu32 ")",
if (!dm_task_set_major(*dmt, major) || !dm_task_set_minor(*dmt, minor)) {
log_error("_deps: failed to set major:minor for (" FMTu32 ":" FMTu32 ").",
major, minor);
goto failed;
}
@ -850,11 +842,7 @@ static int _deps(struct dm_task **dmt, struct dm_pool *mem, uint32_t major, uint
goto failed;
}
if (!info->exists) {
*name = "";
*uuid = "";
*deps = NULL;
} else {
if (info->exists) {
if (info->major != major) {
log_error("Inconsistent dtree major number: %u != %u",
major, info->major);
@ -874,6 +862,8 @@ static int _deps(struct dm_task **dmt, struct dm_pool *mem, uint32_t major, uint
failed:
dm_task_destroy(*dmt);
*dmt = NULL;
return 0;
}