From: Mat Martineau <mathew.j.martineau@linux.intel.com>
To: Matthieu Baerts <matthieu.baerts@tessares.net>
Cc: mptcp@lists.linux.dev, kernel test robot <lkp@intel.com>,
Dan Carpenter <error27@gmail.com>
Subject: Re: [PATCH mptcp-next] mptcp: return 0 instead of 'err' var
Date: Mon, 5 Dec 2022 13:31:05 -0800 (PST) [thread overview]
Message-ID: <4ca7e8d1-4d93-0e23-45a5-2084f7df982e@linux.intel.com> (raw)
In-Reply-To: <20221205101002.2620762-1-matthieu.baerts@tessares.net>
On Mon, 5 Dec 2022, Matthieu Baerts wrote:
> When 'err' is 0, it looks clearer to return '0' instead of the variable
> called 'err'.
>
> The behaviour is then not modified, just a clearer code.
>
> By doing this, we can also avoid false positive smatch warnings like
> this one:
>
> net/mptcp/pm_netlink.c:1169 mptcp_pm_parse_pm_addr_attr() warn: missing error code? 'err'
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <error27@gmail.com>
> Suggested-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Thanks for the cleanup Matthieu. Looks good to me.
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
> ---
> net/mptcp/pm_netlink.c | 4 ++--
> net/mptcp/sockopt.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 39b0f054f39f..d20f1d969900 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -1187,7 +1187,7 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[],
>
> if (!tb[MPTCP_PM_ADDR_ATTR_FAMILY]) {
> if (!require_family)
> - return err;
> + return 0;
>
> NL_SET_ERR_MSG_ATTR(info->extack, attr,
> "missing family");
> @@ -1221,7 +1221,7 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[],
> if (tb[MPTCP_PM_ADDR_ATTR_PORT])
> addr->port = htons(nla_get_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]));
>
> - return err;
> + return 0;
> }
>
> int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index a47423ebb33a..d4b1e6ec1b36 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
> @@ -740,7 +740,7 @@ static int mptcp_setsockopt_v4_set_tos(struct mptcp_sock *msk, int optname,
> }
> release_sock(sk);
>
> - return err;
> + return 0;
> }
>
> static int mptcp_setsockopt_v4(struct mptcp_sock *msk, int optname,
>
> base-commit: 9324c815f96dd77d23679e999edb875d9f4acd34
> --
> 2.37.2
>
>
--
Mat Martineau
Intel
next prev parent reply other threads:[~2022-12-05 21:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-05 10:10 [PATCH mptcp-next] mptcp: return 0 instead of 'err' var Matthieu Baerts
2022-12-05 11:26 ` mptcp: return 0 instead of 'err' var: Tests Results MPTCP CI
2022-12-05 21:31 ` Mat Martineau [this message]
2022-12-06 11:02 ` [PATCH mptcp-next] mptcp: return 0 instead of 'err' var Matthieu Baerts
2022-12-05 22:52 ` mptcp: return 0 instead of 'err' var: Tests Results MPTCP CI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ca7e8d1-4d93-0e23-45a5-2084f7df982e@linux.intel.com \
--to=mathew.j.martineau@linux.intel.com \
--cc=error27@gmail.com \
--cc=lkp@intel.com \
--cc=matthieu.baerts@tessares.net \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.