Message ID | 20230627182540.5243-1-zeming@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7199963vqr; Sun, 25 Jun 2023 19:23:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ50iOET410JerOnE/0o456i4sxlDs1RClFvydZWNWdqSHgi6nvgJRYYfdQ3m/02pMJi0uWt X-Received: by 2002:aa7:cd6a:0:b0:51d:9df7:72d1 with SMTP id ca10-20020aa7cd6a000000b0051d9df772d1mr169005edb.37.1687746206361; Sun, 25 Jun 2023 19:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687746206; cv=none; d=google.com; s=arc-20160816; b=OonI0QcCGsqIhK63JSJGvJMmCFlVCTmRIByd/+uYA1mi7ImhW6RpTjD9d9Tl53W8R1 FE6/D9d/Z8sqB8YRPbNAi72UD1mXA/LnPiRj0qM4JfIeL5UnrvJgPr3noappYBXx4P8i o80Zmnv/VOo3UIOzEA1KG0Z0Ts3GUjoGjcF/lAk/+N0tSUSEYaHZeP+LHzB5utALSI/V jlmqsMAi9aYUGS2XVjwutvAXUzGgMJOLTnfKGz1cqHjhl9VWn6ONXI5clIqBbn9dx44K /zv3jTCV1L/CFYcVOfqsn+Blr3tbFBdg/Kz/rvLPHr6ph0Ww3/a23schJlSGCglLj0fl c/vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=I1b6ojydnvfNM96Q9372dz9S/6S9kCAzDL1KStIXrgw=; fh=qA8N7nPiaDrmclPtyxVvkizFKMrMx1CcLzlWO+U72mo=; b=xmBQy8oRveJUbiYVhBWvvojVfX4UA97gyP0AxiVMOGYKhqHXMbbcXE3QNRYWv6pw8N 1W90CB4eFBYvSSFSEz0S38XqxrWwkTvjfqk8xG2ODl0/LaGEgBUHTDZksIJG53Z68lvv YyYIfKLT4VvQEf/uPpuOaStgE+ATXi1pFCmBmnWPwDO2nbHOZQCs26QFLdySQgYG27D1 G0X1pue28r/sqoUPWGTiuLPrlNHV298RRRuplOHBSlcqej042164J36AFsAlR2/gQqzn 7Miez2imviV2ZWWU80Fz4Lyp90/nlh6IW3vmpfWL6CyeKrD2+vwlWLjPdd9wcHu2nr24 dRJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f5-20020a056402150500b0051d9376c051si1247406edw.252.2023.06.25.19.22.54; Sun, 25 Jun 2023 19:23:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229452AbjFZByb (ORCPT <rfc822;filip.gregor98@gmail.com> + 99 others); Sun, 25 Jun 2023 21:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjFZBya (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 25 Jun 2023 21:54:30 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 7575A196 for <linux-kernel@vger.kernel.org>; Sun, 25 Jun 2023 18:54:28 -0700 (PDT) Received: from localhost.localdomain (unknown [219.141.250.2]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 14E0B606536B5; Mon, 26 Jun 2023 09:54:20 +0800 (CST) X-MD-Sfrom: zeming@nfschina.com X-MD-SrcIP: 219.141.250.2 From: Li zeming <zeming@nfschina.com> To: jstultz@google.com, tglx@linutronix.de, sboyd@kernel.org Cc: linux-kernel@vger.kernel.org, Li zeming <zeming@nfschina.com> Subject: [PATCH] =?utf-8?q?time=3A_ntp=3A_Remove_unnecessary_=E2=80=98-ENODE?= =?utf-8?q?V=E2=80=99_values_from_err?= Date: Wed, 28 Jun 2023 02:25:40 +0800 Message-Id: <20230627182540.5243-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_24_48, RDNS_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769730166346151892?= X-GMAIL-MSGID: =?utf-8?q?1769730166346151892?= |
Series |
time: ntp: Remove unnecessary ‘-ENODEV’ values from err
|
|
Commit Message
Li zeming
June 27, 2023, 6:25 p.m. UTC
err is assigned first, so it does not need to initialize the assignment.
Signed-off-by: Li zeming <zeming@nfschina.com>
---
kernel/time/ntp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
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: hexagon-randconfig-r045-20230626 (https://download.01.org/0day-ci/archive/20230626/202306261146.21X5CDd9-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/20230626/202306261146.21X5CDd9-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/202306261146.21X5CDd9-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from kernel/time/ntp.c:10: In file included from include/linux/clocksource.h:22: In file included from arch/hexagon/include/asm/io.h:334: 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/ntp.c:10: In file included from include/linux/clocksource.h:22: In file included from arch/hexagon/include/asm/io.h:334: 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/ntp.c:10: In file included from include/linux/clocksource.h:22: In file included from arch/hexagon/include/asm/io.h:334: 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); | ~~~~~~~~~~ ^ >> kernel/time/ntp.c:591:6: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] 591 | if (!rtc->ops || !rtc->ops->set_time) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kernel/time/ntp.c:605:9: note: uninitialized use occurs here 605 | return err; | ^~~ kernel/time/ntp.c:591:2: note: remove the 'if' if its condition is always false 591 | if (!rtc->ops || !rtc->ops->set_time) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 592 | goto out_close; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> kernel/time/ntp.c:591:6: warning: variable 'err' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized] 591 | if (!rtc->ops || !rtc->ops->set_time) | ^~~~~~~~~ kernel/time/ntp.c:605:9: note: uninitialized use occurs here 605 | return err; | ^~~ kernel/time/ntp.c:591:6: note: remove the '||' if its condition is always false 591 | if (!rtc->ops || !rtc->ops->set_time) | ^~~~~~~~~~~~ kernel/time/ntp.c:585:9: note: initialize the variable 'err' to silence this warning 585 | int err; | ^ | = 0 8 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
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
On Wed, Jun 28 2023 at 02:25, Li zeming wrote: > err is assigned first, so it does not need to initialize the > assignment. I don't know how you or the broken tool you rely upon came to that conclusion. There is clearly an error exit path which proves you wrong. Please look at your changes and compile them before posting. There are existing tools which do a better job than that. Thanks, tglx
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index 406dccb79c2b..3808bbf4db0c 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -582,7 +582,7 @@ static int update_rtc(struct timespec64 *to_set, unsigned long *offset_nsec) { struct rtc_device *rtc; struct rtc_time tm; - int err = -ENODEV; + int err; rtc = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE); if (!rtc)