From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 980C7C433E1 for ; Thu, 13 Aug 2020 00:57:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73C882087C for ; Thu, 13 Aug 2020 00:57:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbgHMA5K (ORCPT ); Wed, 12 Aug 2020 20:57:10 -0400 Received: from mga06.intel.com ([134.134.136.31]:34243 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgHMA5I (ORCPT ); Wed, 12 Aug 2020 20:57:08 -0400 IronPort-SDR: AclPTNtRwn5q46e+gDK8gLo5fJyA6pdGL4lw/OPJD/3oHK6l6j7X+V5+twTzTU3u8HZkQLxrCG Ti1ezcFRTU3A== X-IronPort-AV: E=McAfee;i="6000,8403,9711"; a="215661599" X-IronPort-AV: E=Sophos;i="5.76,306,1592895600"; d="scan'208";a="215661599" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 17:57:06 -0700 IronPort-SDR: u7Aiy1qwlsy2QF30pNizvz440Xfnah0SQY5g4acYiprToEF+0UObe4x1XOGh2N+4vA5ioml2Vf lofwPm6ei25g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,306,1592895600"; d="scan'208";a="470030390" Received: from lkp-server01.sh.intel.com (HELO 7f1ebb311643) ([10.239.97.150]) by orsmga005.jf.intel.com with ESMTP; 12 Aug 2020 17:57:04 -0700 Received: from kbuild by 7f1ebb311643 with local (Exim 4.92) (envelope-from ) id 1k61YF-0000Lh-IF; Thu, 13 Aug 2020 00:57:03 +0000 Date: Thu, 13 Aug 2020 08:56:12 +0800 From: kernel test robot To: Denis Efremov Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, Julia Lawall , Stefan Achatz , Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Message-ID: <20200813005612.GA85308@8851f5375e5a> References: <202008130840.TWLDLwLA%lkp@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202008130840.TWLDLwLA%lkp@intel.com> X-Patchwork-Hint: ignore User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: kernel test robot drivers/hid/hid-roccat-kovaplus.c:330:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kovaplus.c:277:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kovaplus.c:339:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kovaplus.c:349:8-16: WARNING: use scnprintf or sprintf drivers/hid/hid-roccat-kovaplus.c:370:8-16: WARNING: use scnprintf or sprintf From Documentation/filesystems/sysfs.txt: show() must not use snprintf() when formatting the value to be returned to user space. If you can guarantee that an overflow will never happen you can use sprintf() otherwise you must use scnprintf(). Generated by: scripts/coccinelle/api/device_attr_show.cocci Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script") CC: Denis Efremov Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 7c2a69f610e64c8dec6a06a66e721f4ce1dd783a commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add device_attr_show script Please take the patch only if it's a positive warning. Thanks! hid-roccat-kovaplus.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c @@ -274,7 +274,7 @@ static ssize_t kovaplus_sysfs_show_actua { struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_profile); + return scnprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_profile); } static ssize_t kovaplus_sysfs_set_actual_profile(struct device *dev, @@ -327,7 +327,7 @@ static ssize_t kovaplus_sysfs_show_actua { struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_cpi); + return scnprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_cpi); } static DEVICE_ATTR(actual_cpi, 0440, kovaplus_sysfs_show_actual_cpi, NULL); @@ -336,7 +336,7 @@ static ssize_t kovaplus_sysfs_show_actua { struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_x_sensitivity); + return scnprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_x_sensitivity); } static DEVICE_ATTR(actual_sensitivity_x, 0440, kovaplus_sysfs_show_actual_sensitivity_x, NULL); @@ -346,7 +346,7 @@ static ssize_t kovaplus_sysfs_show_actua { struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_y_sensitivity); + return scnprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_y_sensitivity); } static DEVICE_ATTR(actual_sensitivity_y, 0440, kovaplus_sysfs_show_actual_sensitivity_y, NULL); @@ -367,7 +367,7 @@ static ssize_t kovaplus_sysfs_show_firmw &info, KOVAPLUS_SIZE_INFO); mutex_unlock(&kovaplus->kovaplus_lock); - return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); + return scnprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); } static DEVICE_ATTR(firmware_version, 0440, kovaplus_sysfs_show_firmware_version, NULL); From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0580965353507814801==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: [PATCH] coccinelle: api: fix device_attr_show.cocci warnings Date: Thu, 13 Aug 2020 08:56:12 +0800 Message-ID: <20200813005612.GA85308@8851f5375e5a> In-Reply-To: <202008130840.TWLDLwLA%lkp@intel.com> List-Id: --===============0580965353507814801== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: kernel test robot drivers/hid/hid-roccat-kovaplus.c:330:8-16: WARNING: use scnprintf or sprin= tf drivers/hid/hid-roccat-kovaplus.c:277:8-16: WARNING: use scnprintf or sprin= tf drivers/hid/hid-roccat-kovaplus.c:339:8-16: WARNING: use scnprintf or sprin= tf drivers/hid/hid-roccat-kovaplus.c:349:8-16: WARNING: use scnprintf or sprin= tf drivers/hid/hid-roccat-kovaplus.c:370:8-16: WARNING: use scnprintf or sprin= tf From Documentation/filesystems/sysfs.txt: show() must not use snprintf() when formatting the value to be returned to user space. If you can guarantee that an overflow will never happen you can use sprintf() otherwise you must use scnprintf(). Generated by: scripts/coccinelle/api/device_attr_show.cocci Fixes: abfc19ff202d ("coccinelle: api: add device_attr_show script") CC: Denis Efremov Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git = master head: 7c2a69f610e64c8dec6a06a66e721f4ce1dd783a commit: abfc19ff202d287742483e15fd478ddd6ada2187 coccinelle: api: add devic= e_attr_show script Please take the patch only if it's a positive warning. Thanks! hid-roccat-kovaplus.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c @@ -274,7 +274,7 @@ static ssize_t kovaplus_sysfs_show_actua { struct kovaplus_device *kovaplus =3D hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_profile); + return scnprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_profile); } = static ssize_t kovaplus_sysfs_set_actual_profile(struct device *dev, @@ -327,7 +327,7 @@ static ssize_t kovaplus_sysfs_show_actua { struct kovaplus_device *kovaplus =3D hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_cpi); + return scnprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_cpi); } static DEVICE_ATTR(actual_cpi, 0440, kovaplus_sysfs_show_actual_cpi, NULL); = @@ -336,7 +336,7 @@ static ssize_t kovaplus_sysfs_show_actua { struct kovaplus_device *kovaplus =3D hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_x_sensitivity); + return scnprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_x_sensitivity); } static DEVICE_ATTR(actual_sensitivity_x, 0440, kovaplus_sysfs_show_actual_sensitivity_x, NULL); @@ -346,7 +346,7 @@ static ssize_t kovaplus_sysfs_show_actua { struct kovaplus_device *kovaplus =3D hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_y_sensitivity); + return scnprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_y_sensitivity); } static DEVICE_ATTR(actual_sensitivity_y, 0440, kovaplus_sysfs_show_actual_sensitivity_y, NULL); @@ -367,7 +367,7 @@ static ssize_t kovaplus_sysfs_show_firmw &info, KOVAPLUS_SIZE_INFO); mutex_unlock(&kovaplus->kovaplus_lock); = - return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); + return scnprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); } static DEVICE_ATTR(firmware_version, 0440, kovaplus_sysfs_show_firmware_version, NULL); --===============0580965353507814801==--