From patchwork Sat Oct 8 19:43:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Irenge X-Patchwork-Id: 13001865 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B9A8C433FE for ; Sat, 8 Oct 2022 19:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbiJHTnY (ORCPT ); Sat, 8 Oct 2022 15:43:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbiJHTnX (ORCPT ); Sat, 8 Oct 2022 15:43:23 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB9552ED66 for ; Sat, 8 Oct 2022 12:43:22 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id ay36so4688493wmb.0 for ; Sat, 08 Oct 2022 12:43:22 -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=dENEKygRwSDGf9BtYiof9f1e4xEx6iQUvp8M7Xgg++w=; b=qMX66aAP31wBN0iSW8w04jvqvUZ3sgREynEjfMxED3SFrHIi/er8oMOlTk87GSrtcd BE+28pZGpASQFXC1h9DQMxrib5RS2k/zCaIzytBglgBJQnMHRs4p+r92PaEfs1r2A8w9 rXJ7sdHoglc1WM+PUTwzHomtRvN234xwW/4pjU8Xd4jHVY6odqC0U7tjVl8oWBiKd5Dx 1L/wsYCTZXhrd4shy/OUmFCBt/t/zoJIOuA37ewwvJTrAEecOlhYUJodT8pXXqYBx8Wp hEoeLtaInNuimpvXGY53153+FRUzvTki+BLA+FVDcruhxlHORxXhkesp2hqnIJ4Eu61J 1Vyg== 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=dENEKygRwSDGf9BtYiof9f1e4xEx6iQUvp8M7Xgg++w=; b=dw2aHlJQWfSDbHhFSi9hY2/xZ3D9W8M38NUD1LmYwnOVaTOHoWJdmm7gxsMF5TKnw5 LVb94EdgUvZWGpWZrT4CTlHK0CE9UikV7X+Jh9KMMmORQOclzm+cJ8JIvz/lRXp1dKfa Y/tzjwd7Qcwn6ZoXa1HLdZKxk7g5h2zl/YWRE45FTqTRLDSg5JNQrUC//jwrPJ1SadZz 5oM9vDf6frRsYzVA6cW44SpB99tVtgHME+FEoqUExFC0SvSdvaYKr5yHS/m4wQMWNUUi chlkUnUKpVDeIu2v9rMa+jJFQAl582593tO/UwwR8TGxRxByek2F+hNog/uJM0rvIruL ASvw== X-Gm-Message-State: ACrzQf22H5wEqtjdYGa3H1SYhOsYP+MH0yBu61tQEj5aozcHgl+YA7xy BgGJdm/0OUGGhpDzw75vsjMVF5nH+A== X-Google-Smtp-Source: AMsMyM60orbbNN8EDUUKHY3pf/y3yOZ24xmSKbXo8tor5kX1Lgo+7cjdaZwULTUGW3yi6reDMWMLTQ== X-Received: by 2002:a05:600c:a4b:b0:3b9:859d:7ed6 with SMTP id c11-20020a05600c0a4b00b003b9859d7ed6mr14653521wmq.169.1665258201143; Sat, 08 Oct 2022 12:43:21 -0700 (PDT) Received: from octinomon ([2a00:23c8:2f02:3b01:3ea1:40:8650:189]) by smtp.gmail.com with ESMTPSA id p17-20020a05600c1d9100b003b47a99d928sm5239179wms.18.2022.10.08.12.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Oct 2022 12:43:20 -0700 (PDT) From: Jules Irenge X-Google-Original-From: Jules Irenge Date: Sat, 8 Oct 2022 20:43:19 +0100 To: erazor_de@users.sourceforge.net Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org Subject: [PATCH 1/2] HID: roccat: Convert snprintf() to sysfs_emit() Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-input@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-pyra.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 4fcc8e7d276f..8b4d2519d4c4 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c @@ -286,7 +286,7 @@ static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev, { struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi); + return sysfs_emit(buf, "%d\n", pyra->actual_cpi); } static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL); @@ -303,7 +303,7 @@ static ssize_t pyra_sysfs_show_actual_profile(struct device *dev, &settings, PYRA_SIZE_SETTINGS); mutex_unlock(&pyra->pyra_lock); - return snprintf(buf, PAGE_SIZE, "%d\n", settings.startup_profile); + return sysfs_emit(buf, "%d\n", settings.startup_profile); } static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL); static DEVICE_ATTR(startup_profile, 0440, pyra_sysfs_show_actual_profile, NULL); @@ -324,7 +324,7 @@ static ssize_t pyra_sysfs_show_firmware_version(struct device *dev, &info, PYRA_SIZE_INFO); mutex_unlock(&pyra->pyra_lock); - return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); + return sysfs_emit(buf, "%d\n", info.firmware_version); } static DEVICE_ATTR(firmware_version, 0440, pyra_sysfs_show_firmware_version, NULL); From patchwork Sat Oct 8 19:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Irenge X-Patchwork-Id: 13001866 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2347C433FE for ; Sat, 8 Oct 2022 19:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229798AbiJHTq6 (ORCPT ); Sat, 8 Oct 2022 15:46:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbiJHTq5 (ORCPT ); Sat, 8 Oct 2022 15:46:57 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6A99326DE; Sat, 8 Oct 2022 12:46:55 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id j16so11699104wrh.5; Sat, 08 Oct 2022 12:46:55 -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=ug3lOc6jfgPHpJPdL4UNADTEvLPCskKFnlfe0HCOmbw=; b=n0tI/K/Z7QZYmn1JsfkgpNVg6VscSyMimstyBK/nL8weDKMf56DUqs5z98GR9R6l5f TUw0aMsDkzGqOwoS12y4GI2dXLv2vlzqU4FudQz+ntgGnjOyoja+QMFmYj/seDjI9Xb0 +d9aNHS5QWbeBLe/EupmqE+NsCcHvA01YPRvbJaLATdlW6Je8M/Sz7MKpHD9xylE3LH8 QbM/VVAAGHORkCuLA4y2ZLWytZVkW7hvyQXnzwrhPkoje+JUbzcawbIIf3eLOOBJ2oxm UvGVvbtCej2VOaLl1kRas+ETQ/X2A1fhpaZbwUfhdmlzePrndmNQ6XlZ2owoBYkVTYFD PO6w== 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=ug3lOc6jfgPHpJPdL4UNADTEvLPCskKFnlfe0HCOmbw=; b=AkNrECdGuLIfkLpmbkkToa3zDJ2i16TMBZLvw/QBjURkb2PRxV+VCNE1zumGcimB/c 2GZtGr4Nbugnb0M/5nf/uEsxjZXFWUE/aQx1oy73jxg39ovTpYebRVHaproPXjyQhqwr esI1JI0OJovIE6j3SThZaBcjBBgtP3M2RM97tFFqWq01b7X8uQ2+jkBaJ0E+Az/d2ptu gCKbb+BBR0X8KgOllcaJNz8vNwBtD7YjL7XfBRmd0cT3gE8voAin0fdmqBna1e9sNUO8 EUHfX+pvLcKIlt+ySYYSiJOxzkktmxpnXplaa49HrIH1QYZMNSf+Im2nlZSpGWU7srdg RIgg== X-Gm-Message-State: ACrzQf2PDr/wutkQx+SSwQfekpDg9bmhRq3Og7iJlWPXwfp3XVPpdGmP FO31k1f1ZYu1qnJUUOjk1w5n4npauQ== X-Google-Smtp-Source: AMsMyM4ZQVOmT+WW0nvOmRqYLse5zaWyiRiDBLMoBNS9Q5QfykkWHl66eY+4fgW8C/vvPTxoNHLn1w== X-Received: by 2002:adf:f9c9:0:b0:22e:3581:2422 with SMTP id w9-20020adff9c9000000b0022e35812422mr7006215wrr.592.1665258414357; Sat, 08 Oct 2022 12:46:54 -0700 (PDT) Received: from octinomon ([2a00:23c8:2f02:3b01:3ea1:40:8650:189]) by smtp.gmail.com with ESMTPSA id i129-20020a1c3b87000000b003b50428cf66sm2291828wma.33.2022.10.08.12.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Oct 2022 12:46:54 -0700 (PDT) From: Jules Irenge X-Google-Original-From: Jules Irenge Date: Sat, 8 Oct 2022 20:46: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 2/2] HID: roccat: Convert snprintf() to sysfs_emit() Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-input@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-koneplus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index 1896c69ea512..1635ddc7c3cf 100644 --- a/drivers/hid/hid-roccat-koneplus.c +++ b/drivers/hid/hid-roccat-koneplus.c @@ -244,7 +244,7 @@ static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, { struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile); + return sysfs_emit(buf, "%d\n", koneplus->actual_profile); } static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev, @@ -311,7 +311,7 @@ static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev, &info, KONEPLUS_SIZE_INFO); mutex_unlock(&koneplus->koneplus_lock); - return snprintf(buf, PAGE_SIZE, "%d\n", info.firmware_version); + return sysfs_emit(buf, "%d\n", info.firmware_version); } static DEVICE_ATTR(firmware_version, 0440, koneplus_sysfs_show_firmware_version, NULL);