[LU-8671] bad error handling in mgs_object_init Created: 06/Oct/16  Updated: 08/Nov/18  Resolved: 08/Nov/18

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Ashish Purkar (Inactive) Assignee: WC Triage
Resolution: Duplicate Votes: 0
Labels: patch

Issue Links:
Duplicate
duplicates LU-8378 unused but set variables Resolved
Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

The function mgs_object_init() lost an error code return and always return zero as success.
Need to return proper error code.

lustre-wc-rel/lustre/mgs/mgs_handler.c:
static int mgs_object_init(const struct lu_env *env, struct lu_object *o,
const struct lu_object_conf *unused)
{
struct mgs_device *d = lu2mgs_dev(o->lo_dev);
struct lu_device *under;
struct lu_object *below;
int rc = 0;
ENTRY;

/* do no set .do_ops as mgs calls to bottom osd directly */

CDEBUG(D_INFO, "object init, fid = "DFID"\n",
PFID(lu_object_fid(o)));

under = &d->mgs_bottom->dd_lu_dev;
below = under->ld_ops->ldo_object_alloc(env, o->lo_header, under);
if (below != NULL)
lu_object_add(o, below);
else
rc = ENOMEM;<-- Variable 'rc' is assigned a value that is never used.

return 0;
}



 Comments   
Comment by Gerrit Updater [ 06/Oct/16 ]

Ashish Purkar (ashish.purkar@seagate.com) uploaded a new patch: http://review.whamcloud.com/22973
Subject: LU-8671 mgs: correct error handling in mgs_object_init()
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 8f9b3b257467a564ba91bbabade5dab21ccd521c

Comment by Ashish Purkar (Inactive) [ 06/Oct/16 ]

lustre-wc-rel/lustre/mgs/mgs_handler.c:

static int mgs_object_init(const struct lu_env *env, struct lu_object *o,
			   const struct lu_object_conf *unused)
{
	struct mgs_device *d = lu2mgs_dev(o->lo_dev);
	struct lu_device  *under;
	struct lu_object  *below;
	int                rc = 0;
	ENTRY;

	/* do no set .do_ops as mgs calls to bottom osd directly */

	CDEBUG(D_INFO, "object init, fid = "DFID"\n",
			PFID(lu_object_fid(o)));

	under = &d->mgs_bottom->dd_lu_dev;
	below = under->ld_ops->ldo_object_alloc(env, o->lo_header, under);
	if (below != NULL)
		lu_object_add(o, below);
	else
		rc = -ENOMEM;<--- Variable 'rc' is assigned a value that is never used.

	return 0;
}
Comment by Andreas Dilger [ 08/Nov/18 ]

This is fixed in patch http://review.whamcloud.com/23221 "LU-8378 all: remove set but unused variables"

Generated at Sat Feb 10 02:19:34 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.