From 61d438e73857776a1f96a7334f56b132275a587b Mon Sep 17 00:00:00 2001 From: Sheetal Pamecha Date: Mon, 19 Aug 2019 15:27:57 +0530 Subject: libgfapi: return correct errno on invalid volume name glfs_init when called with volume name prefixed by '/' sets errno to 0. Setting errno to EINVAL to resolve the issue. Also volname is a parameter to glfs_new. Thus, validating volname in glfs_new itself and returning EINVAL from that function fixes: bz#1507896 Change-Id: I0d4d2423e26cc07644d50ec8cce788ecc639203d Signed-off-by: Sheetal Pamecha --- libglusterfs/src/graph.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'libglusterfs/src/graph.c') diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c index e6ae40db2ed..913f57804cc 100644 --- a/libglusterfs/src/graph.c +++ b/libglusterfs/src/graph.c @@ -568,14 +568,13 @@ glusterfs_graph_prepare(glusterfs_graph_t *graph, glusterfs_ctx_t *ctx, } else { ret = glusterfs_graph_settop(graph, volume_name, _gf_false); } - if (!ret) { - goto ok; - } - gf_msg("graph", GF_LOG_ERROR, 0, LG_MSG_GRAPH_ERROR, - "glusterfs graph settop failed"); - return -1; -ok: + if (ret) { + gf_msg("graph", GF_LOG_ERROR, EINVAL, LG_MSG_GRAPH_ERROR, + "glusterfs graph settop failed"); + errno = EINVAL; + return -1; + } /* XXX: WORM VOLUME */ ret = glusterfs_graph_worm(graph, ctx); -- cgit