kernel: time: clocksource: Remove unnecessary ‘0’ values from ret

Message ID 20230808173611.3066-1-zeming@nfschina.com
State New
Headers
Series kernel: time: clocksource: Remove unnecessary ‘0’ values from ret |

Commit Message

Li zeming Aug. 8, 2023, 5:36 p.m. UTC
  ret is assigned first, so it does not need to initialize the assignment.

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 kernel/time/clocksource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

kernel test robot Aug. 7, 2023, 3:29 a.m. UTC | #1
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.5-rc5 next-20230804]
[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/kernel-time-clocksource-Remove-unnecessary-0-values-from-ret/20230807-090629
base:   tip/timers/core
patch link:    https://lore.kernel.org/r/20230808173611.3066-1-zeming%40nfschina.com
patch subject: [PATCH] kernel: time: clocksource: Remove unnecessary ‘0’ values from ret
config: um-allnoconfig (https://download.01.org/0day-ci/archive/20230807/202308071105.lWPLR4Kr-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230807/202308071105.lWPLR4Kr-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/202308071105.lWPLR4Kr-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from kernel/time/clocksource.c:11:
   In file included from include/linux/clocksource.h:22:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     547 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     560 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from kernel/time/clocksource.c:11:
   In file included from include/linux/clocksource.h:22:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     573 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from kernel/time/clocksource.c:11:
   In file included from include/linux/clocksource.h:22:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     584 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     594 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     604 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     692 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     700 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     708 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     717 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     726 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     735 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
>> kernel/time/clocksource.c:1295:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    1295 |         if (!list_empty(&cs->list))
         |             ^~~~~~~~~~~~~~~~~~~~~~
   kernel/time/clocksource.c:1298:9: note: uninitialized use occurs here
    1298 |         return ret;
         |                ^~~
   kernel/time/clocksource.c:1295:2: note: remove the 'if' if its condition is always true
    1295 |         if (!list_empty(&cs->list))
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    1296 |                 ret = clocksource_unbind(cs);
         | ~~~~~~~~~~~~~~~~
   kernel/time/clocksource.c:1292:9: note: initialize the variable 'ret' to silence this warning
    1292 |         int ret;
         |                ^
         |                 = 0
   13 warnings generated.


vim +1295 kernel/time/clocksource.c

7eaeb34305dee2 Thomas Gleixner    2013-04-25  1285  
4713e22ce81eb8 Thomas Gleixner    2008-01-30  1286  /**
4713e22ce81eb8 Thomas Gleixner    2008-01-30  1287   * clocksource_unregister - remove a registered clocksource
b1b73d095084e7 Kusanagi Kouichi   2011-12-19  1288   * @cs:	clocksource to be unregistered
4713e22ce81eb8 Thomas Gleixner    2008-01-30  1289   */
a89c7edbe7d7aa Thomas Gleixner    2013-04-25  1290  int clocksource_unregister(struct clocksource *cs)
4713e22ce81eb8 Thomas Gleixner    2008-01-30  1291  {
1c69718b036413 Li zeming          2023-08-09  1292  	int ret;
a89c7edbe7d7aa Thomas Gleixner    2013-04-25  1293  
75c5158f70c065 Martin Schwidefsky 2009-08-14  1294  	mutex_lock(&clocksource_mutex);
a89c7edbe7d7aa Thomas Gleixner    2013-04-25 @1295  	if (!list_empty(&cs->list))
a89c7edbe7d7aa Thomas Gleixner    2013-04-25  1296  		ret = clocksource_unbind(cs);
75c5158f70c065 Martin Schwidefsky 2009-08-14  1297  	mutex_unlock(&clocksource_mutex);
a89c7edbe7d7aa Thomas Gleixner    2013-04-25  1298  	return ret;
4713e22ce81eb8 Thomas Gleixner    2008-01-30  1299  }
fb63a0ebe615fb Martin Schwidefsky 2009-08-14  1300  EXPORT_SYMBOL(clocksource_unregister);
4713e22ce81eb8 Thomas Gleixner    2008-01-30  1301
  

Patch

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 91836b727cef..b4ad38812ef7 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1289,7 +1289,7 @@  static int clocksource_unbind(struct clocksource *cs)
  */
 int clocksource_unregister(struct clocksource *cs)
 {
-	int ret = 0;
+	int ret;
 
 	mutex_lock(&clocksource_mutex);
 	if (!list_empty(&cs->list))