1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

lib: return value

Drop label out: with goto and return NULL directly.
Add log_debug() for zero metadata offset.
This commit is contained in:
Zdenek Kabelac 2015-03-06 09:04:31 +01:00
parent 4d16bfaabb
commit 60427d5d42

View File

@ -1142,7 +1142,7 @@ const char *vgname_from_mda(const struct format_type *fmt,
if (!mdah) { if (!mdah) {
log_error(INTERNAL_ERROR "vgname_from_mda called with NULL pointer for mda_header"); log_error(INTERNAL_ERROR "vgname_from_mda called with NULL pointer for mda_header");
goto_out; return NULL;
} }
/* FIXME Cope with returning a list */ /* FIXME Cope with returning a list */
@ -1151,13 +1151,16 @@ const char *vgname_from_mda(const struct format_type *fmt,
/* /*
* If no valid offset, do not try to search for vgname * If no valid offset, do not try to search for vgname
*/ */
if (!rlocn->offset) if (!rlocn->offset) {
goto out; log_debug("%s: found metadata with offset 0.",
dev_name(dev_area->dev));
return NULL;
}
/* Do quick check for a vgname */ /* Do quick check for a vgname */
if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset, if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
NAME_LEN, buf)) NAME_LEN, buf))
goto_out; return_NULL;
while (buf[len] && !isspace(buf[len]) && buf[len] != '{' && while (buf[len] && !isspace(buf[len]) && buf[len] != '{' &&
len < (NAME_LEN - 1)) len < (NAME_LEN - 1))
@ -1167,7 +1170,7 @@ const char *vgname_from_mda(const struct format_type *fmt,
/* Ignore this entry if the characters aren't permissible */ /* Ignore this entry if the characters aren't permissible */
if (!validate_name(buf)) if (!validate_name(buf))
goto_out; return_NULL;
/* We found a VG - now check the metadata */ /* We found a VG - now check the metadata */
if (rlocn->offset + rlocn->size > mdah->size) if (rlocn->offset + rlocn->size > mdah->size)
@ -1176,7 +1179,7 @@ const char *vgname_from_mda(const struct format_type *fmt,
if (wrap > rlocn->offset) { if (wrap > rlocn->offset) {
log_error("%s: metadata too large for circular buffer", log_error("%s: metadata too large for circular buffer",
dev_name(dev_area->dev)); dev_name(dev_area->dev));
goto out; return NULL;
} }
/* FIXME 64-bit */ /* FIXME 64-bit */
@ -1188,18 +1191,14 @@ const char *vgname_from_mda(const struct format_type *fmt,
MDA_HEADER_SIZE), MDA_HEADER_SIZE),
wrap, calc_crc, rlocn->checksum, wrap, calc_crc, rlocn->checksum,
vgid, vgstatus, creation_host))) vgid, vgstatus, creation_host)))
goto_out; return_NULL;
/* Ignore this entry if the characters aren't permissible */ /* Ignore this entry if the characters aren't permissible */
if (!validate_name(vgname)) { if (!validate_name(vgname))
vgname = NULL; return_NULL;
goto_out;
}
if (!id_write_format(vgid, uuid, sizeof(uuid))) { if (!id_write_format(vgid, uuid, sizeof(uuid)))
vgname = NULL; return_NULL;
goto_out;
}
log_debug_metadata("%s: Found metadata at %" PRIu64 " size %" PRIu64 log_debug_metadata("%s: Found metadata at %" PRIu64 " size %" PRIu64
" (in area at %" PRIu64 " size %" PRIu64 " (in area at %" PRIu64 " size %" PRIu64
@ -1218,7 +1217,6 @@ const char *vgname_from_mda(const struct format_type *fmt,
*mda_free_sectors = ((buffer_size - 2 * current_usage) / 2) >> SECTOR_SHIFT; *mda_free_sectors = ((buffer_size - 2 * current_usage) / 2) >> SECTOR_SHIFT;
} }
out:
return vgname; return vgname;
} }