All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Li zeming <zeming@nfschina.com>,
	jstultz@google.com, tglx@linutronix.de, sboyd@kernel.org
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	linux-kernel@vger.kernel.org, Li zeming <zeming@nfschina.com>
Subject: Re: [PATCH] time: ntp: Remove unnecessary ‘-ENODEV’ values from err
Date: Mon, 26 Jun 2023 12:05:53 +0800	[thread overview]
Message-ID: <202306261141.5MEtBJtk-lkp@intel.com> (raw)
In-Reply-To: <20230627182540.5243-1-zeming@nfschina.com>

Hi Li,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/timers/core]
[also build test WARNING on linus/master v6.4 next-20230623]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Li-zeming/time-ntp-Remove-unnecessary-ENODEV-values-from-err/20230626-095508
base:   tip/timers/core
patch link:    https://lore.kernel.org/r/20230627182540.5243-1-zeming%40nfschina.com
patch subject: [PATCH] time: ntp: Remove unnecessary ‘-ENODEV’ values from err
config: i386-randconfig-i004-20230626 (https://download.01.org/0day-ci/archive/20230626/202306261141.5MEtBJtk-lkp@intel.com/config)
compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
reproduce: (https://download.01.org/0day-ci/archive/20230626/202306261141.5MEtBJtk-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306261141.5MEtBJtk-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> kernel/time/ntp.c:591:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!rtc->ops || !rtc->ops->set_time)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/time/ntp.c:605:9: note: uninitialized use occurs here
           return err;
                  ^~~
   kernel/time/ntp.c:591:2: note: remove the 'if' if its condition is always false
           if (!rtc->ops || !rtc->ops->set_time)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/time/ntp.c:591:6: warning: variable 'err' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
           if (!rtc->ops || !rtc->ops->set_time)
               ^~~~~~~~~
   kernel/time/ntp.c:605:9: note: uninitialized use occurs here
           return err;
                  ^~~
   kernel/time/ntp.c:591:6: note: remove the '||' if its condition is always false
           if (!rtc->ops || !rtc->ops->set_time)
               ^~~~~~~~~~~~
   kernel/time/ntp.c:585:9: note: initialize the variable 'err' to silence this warning
           int err;
                  ^
                   = 0
   2 warnings generated.


vim +591 kernel/time/ntp.c

76e87d96b30b5f Thomas Gleixner 2020-12-06  578  
33e62e832384c8 Thomas Gleixner 2020-12-06  579  #ifdef CONFIG_RTC_SYSTOHC
76e87d96b30b5f Thomas Gleixner 2020-12-06  580  /* Save NTP synchronized time to the RTC */
76e87d96b30b5f Thomas Gleixner 2020-12-06  581  static int update_rtc(struct timespec64 *to_set, unsigned long *offset_nsec)
33e62e832384c8 Thomas Gleixner 2020-12-06  582  {
33e62e832384c8 Thomas Gleixner 2020-12-06  583  	struct rtc_device *rtc;
33e62e832384c8 Thomas Gleixner 2020-12-06  584  	struct rtc_time tm;
7c397afa918b1a Li zeming       2023-06-28  585  	int err;
33e62e832384c8 Thomas Gleixner 2020-12-06  586  
33e62e832384c8 Thomas Gleixner 2020-12-06  587  	rtc = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE);
33e62e832384c8 Thomas Gleixner 2020-12-06  588  	if (!rtc)
76e87d96b30b5f Thomas Gleixner 2020-12-06  589  		return -ENODEV;
33e62e832384c8 Thomas Gleixner 2020-12-06  590  
33e62e832384c8 Thomas Gleixner 2020-12-06 @591  	if (!rtc->ops || !rtc->ops->set_time)
33e62e832384c8 Thomas Gleixner 2020-12-06  592  		goto out_close;
33e62e832384c8 Thomas Gleixner 2020-12-06  593  
76e87d96b30b5f Thomas Gleixner 2020-12-06  594  	/* First call might not have the correct offset */
76e87d96b30b5f Thomas Gleixner 2020-12-06  595  	if (*offset_nsec == rtc->set_offset_nsec) {
76e87d96b30b5f Thomas Gleixner 2020-12-06  596  		rtc_time64_to_tm(to_set->tv_sec, &tm);
76e87d96b30b5f Thomas Gleixner 2020-12-06  597  		err = rtc_set_time(rtc, &tm);
76e87d96b30b5f Thomas Gleixner 2020-12-06  598  	} else {
76e87d96b30b5f Thomas Gleixner 2020-12-06  599  		/* Store the update offset and let the caller try again */
69eca258c85000 Thomas Gleixner 2020-12-06  600  		*offset_nsec = rtc->set_offset_nsec;
76e87d96b30b5f Thomas Gleixner 2020-12-06  601  		err = -EAGAIN;
33e62e832384c8 Thomas Gleixner 2020-12-06  602  	}
33e62e832384c8 Thomas Gleixner 2020-12-06  603  out_close:
33e62e832384c8 Thomas Gleixner 2020-12-06  604  	rtc_class_close(rtc);
33e62e832384c8 Thomas Gleixner 2020-12-06  605  	return err;
33e62e832384c8 Thomas Gleixner 2020-12-06  606  }
33e62e832384c8 Thomas Gleixner 2020-12-06  607  #else
76e87d96b30b5f Thomas Gleixner 2020-12-06  608  static inline int update_rtc(struct timespec64 *to_set, unsigned long *offset_nsec)
3c00a1fe8496ff Xunlei Pang     2015-04-01  609  {
926617889dc838 Arnd Bergmann   2018-08-14  610  	return -ENODEV;
3c00a1fe8496ff Xunlei Pang     2015-04-01  611  }
3c00a1fe8496ff Xunlei Pang     2015-04-01  612  #endif
3c00a1fe8496ff Xunlei Pang     2015-04-01  613  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

  parent reply	other threads:[~2023-06-26  4:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 18:25 [PATCH] time: ntp: Remove unnecessary ‘-ENODEV’ values from err Li zeming
2023-06-26  4:05 ` kernel test robot
2023-06-26  4:05 ` kernel test robot [this message]
2023-06-26 20:53 ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2023-06-26 17:57 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=202306261141.5MEtBJtk-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=zeming@nfschina.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.