提交 c4bdfafc 编写于 作者: M Michal Privoznik

getOldStyleBlockDevice: Adjust formatting

Instead of initializing return value to zero (success) and overwriting
it on every failure just before the control jumps onto 'out' label,
let's initialize to an error value and set to zero only when we are
sure about the success. Just follow the pattern we have in the rest of
the code.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 71b66bec
...@@ -301,27 +301,25 @@ getOldStyleBlockDevice(const char *lun_path ATTRIBUTE_UNUSED, ...@@ -301,27 +301,25 @@ getOldStyleBlockDevice(const char *lun_path ATTRIBUTE_UNUSED,
char **block_device) char **block_device)
{ {
char *blockp = NULL; char *blockp = NULL;
int retval = 0; int retval = -1;
/* old-style; just parse out the sd */ /* old-style; just parse out the sd */
blockp = strrchr(block_name, ':'); if (!(blockp = strrchr(block_name, ':'))) {
if (blockp == NULL) {
/* Hm, wasn't what we were expecting; have to give up */ /* Hm, wasn't what we were expecting; have to give up */
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to parse block name %s"), _("Failed to parse block name %s"),
block_name); block_name);
retval = -1; goto cleanup;
} else { } else {
blockp++; blockp++;
if (VIR_STRDUP(*block_device, blockp) < 0) { if (VIR_STRDUP(*block_device, blockp) < 0)
retval = -1; goto cleanup;
goto out;
}
VIR_DEBUG("Block device is '%s'", *block_device); VIR_DEBUG("Block device is '%s'", *block_device);
} }
out: retval = 0;
cleanup:
return retval; return retval;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册