public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Tom Rix <trix@redhat.com>
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, hpa@zytor.com,
	ndesaulniers@google.com, goldstein.w.n@gmail.com, x86@kernel.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] x86/csum: Move csum_tail result parameter to a local variable.
Date: Tue, 30 May 2023 08:20:16 -0700	[thread overview]
Message-ID: <20230530152016.GA3503416@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20230530135953.3341174-1-trix@redhat.com>

Hi Tom,

On Tue, May 30, 2023 at 09:59:53AM -0400, Tom Rix wrote:
> clang with W=1 reports
> arch/x86/lib/csum-partial_64.c:74:20: error: variable
>   'result' is uninitialized when used here [-Werror,-Wuninitialized]
>                 return csum_tail(result, temp64, odd);
>                                  ^~~~~~
> This is a false positive, but there is never an intermediate value
> of result to pass into csum_trail, so move the parameter result to
> a local variable.
> 
> Signed-off-by: Tom Rix <trix@redhat.com>

Thanks for the patch. I sent the same one last Friday, which should be
in your inbox:

https://lore.kernel.org/20230526-csum_partial-wuninitialized-v1-1-ebc0108dcec1@kernel.org/

Dave picked it up yesterday, I guess -tip's auto-latest was not
refreshed for today's -next:

https://git.kernel.org/tip/2fe1e67e6987b6f05329740da79c8150a2205b0d

Cheers,
Nathan

> ---
>  arch/x86/lib/csum-partial_64.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
> index fe5861951b15..cea25ca8b8cf 100644
> --- a/arch/x86/lib/csum-partial_64.c
> +++ b/arch/x86/lib/csum-partial_64.c
> @@ -21,8 +21,10 @@ static inline unsigned short from32to16(unsigned a)
>  	return b;
>  }
>  
> -static inline __wsum csum_tail(unsigned int result, u64 temp64, int odd)
> +static inline __wsum csum_tail(u64 temp64, int odd)
>  {
> +	unsigned int result;
> +
>  	result = add32_with_carry(temp64 >> 32, temp64 & 0xffffffff);
>  	if (unlikely(odd)) {
>  		result = from32to16(result);
> @@ -45,7 +47,7 @@ static inline __wsum csum_tail(unsigned int result, u64 temp64, int odd)
>  __wsum csum_partial(const void *buff, int len, __wsum sum)
>  {
>  	u64 temp64 = (__force u64)sum;
> -	unsigned odd, result;
> +	unsigned odd;
>  
>  	odd = 1 & (unsigned long) buff;
>  	if (unlikely(odd)) {
> @@ -71,7 +73,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>  		    "adcq $0,%[res]"
>  		    : [res] "+r"(temp64)
>  		    : [src] "r"(buff), "m"(*(const char(*)[40])buff));
> -		return csum_tail(result, temp64, odd);
> +		return csum_tail(temp64, odd);
>  	}
>  	if (unlikely(len >= 64)) {
>  		/*
> @@ -141,7 +143,7 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
>  		    : [res] "+r"(temp64)
>  		    : [trail] "r"(trail));
>  	}
> -	return csum_tail(result, temp64, odd);
> +	return csum_tail(temp64, odd);
>  }
>  EXPORT_SYMBOL(csum_partial);
>  
> -- 
> 2.27.0
> 

  reply	other threads:[~2023-05-30 15:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30 13:59 [PATCH] x86/csum: Move csum_tail result parameter to a local variable Tom Rix
2023-05-30 15:20 ` Nathan Chancellor [this message]
2023-06-01 16:58   ` Dave Hansen

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=20230530152016.GA3503416@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=goldstein.w.n@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mingo@redhat.com \
    --cc=ndesaulniers@google.com \
    --cc=tglx@linutronix.de \
    --cc=trix@redhat.com \
    --cc=x86@kernel.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