Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2710660rwb; Sat, 8 Oct 2022 12:46:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ZxN0qX9SgGqW8rZ5bhCMK6+53IKWwMpaalButKW+f4UrTAFF9SA1KLFCQDen7xPh/pgBt X-Received: by 2002:a05:6402:1c97:b0:458:d4fa:b8e1 with SMTP id cy23-20020a0564021c9700b00458d4fab8e1mr10097575edb.7.1665258403330; Sat, 08 Oct 2022 12:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665258403; cv=none; d=google.com; s=arc-20160816; b=zBMD6TXxlwHms8USThumma2lBGsDDZO3J8J9kqkCU9CHi4QNrJ/BcmCmy+okoSqyP9 hPROUs7oiAKrD/cKdfR9QO/GzOl6D8fkgeT5D31H+uYKv96vr/lObJtjCtlhseQU6Ld0 LZv97yjOUMlGJSKVhZUpueJPrQIgEyiXGxOJL9FWeH7GQTtycByMpZePWLzipU5ANuxc GORniMVI+kGxAMNm0YVQv/tIfhFbps/oGVGAei9h3dagys0barUhd0JIq9IZVI5SNUxK kaKkMs9NBvSSMDFmxUT/1lxOBmSSL2ejfJVBP2Ba2CCMIv0vTtwuhVpyB3JeFcCBnbsA NEGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:date:from:dkim-signature; bh=1wbrHIINWpNtq1uT4Jf3QIYAe/wvpMtUNlJq6URPo7Y=; b=oZpChwx3huCDvwJEfZn/bTr2CJIK6rWQxvPG013SMU89OGFMWhv6vdq57OljeTiPAr LoQO1NkkUWF6PldEToVgDBotQp/hY6XxLVAW4WHAVm2XRldhXDS+q8ltyYnzWm/UAWqu /CIydJKW5wG+8bLwmwNAxXROtH4Qp5vpm9GcOKUV6/AXRLTsDFMMDHCcswRf5LuYXx7X 6M7RYa0nIs/2rKMthmFHI/OnkdU/Dr/ez1hVAcEKLoD3/GceFqlKcx1QVJCcVyX6Scl4 Jt50E2ES8YIFefw9Gp7g3BOyynj1po714WgmncW7Hsgyxh/TmojfoZmlOrgp5GLGZ29f ripQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gWoU7Rx2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a170906361200b00730bc62507csi5131495ejb.125.2022.10.08.12.46.15; Sat, 08 Oct 2022 12:46:43 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gWoU7Rx2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229820AbiJHTLB (ORCPT + 99 others); Sat, 8 Oct 2022 15:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiJHTK6 (ORCPT ); Sat, 8 Oct 2022 15:10:58 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A21392F643; Sat, 8 Oct 2022 12:10:56 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id bv10so8062585wrb.4; Sat, 08 Oct 2022 12:10:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:date:from :from:to:cc:subject:date:message-id:reply-to; bh=1wbrHIINWpNtq1uT4Jf3QIYAe/wvpMtUNlJq6URPo7Y=; b=gWoU7Rx2ibfkGptoYG9FDbP0gxfTtzkWf1ilHfG+T3uESHxU32ANZzJ2JF4sWQOVkk YWv7mQdLwAOueULcAyuZ7rg1cuEGPUU5G5OI+h7Oecpc2SHWAVQFt4jIZDAeIJfp4INL yo3kk5sPu0gHjkXJZAXXeHRaI+/zBx4wpgiFeacC1YQ3JCnpyeks6ZC9++/XuAzbDdq0 6IazpEkmbbMePGeovpcOoVKtC9kjCUthFH35UiasyExZtoKbf/C3h0L8lEV184dDtPOG aJz/+FTM5IHHqapZ8bYyBvOa0w44qIWy191BzoxLKE4NIgGuKQkqK42tWrl6E/1JyqQ3 oq1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1wbrHIINWpNtq1uT4Jf3QIYAe/wvpMtUNlJq6URPo7Y=; b=bkqEjnrPPzWWB2cLMx/bCgioaI9Om8sON+zYXgqv9WRBZ2Pcn0be1Ce++m2F4deRGk hdwW54mm0JjNh6kp3KNxNL+c5iE629QMrfDFaSxT5fvKGptHoDE9aafJCZa5N7EfxX4e ORKxyUVeIAJuEGpTVMUwxeJ8cA6Aulbc9XrEtbOgn2jmj6wc75IflI0Huk7Ca/fJlQbb Vai+38Vv5daTNY72qnKXJiXwtPsC0SGfuwhE2KTQv4AXF/vdAPPZi4NaQ+RuFiwe5pek o6how6Sw3mMyH85iyBcmHR5jmGtFozC2XHSXGFC1g94cT/GTmCdOn/rrlhyWBP21sk4y OLlw== X-Gm-Message-State: ACrzQf0I1zixsqkLDf0MGksTXBbuVYQZUYeVLEafiBOT22zUIIbk2F/m TotVdUSOqumyEU62Un4Ubw== X-Received: by 2002:a5d:5552:0:b0:22e:6941:81f8 with SMTP id g18-20020a5d5552000000b0022e694181f8mr6563177wrw.521.1665256255039; Sat, 08 Oct 2022 12:10:55 -0700 (PDT) Received: from octinomon ([2a00:23c8:2f02:3b01:3ea1:40:8650:189]) by smtp.gmail.com with ESMTPSA id q3-20020a1c4303000000b003b4bd18a23bsm10912968wma.12.2022.10.08.12.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Oct 2022 12:10:54 -0700 (PDT) From: Jules Irenge X-Google-Original-From: Jules Irenge Date: Sat, 8 Oct 2022 20:10:52 +0100 To: erazor_de@users.sourceforge.net Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] HID: roccat: Convert snprintf() to sysfs_emit() Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org Coccinnelle reports a warning Warning: Use scnprintf or sprintf Following the advice on kernel documentation https://www.kernel.org/doc/html/latest/filesystems/sysfs.html For show(device *...) functions we should only use sysfs_emit() or sysfs_emit_at() especially when formatting the value to be returned to user space. Convert snprintf() to sysfs_emit() Signed-off-by: Jules Irenge --- drivers/hid/hid-roccat-kone.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index 76da04801ca9..f0c35c05e702 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c @@ -403,7 +403,7 @@ static ssize_t kone_sysfs_show_actual_profile(struct device *dev, { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile); + return sysfs_emit(buf, "%d\n", kone->actual_profile); } static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL); @@ -412,7 +412,7 @@ static ssize_t kone_sysfs_show_actual_dpi(struct device *dev, { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi); + return sysfs_emit(buf, "%d\n", kone->actual_dpi); } static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL); @@ -435,7 +435,7 @@ static ssize_t kone_sysfs_show_weight(struct device *dev, if (retval) return retval; - return snprintf(buf, PAGE_SIZE, "%d\n", weight); + return sysfs_emit(buf, "%d\n", weight); } static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL); @@ -444,7 +444,7 @@ static ssize_t kone_sysfs_show_firmware_version(struct device *dev, { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version); + return sysfs_emit(buf, "%d\n", kone->firmware_version); } static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version, NULL); @@ -454,7 +454,7 @@ static ssize_t kone_sysfs_show_tcu(struct device *dev, { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu); + return sysfs_emit(buf, "%d\n", kone->settings.tcu); } static int kone_tcu_command(struct usb_device *usb_dev, int number) @@ -556,7 +556,7 @@ static ssize_t kone_sysfs_show_startup_profile(struct device *dev, { struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile); + return sysfs_emit(buf, "%d\n", kone->settings.startup_profile); } static ssize_t kone_sysfs_set_startup_profile(struct device *dev, -- 2.37.3