netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	Florian Westphal <fw@strlen.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Joe Perches <joe@perches.com>,
	"netfilter-devel@vger.kernel.org"
	<netfilter-devel@vger.kernel.org>,
	"coreteam@netfilter.org" <coreteam@netfilter.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: Re: [PATCH] netfilter: conntrack: remote a return value of the 'seq_print_acct' function.
Date: Mon, 23 Jan 2023 15:28:46 +0200	[thread overview]
Message-ID: <Y86Lji5prQEAxKLi@unreal> (raw)
In-Reply-To: <20230123081957.1380790-1-Ilia.Gavrilov@infotecs.ru>

On Mon, Jan 23, 2023 at 08:19:50AM +0000, Gavrilov Ilia wrote:
> The static 'seq_print_acct' function always returns 0.
> 
> Change the return value to 'void' and remove unnecessary checks.
> 
> Found by InfoTeCS on behalf of Linux Verification Center
> (linuxtesting.org) with SVACE.
> 
> Fixes: 1ca9e41770cb ("netfilter: Remove uses of seq_<foo> return values")
> Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
> ---
>  net/netfilter/nf_conntrack_standalone.c | 26 ++++++++++---------------
>  1 file changed, 10 insertions(+), 16 deletions(-)
> 
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index 0250725e38a4..bee99d4bcf36 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -275,22 +275,18 @@ static const char* l4proto_name(u16 proto)
>  	return "unknown";
>  }
>  
> -static unsigned int
> +static void
>  seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir)
>  {
> -	struct nf_conn_acct *acct;
> -	struct nf_conn_counter *counter;
> +	struct nf_conn_acct *acct = nf_conn_acct_find(ct);
>  
> -	acct = nf_conn_acct_find(ct);
> -	if (!acct)
> -		return 0;
> -
> -	counter = acct->counter;
> -	seq_printf(s, "packets=%llu bytes=%llu ",
> -		   (unsigned long long)atomic64_read(&counter[dir].packets),
> -		   (unsigned long long)atomic64_read(&counter[dir].bytes));
> +	if (acct) {
> +		struct nf_conn_counter *counter = acct->counter;
>  
> -	return 0;
> +		seq_printf(s, "packets=%llu bytes=%llu ",
> +			   (unsigned long long)atomic64_read(&counter[dir].packets),
> +			   (unsigned long long)atomic64_read(&counter[dir].bytes));
> +	}

The preferred linux kernel style is to perform if (check_error) return;
In this case, this pattern should stay.

acct = nf_conn_acct_find(ct);
if (!acct)
   return;

Thanks

  reply	other threads:[~2023-01-23 13:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-23  8:19 [PATCH] netfilter: conntrack: remote a return value of the 'seq_print_acct' function Gavrilov Ilia
2023-01-23 13:28 ` Leon Romanovsky [this message]
2023-01-23 14:06   ` Gavrilov Ilia
2023-01-23 14:31   ` [PATCH v2] " Gavrilov Ilia
2023-01-23 17:44     ` Leon Romanovsky
2023-02-01 11:17     ` Pablo Neira Ayuso

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=Y86Lji5prQEAxKLi@unreal \
    --to=leon@kernel.org \
    --cc=Ilia.Gavrilov@infotecs.ru \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=joe@perches.com \
    --cc=kadlec@netfilter.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).