All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricky WU <ricky_wu@realtek.com>
To: Kai-Heng Feng <kai.heng.feng@canonical.com>, Tom Rix <trix@redhat.com>
Cc: Nathan Chancellor <nathan@kernel.org>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"ndesaulniers@google.com" <ndesaulniers@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"llvm@lists.linux.dev" <llvm@lists.linux.dev>
Subject: RE: [PATCH] misc: rtsx: Set setting_reg2 before use.
Date: Tue, 17 May 2022 08:10:17 +0000	[thread overview]
Message-ID: <bab0c4250147420a842f3e966a8264a6@realtek.com> (raw)
In-Reply-To: <CAAd53p57APcectWW-NN_=HE6JkTQRk717cWNZ5iJcP+MtEYjog@mail.gmail.com>

> -----Original Message-----
> From: Kai-Heng Feng <kai.heng.feng@canonical.com>
> Sent: Tuesday, May 17, 2022 9:53 AM
> To: Tom Rix <trix@redhat.com>
> Cc: Nathan Chancellor <nathan@kernel.org>; arnd@arndb.de;
> gregkh@linuxfoundation.org; ndesaulniers@google.com; Ricky WU
> <ricky_wu@realtek.com>; linux-kernel@vger.kernel.org; llvm@lists.linux.dev
> Subject: Re: [PATCH] misc: rtsx: Set setting_reg2 before use.
> 
> On Tue, May 17, 2022 at 1:06 AM Tom Rix <trix@redhat.com> wrote:
> >
> >
> > On 5/16/22 8:56 AM, Nathan Chancellor wrote:
> > > On Mon, May 16, 2022 at 09:00:47AM -0400, Tom Rix wrote:
> > >> The clang build fails with
> > >> rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized
> whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
> > >>          } else if (efuse_valid == 0) {
> > >>                     ^~~~~~~~~~~~~~~~
> > >>
> > >> setting_reg2 is set in this block
> > >>    if (efuse_valid == 2 || efuse_valid == 3) { ..
> > >>    } else if (efuse_valid == 0) {
> > >>      // default
> > >> ..
> > >>    }
> > >> But efuse_valid can also have a value of 1.
> > >> Change the 'else if' to 'else' to make the second block the default.
> > >>
> > >> Fixes: b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")
> > >> Signed-off-by: Tom Rix <trix@redhat.com>
> > > I am not sure if this fix is correct from a functional standpoint (i.e.
> > > is treating efuse_valid == 1 the same as efuse_valid == 0 correct?)
> > > but it is better than not handling this value altogether. For what
> > > it's
> > > worth:
> >
> > I looked at how the code used to work, this seemed better than
> > initializing to NULL.
> 
> Or maybe use a single if block?
> 
> u16 setting_reg1 =PCR_SETTING_REG1 , setting_reg2 =
> PCR_SETTING_REG2; ...
> if ((efuse_valid == 2 || efuse_valid == 3) && (valid != 3) {
>     setting_reg1 = PCR_SETTING_REG4;
>     setting_reg2 = PCR_SETTING_REG5;
> }
> 
> Kai-Heng
> 
> >
> > >
> > > Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> > >
> > > As a side note, it is unfortunate that this change made it into
> > > -next when there was an outstanding report about this warning:
> >
> >  From the clang side, this is a build break and my static analysis
> > infra goes down.
> >
> > These build breaks seem to happening every week, is there a precommit
> > clang gating test that could be done for -next ?
> >
> > Tom
> >
> > >
> > > https://lore.kernel.org/202205100220.WyAyhKap-lkp@intel.com/
> > >
> > >> ---
> > >>   drivers/misc/cardreader/rts5261.c | 2 +-
> > >>   1 file changed, 1 insertion(+), 1 deletion(-)
> > >>
> > >> diff --git a/drivers/misc/cardreader/rts5261.c
> > >> b/drivers/misc/cardreader/rts5261.c
> > >> index 749cc5a46d13..f22634b14dc8 100644
> > >> --- a/drivers/misc/cardreader/rts5261.c
> > >> +++ b/drivers/misc/cardreader/rts5261.c
> > >> @@ -403,7 +403,7 @@ static void rts5261_init_from_hw(struct rtsx_pcr
> *pcr)
> > >>                      setting_reg1 = PCR_SETTING_REG4;
> > >>                      setting_reg2 = PCR_SETTING_REG5;
> > >>              }
> > >> -    } else if (efuse_valid == 0) {
> > >> +    } else {
> > >>              // default
> > >>              setting_reg1 = PCR_SETTING_REG1;
> > >>              setting_reg2 = PCR_SETTING_REG2;

Sorry for the trouble 
here can be changed to 
...
} else if (efuse_valid == 0) {
		// default
		setting_reg1 = PCR_SETTING_REG1;
		setting_reg2 = PCR_SETTING_REG2;
} else {
 return;
}
Because other values are invalid


> > >> --
> > >> 2.27.0
> > >>
> > > Cheers,
> > > Nathan
> > >
> >
> ------Please consider the environment before printing this e-mail.

  reply	other threads:[~2022-05-17  8:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16 13:00 [PATCH] misc: rtsx: Set setting_reg2 before use Tom Rix
2022-05-16 15:56 ` Nathan Chancellor
2022-05-16 17:06   ` Tom Rix
2022-05-16 21:22     ` Nick Desaulniers
2022-05-16 21:57       ` Nathan Chancellor
2022-05-17  1:53     ` Kai-Heng Feng
2022-05-17  8:10       ` Ricky WU [this message]
2022-05-19 20:57         ` Nathan Chancellor
2022-05-19 21:18           ` Tom Rix
2022-05-19 21:24             ` Nathan Chancellor

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=bab0c4250147420a842f3e966a8264a6@realtek.com \
    --to=ricky_wu@realtek.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kai.heng.feng@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=trix@redhat.com \
    /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.