Re: [PATCH v4 2/2] RDMA/srp: Fix error return code in srp_parse_options()

From: Andy Shevchenko
Date: Thu Dec 01 2022 - 07:21:34 EST


On Thu, Dec 01, 2022 at 09:49:51AM +0800, wangyufen wrote:
> 在 2022/12/1 2:00, Bart Van Assche 写道:
> > On 11/29/22 19:31, wangyufen wrote:

...

> case SRP_OPT_CMD_SG_ENTRIES:
> - if (match_int(args, &token) || token < 1 || token >
> 255) {
> + ret = match_int(args, &token);
> + if (ret) {
> + pr_warn("bad max cmd_sg_entries parameter
> '%s'\n",

It's misleading message here. The problem is that parser failed by some reason.
Otherwise this variant seems good one.

> + p);
> + goto out;
> + }
> + if (token < 1 || token > 255) {
> pr_warn("bad max cmd_sg_entries parameter
> '%s'\n",
> p);
> + ret = -EINVAL;
> goto out;
> }
> target->cmd_sg_cnt = token;
> break;

...

> Or the following is better?

Why do you want to shadow actual error code?

--
With Best Regards,
Andy Shevchenko