All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: arch/x86/kernel/fpu/xstate.c:605:7: warning: Redundant initialization for 'size'. The initialized value is overwritten before it is read. [redundantInitialization]
Date: Tue, 09 Aug 2022 15:14:44 +0800	[thread overview]
Message-ID: <202208091530.4FFhLqLd-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 5833 bytes --]

:::::: 
:::::: Manual check reason: "low confidence static check warning: arch/x86/kernel/fpu/xstate.c:605:7: warning: Redundant initialization for 'size'. The initialized value is overwritten before it is read. [redundantInitialization]"
:::::: 

BCC: lkp(a)intel.com
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Thomas Gleixner <tglx@linutronix.de>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   eb555cb5b794f4e12a9897f3d46d5a72104cd4a7
commit: 8ad7e8f696951f192c6629a0cbda9ac94c773159 x86/fpu/xsave: Support XSAVEC in the kernel
date:   4 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 4 months ago
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout 8ad7e8f696951f192c6629a0cbda9ac94c773159
        cppcheck --quiet --enable=style,performance,portability --template=gcc FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

cppcheck warnings: (new ones prefixed by >>)
   arch/x86/kernel/fpu/xstate.c:1236:7: warning: Local variable 'mask' shadows outer variable [shadowVariable]
     u64 mask = ((u64)1 << i);
         ^
   arch/x86/kernel/fpu/xstate.c:1205:6: note: Shadowed declaration
    u64 mask;
        ^
   arch/x86/kernel/fpu/xstate.c:1236:7: note: Shadow variable
     u64 mask = ((u64)1 << i);
         ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> arch/x86/kernel/fpu/xstate.c:605:7: warning: Redundant initialization for 'size'. The initialized value is overwritten before it is read. [redundantInitialization]
    size = xstate_calculate_size(fpu_kernel_cfg.max_features, compacted);
         ^
   arch/x86/kernel/fpu/xstate.c:590:20: note: size is initialized
    unsigned int size = FXSAVE_SIZE + XSAVE_HDR_SIZE;
                      ^
   arch/x86/kernel/fpu/xstate.c:605:7: note: size is overwritten
    size = xstate_calculate_size(fpu_kernel_cfg.max_features, compacted);
         ^
>> arch/x86/kernel/fpu/xstate.c:589:7: warning: Local variable 'xsaves' shadows outer function [shadowFunction]
    bool xsaves = cpu_feature_enabled(X86_FEATURE_XSAVES);
         ^
   arch/x86/kernel/fpu/xstate.c:1310:6: note: Shadowed declaration
   void xsaves(struct xregs_state *xstate, u64 mask)
        ^
   arch/x86/kernel/fpu/xstate.c:589:7: note: Shadow variable
    bool xsaves = cpu_feature_enabled(X86_FEATURE_XSAVES);
         ^
   arch/x86/kernel/fpu/xstate.c:1708:43: warning: Parameter 'tsk' can be declared with const [constParameter]
   long fpu_xstate_prctl(struct task_struct *tsk, int option, unsigned long arg2)
                                             ^

vim +/size +605 arch/x86/kernel/fpu/xstate.c

84e4dccc8fce20 Chang S. Bae    2021-10-21  576  
65ac2e9baa7dee Dave Hansen     2015-09-02  577  /*
65ac2e9baa7dee Dave Hansen     2015-09-02  578   * This essentially double-checks what the cpu told us about
65ac2e9baa7dee Dave Hansen     2015-09-02  579   * how large the XSAVE buffer needs to be.  We are recalculating
65ac2e9baa7dee Dave Hansen     2015-09-02  580   * it to be safe.
76d10256a97a7c Kan Liang       2020-07-20  581   *
01707b66535872 Andy Lutomirski 2021-06-23  582   * Independent XSAVE features allocate their own buffers and are not
76d10256a97a7c Kan Liang       2020-07-20  583   * covered by these checks. Only the size of the buffer for task->fpu
76d10256a97a7c Kan Liang       2020-07-20  584   * is checked here.
65ac2e9baa7dee Dave Hansen     2015-09-02  585   */
cd9ae761744912 Thomas Gleixner 2021-10-15  586  static bool __init paranoid_xstate_size_valid(unsigned int kernel_size)
65ac2e9baa7dee Dave Hansen     2015-09-02  587  {
8ad7e8f696951f Thomas Gleixner 2022-04-04  588  	bool compacted = cpu_feature_enabled(X86_FEATURE_XCOMPACTED);
8ad7e8f696951f Thomas Gleixner 2022-04-04 @589  	bool xsaves = cpu_feature_enabled(X86_FEATURE_XSAVES);
cd9ae761744912 Thomas Gleixner 2021-10-15  590  	unsigned int size = FXSAVE_SIZE + XSAVE_HDR_SIZE;
65ac2e9baa7dee Dave Hansen     2015-09-02  591  	int i;
65ac2e9baa7dee Dave Hansen     2015-09-02  592  
1c253ff2287fe3 Thomas Gleixner 2021-10-15  593  	for_each_extended_xfeature(i, fpu_kernel_cfg.max_features) {
cd9ae761744912 Thomas Gleixner 2021-10-15  594  		if (!check_xstate_against_struct(i))
cd9ae761744912 Thomas Gleixner 2021-10-15  595  			return false;
65ac2e9baa7dee Dave Hansen     2015-09-02  596  		/*
65ac2e9baa7dee Dave Hansen     2015-09-02  597  		 * Supervisor state components can be managed only by
02b93c0b00df22 Thomas Gleixner 2021-06-23  598  		 * XSAVES.
65ac2e9baa7dee Dave Hansen     2015-09-02  599  		 */
8ad7e8f696951f Thomas Gleixner 2022-04-04  600  		if (!xsaves && xfeature_is_supervisor(i)) {
cd9ae761744912 Thomas Gleixner 2021-10-15  601  			XSTATE_WARN_ON(1);
cd9ae761744912 Thomas Gleixner 2021-10-15  602  			return false;
cd9ae761744912 Thomas Gleixner 2021-10-15  603  		}
65ac2e9baa7dee Dave Hansen     2015-09-02  604  	}
84e4dccc8fce20 Chang S. Bae    2021-10-21 @605  	size = xstate_calculate_size(fpu_kernel_cfg.max_features, compacted);
cd9ae761744912 Thomas Gleixner 2021-10-15  606  	XSTATE_WARN_ON(size != kernel_size);
cd9ae761744912 Thomas Gleixner 2021-10-15  607  	return size == kernel_size;
65ac2e9baa7dee Dave Hansen     2015-09-02  608  }
65ac2e9baa7dee Dave Hansen     2015-09-02  609  

:::::: The code at line 605 was first introduced by commit
:::::: 84e4dccc8fce20b497388d756e12de5c9006eb48 x86/fpu/xstate: Provide xstate_calculate_size()

:::::: TO: Chang S. Bae <chang.seok.bae@intel.com>
:::::: CC: Borislav Petkov <bp@suse.de>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

             reply	other threads:[~2022-08-09  7:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-09  7:14 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-11-07  5:33 arch/x86/kernel/fpu/xstate.c:605:7: warning: Redundant initialization for 'size'. The initialized value is overwritten before it is read. [redundantInitialization] kernel test robot
2022-11-02  8:09 kernel test robot
2022-06-27 14:31 kernel test robot

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=202208091530.4FFhLqLd-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.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 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.