From patchwork Fri Oct 15 11:07:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5pOO?= X-Patchwork-Id: 12561039 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7260FC433F5 for ; Fri, 15 Oct 2021 11:07:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 565AE610E8 for ; Fri, 15 Oct 2021 11:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238301AbhJOLKC (ORCPT ); Fri, 15 Oct 2021 07:10:02 -0400 Received: from mail-eopbgr1300118.outbound.protection.outlook.com ([40.107.130.118]:14625 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238235AbhJOLKB (ORCPT ); Fri, 15 Oct 2021 07:10:01 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nPJd60d6GNABTUOKGou6wA/88ISaOO+AkfHyXQjCLqwTOecWKC2sqlf72swDm0jvT3DDCnkPWhZoJJe9HVZkaE7nEhrKgvinEZ4KIhv9HS5h/lvew2boDI7QZ5t7TxZCNQeSRkXwWNm3Ub+tBKblMMet5VLCtO/VowZ3AkUufd/1cYmUMEbaR18O2/C8Q5YTgnMkn+5kNXEwvhshsioNMiDWOZnXvJeqNuLgLbwA1bSDE6a/ds0lYifh4JBbAw46dSq0Buf1ZbYW+kb9YqWiqpj/TmwR+f7zg0i6vgsjzpG5b9DK0pS4DdJKyllCK8ooV8YDgwl7S31/0EY0/544uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6P6jGKUJd02VtL2cYBHjUPwk/UcDG5wsCZhY8YShl6Q=; b=WULylvvybvVi48qwvbnCcKZIwXs03Yph82LbqaMKFEfFVo9A+lwhbv2OePBco9Vw9vF1g8uPcWTuTlccNfqgbdR4gHpLxK2GDNkOK/aswSEOaCrM9oYi3RmgvicRGSQTKjFOEsO6t3Lsar45FWYnuac6uEojBJxxVyC83OdG/MiX+hMV81nFFhO3AXapKP/A31BRmvR96mtffRZBkl9MhUNjBniIoq4/+wq0txduiGTN4tiwvq7TH0gf4mSJ3QyN4jJUR4MV/M5dJzei2jBJqYr4tCIzqzbUPcDPyen83/DOQbK8re8O/LBk14+SVNvV7pNMxOVxYolPQScj5Ul3Jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo0.onmicrosoft.com; s=selector2-vivo0-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6P6jGKUJd02VtL2cYBHjUPwk/UcDG5wsCZhY8YShl6Q=; b=EXw65qJE9azB6oXFaHyEB7k4/W1s0Q6H+a+TkkZDe2ZOKyPFB4G5NmN4uVR0GN3N0ag6uMhnb+fCm+Ocitj2wNCfQhCtiDFDiBMzu7YqIVp4Hy5Xjclu6IYBgb33Xp34nRJN5V3EsiGI1feOQkG+QTWKxAwYzea42Jyym1m+CJU= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=vivo.com; Received: from SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) by SL2PR06MB3212.apcprd06.prod.outlook.com (2603:1096:100:3b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Fri, 15 Oct 2021 11:07:52 +0000 Received: from SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414]) by SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414%6]) with mapi id 15.20.4608.017; Fri, 15 Oct 2021 11:07:52 +0000 From: Qing Wang To: Jiri Kosina , Benjamin Tissoires , =?utf-8?q?Bruno_Pr?= =?utf-8?q?=C3=A9mont?= , Stefan Achatz , Jonathan Cameron , Srinivas Pandruvada , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: Qing Wang Subject: [PATCH V2 1/5] hid-lenovo: replace snprintf in show functions with sysfs_emit Date: Fri, 15 Oct 2021 04:07:28 -0700 Message-Id: <1634296054-6971-2-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634296054-6971-1-git-send-email-wangqing@vivo.com> References: <1634296054-6971-1-git-send-email-wangqing@vivo.com> X-ClientProxiedBy: HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) To SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) MIME-Version: 1.0 Received: from ubuntu.localdomain (103.220.76.181) by HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4608.16 via Frontend Transport; Fri, 15 Oct 2021 11:07:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fc0249c-5ca3-4d65-2c4e-08d98fcc081d X-MS-TrafficTypeDiagnostic: SL2PR06MB3212: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:983; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4kCBZd3K4CqiAB/HbZP1ZcdLQdBb1YWEAoNf+0G4DJ8wxGqAFJCM6OkMkFZhiTLXLYBaVlYPyhk1HC/gj/BhilVuvfILIryVbibcwEgu3dvAz5RllSGzirpvofJfoGll6PpMtfl//ktZXneBhBiDdn6dB3FwLtBj4xuFTD3XdmgtAla5CDEsP+d1rpK+3EIf8S4oxOR4e6oS1QarnXQCRN0vK1tk4AD/ybPnuo07FDU5gVDe9gqR4MfmJXHToivIJDqTiq3emaeHSVBUQkLMSJJlmTnHAhr5wW7gK95WfR9ESSTmXKM4RmujoKpXlfUd9sFDQ1BKZQEeMd6i3BJDECwuGra4dzfs1QKcmsI1NZooiTt15gKlLgWC0/0sWH9FN83L6PbfKsgiKmFuCfZiSsqZS7elyNm6yBwTHDHAb251kEQ1wiFIN6WnYMFTc4q9mrJyBuxtPnuUZOfpYMYE6c6xX4pmNlxoyB78eYwWQZLf9DXArioXJLgUZKMA0VU0LDiEh2/jW1zsveJ0c9kQO7uwMwxm/UOt+31u8z8e4CEYFnI5KlVDGLdWb51KjlPGcDg8+/SA8KFwKjXRq5CrhEVXV+4TIcOAXiQBtg68ylMKgB2ncAWvd3uICq2lvm7bAAcV8eWml7qL1DFeK9irdkEWeqhonN6CDaKJQ3KxEIMmt5ktBOeHxlRSRK9B/dOIgY5zJgepAcFWjoluoPrxJA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SL2PR06MB3082.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(956004)(508600001)(2616005)(6506007)(110136005)(316002)(107886003)(86362001)(4326008)(5660300002)(2906002)(6486002)(26005)(52116002)(8676002)(8936002)(6512007)(186003)(38350700002)(38100700002)(83380400001)(6666004)(66946007)(36756003)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 27dZtgo87zN2D0eC/wQVoiOdh9gSGB37VGIi2Cc7TyerQh4MOg3El1ofA39QCGdWqlSMnbSVH7YAPJcdNUmXqWHt/RpMBxekwGv9JqEmKzb88y/1OfT0MG92w0R89p07LINq0sbEj/dA9Q5r0RHbWTzqs2y68j1M6t2VrMsHDvRlnbrNJSgtx8BFsgJTFL+hbWvCENyHR9SUjz3BEQ2m/bAPY8RpQUh4sUSqUhUJAbo9uSnaq0hCtYekOq4S99YxK/TssW9a1dALGuYgyqx8z2uJG+4sX3qSCeLi2kWuojlIYIs5Fy+MVp+Af1UzvWFQmknjfFXoxSZrS7PC49j815Btq12Zv0eozO2SNMmkmtD3FpFKaDRA8TGQlSekNPctXY+xmJ4b51IMIJ+JiGWNuyiMyWvNErIw9ai+s6UnRJQC96yjI6uiwM3QE2kqmET+UtPtBaJgxKI3ZszbBxvO2rwPNWfCJUWdswG6igpHhaSdfnVOkV0t52bUMlw0DPmoZbUKirAQGb0ma/tx3nq19L4G0zUYH3yFmdcqd/IM45uYUOIXeK/8HRdAeJyLQCEsmwvZZrA2bEC4aEZWSCd1d8fG61ggAtBLEmgcyKGve00vbRQkZpLh2zAUPkODDhoW2E59vFr3r6HheZ7ApS7pE5fRjPU2YhmF4n7M6bMS3TDYy0rTM2SkxpnpRYLCcD87xtxCqKS1O6TLIlW8U0Bj3Ew9m2b40BMc8LPJSi+ppkmupBQ0c8Xdd2Q4W8RlP1RRTnMYO/KoxABNH/YdZOvQR8MnbP825fyV0RB3oCbd2dpYS+BaZJcZZPVbl16c/kTbBtB+t89t8iN/aR2qaPaxBxpf4lNv/wx7Z/ZlDsKITctHM6MyoPHT9Mz1/ft/C0VrmijioRy6+vmp8gxpU5O32UewUxHOpH8cuEbrWUmztcB0bvTHYiVLxixbNKO+IjeDdO0LVf7VQ1jSntPYcwYT1eMqHUrIjOvvvO9RELrzash4K0qnm/BC82vJDna5+8dUxz7YhD4N/oyHkQ8iN+Q0oJqSC6EtUkyiN7XCSsAKhxzsGnSEA7vaBnqdwuZS4+3l0ifgy9DUo9LYpuKl70lxEdMT9wtEKLQtEsjTXSDTUstWaW5ki14bJyITrZzZOMDtPcfxLKQ3ANd5cyY/2aNfdcJ7XkNuP+s7FZhDnrS3JqjjGPJGgeidC2OjVHjyNfzMLm8BxHuzzQ1awq+zXekVs1prVgMt/tWkXJhDYkHAksdvbO5TDKfcK/vNU7HYrTAOWi6ioGTAbUT9ESlRwWwnYxYYeAX9f7pUyMW4VFzag/nFgwhObSKPfuGjHa8LbDCY X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fc0249c-5ca3-4d65-2c4e-08d98fcc081d X-MS-Exchange-CrossTenant-AuthSource: SL2PR06MB3082.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 11:07:52.3285 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Xf476o5mdiF9CpfcFyBbdLGgr5112tyXjSGO4FrywaIUpAtHD1XLJlm+bON18wRrFqR2JdJWiOtNvWDbdLSJIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SL2PR06MB3212 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org show() should not use snprintf() when formatting the value to be returned to user space, snprintf() returns the length the resulting string and scnprintf() returns the number of bytes printed into the buffer. Fix the coccicheck warnings: WARNING: use scnprintf or sprintf. Use sysfs_emit() instead of scnprintf() makes more sense. Signed-off-by: Qing Wang --- drivers/hid/hid-lenovo.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c index 93b1f93..086a7ae 100644 --- a/drivers/hid/hid-lenovo.c +++ b/drivers/hid/hid-lenovo.c @@ -400,7 +400,7 @@ static ssize_t attr_fn_lock_show(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct lenovo_drvdata *data = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%u\n", data->fn_lock); + return sysfs_emit(buf, "%u\n", data->fn_lock); } static ssize_t attr_fn_lock_store(struct device *dev, @@ -442,7 +442,7 @@ static ssize_t attr_sensitivity_show_cptkbd(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct lenovo_drvdata *cptkbd_data = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%u\n", + return sysfs_emit(buf, "%u\n", cptkbd_data->sensitivity); } @@ -603,7 +603,7 @@ static ssize_t attr_press_to_select_show_tpkbd(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select); + return sysfs_emit(buf, "%u\n", data_pointer->press_to_select); } static ssize_t attr_press_to_select_store_tpkbd(struct device *dev, @@ -633,7 +633,7 @@ static ssize_t attr_dragging_show_tpkbd(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging); + return sysfs_emit(buf, "%u\n", data_pointer->dragging); } static ssize_t attr_dragging_store_tpkbd(struct device *dev, @@ -663,7 +663,7 @@ static ssize_t attr_release_to_select_show_tpkbd(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select); + return sysfs_emit(buf, "%u\n", data_pointer->release_to_select); } static ssize_t attr_release_to_select_store_tpkbd(struct device *dev, @@ -693,7 +693,7 @@ static ssize_t attr_select_right_show_tpkbd(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right); + return sysfs_emit(buf, "%u\n", data_pointer->select_right); } static ssize_t attr_select_right_store_tpkbd(struct device *dev, @@ -723,7 +723,7 @@ static ssize_t attr_sensitivity_show_tpkbd(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%u\n", + return sysfs_emit(buf, "%u\n", data_pointer->sensitivity); } @@ -752,7 +752,7 @@ static ssize_t attr_press_speed_show_tpkbd(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct lenovo_drvdata *data_pointer = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%u\n", + return sysfs_emit(buf, "%u\n", data_pointer->press_speed); } From patchwork Fri Oct 15 11:07:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?546L5pOO?= X-Patchwork-Id: 12561041 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBA6AC433EF for ; Fri, 15 Oct 2021 11:08:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1D8061163 for ; Fri, 15 Oct 2021 11:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238335AbhJOLKI (ORCPT ); Fri, 15 Oct 2021 07:10:08 -0400 Received: from mail-eopbgr1300118.outbound.protection.outlook.com ([40.107.130.118]:14625 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238226AbhJOLKC (ORCPT ); Fri, 15 Oct 2021 07:10:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YARs6/J4dqSKCIFb9J5lK2q2tHk7KiGYR0dWUFc0s/cvdH78Ipw2q5M26ISesMscdNdeAr7uzD+pH0YKupmP1kDAO0ScfgZmofI+ZXVbJJ3DGWWXRFFvFJjC0TTZIxoiyKsR8LQbxsZIF30Y+soHy3ozvPpDJ+lFim7gZxk5O9YY7+65uB1qSzmffB3XUDef6As+ZQrDbUiXoRPr5+Wi4wHJVxlqr0VgnpSnb22//FdMLP8JCx9DbykFgLrXSWdRVbsUGVpdt/IifN8NTj6ZqdcuivLKy1PPwBBpHggY7em8LPRfqcfUyRAOEwsJ4Xaq3mrlUnk38hqdlNBWrPADjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zXRdiggmXPaF8kQtcBHRO4KmV4NOu/gRUg2qvrt+2eo=; b=POqSeo3qrwy6OJWYO6DIbK59JG5JxSKX6sifui2ywgWM+TUt/7RlA3D0lXworHUPFdZIkDvYSwqYummAEYnjU2a3AoT30ZwGdO3by+yoxO6qYJV/v7pEpu0T6fxV2XHuI21n9j3IkbiyTKnH2IzvqViakAHkIxxnI6oRDuhfT9WTLv2VOoxrTfhEyObJICCOfAtv8ISCKkKApdt9gdH86YD19SP+yPDYBUF5yWOtTCX7oQOYv86ftBGnmTlQeixjOaBWkI27sGNTOfVQyJLUJZTiN3v6PC67iWpFhGwkid+MBpMAoJiKkIRHkpnNdWzLJeG1cQbyTJ4nhUBYH8nqsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo0.onmicrosoft.com; s=selector2-vivo0-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zXRdiggmXPaF8kQtcBHRO4KmV4NOu/gRUg2qvrt+2eo=; b=nM9DCbdTkX9XrNIy6QWqOW8vw5uc44LCST96kFEj9afBT5vPvhwLpu9DmdD7//tXHi5xxsW35jkfYrlQ5fl2j28cfYXI+edBlNL94+YqewcQLkjtSSCW9mXJtXEyxPQO+1BCE6okoXmmUCOKcxosB6gINyKFErex1skGNX3HYrs= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=vivo.com; Received: from SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) by SL2PR06MB3212.apcprd06.prod.outlook.com (2603:1096:100:3b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Fri, 15 Oct 2021 11:07:54 +0000 Received: from SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414]) by SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414%6]) with mapi id 15.20.4608.017; Fri, 15 Oct 2021 11:07:54 +0000 From: Qing Wang To: Jiri Kosina , Benjamin Tissoires , =?utf-8?q?Bruno_Pr?= =?utf-8?q?=C3=A9mont?= , Stefan Achatz , Jonathan Cameron , Srinivas Pandruvada , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: Qing Wang Subject: [PATCH V2 2/5] hid-picolcd: replace snprintf in show functions with sysfs_emit Date: Fri, 15 Oct 2021 04:07:29 -0700 Message-Id: <1634296054-6971-3-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634296054-6971-1-git-send-email-wangqing@vivo.com> References: <1634296054-6971-1-git-send-email-wangqing@vivo.com> X-ClientProxiedBy: HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) To SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) MIME-Version: 1.0 Received: from ubuntu.localdomain (103.220.76.181) by HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4608.16 via Frontend Transport; Fri, 15 Oct 2021 11:07:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f7e3b05a-c958-43a1-72c8-08d98fcc0952 X-MS-TrafficTypeDiagnostic: SL2PR06MB3212: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2887; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hJ20n5GKvsTcCjlxO4AK1JK2GviYIG8t5D8gtTcWeiD2xL5RQ0lf6q5xFs0U1C/FamhSisysSY45oosvVi+JktI1c8GvWaIwghu0ZwUaEQD3OqOdnA8fdMzfBeVGwcLDjL/EWfX1aUf1M6IzVZ5Nh+F99taxpP1F6PyiMplVV75+yjjbpRFuhO1lzI/EIQNdG9bZJNP2MY6awVorYYbfFIoq30onSR0e7zBuBMjUK0Xp+7kvSXw3IybY6Y+1AuIvihYCg/N7PpdQEVweHbfXiagMBnr+jIaGHwdv503N544IFP34Wxvbkv3bvgbALgaYEWIn5tMTqPdL4TYgDkEsaYHYG1MLE+1bl4zDHhDQqK0NBwWg/5SennpvojLYvWeCj+uOMEYbaRrVU0/mHl5GL6oz+NzQYRixlFv6lwV8SXr/zd4epd7Em02wUq/JejGraijJePN9utIv9dsZTKOQixzbdlXYqBi2DcPyvCHdW7HL1iOFvpUbKzXmGfjTY9VqjmAJO7+rbNXI5wDnurD2PKH0MNDIfc4G9RrPapgYKe/RN3STqvhsAcZb6/6g3CbB+PE6siPVGsQPu5yz025gw63CqeXyuDmE1xzfkMjZMO10cmWg3/428P98LJQO/4UAFXlLrF404Kr7xZvlD1ZNbTru9tF8KUC/SAukdx+11DKLj0vaoF/HMotAKKwbRS/k+ZCqTse1NLZoe028Lc7Dew== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SL2PR06MB3082.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(956004)(508600001)(2616005)(6506007)(110136005)(316002)(107886003)(86362001)(4326008)(5660300002)(2906002)(6486002)(26005)(52116002)(8676002)(8936002)(6512007)(186003)(38350700002)(38100700002)(83380400001)(6666004)(66946007)(66574015)(36756003)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?JAyg25CCdh1imRj5bXpSX8yTugwK?= =?utf-8?q?wwDHnzzfLqTIgG3ATbeqCtmfWZXpbbj3T4OSqFjaLHAnLSlolDetqhjbpZMpbR2yA?= =?utf-8?q?6Li2e/AUk+sFKFhKIQnkMqtdsMJW2ROhKiXy+ikzvQ0Yr6onNT9zrtg9imxEKNsgc?= =?utf-8?q?9XoEYKT7PE2hfUTnC7qtgH4jjJhAS5YGNXASGDUJ6K4CWWGpU4wouqfVmhV+lDrjl?= =?utf-8?q?yUlv6SehrIt6sLs/LqAtFQoH7/dr+w7CfTllHvYOkFZFrwUO0i9Cbt9emem4e/hkK?= =?utf-8?q?XxASPQrqyENE6IO4/8h1BhdPuN9UOIJDmy3raxgEdGoGEVisHFNPKb6Y7NeriumTS?= =?utf-8?q?5+wOtYhfeqdKTiWwLzWbmAq3s9AynJY83TX+9eEwhiSHNCgwraM9lV0Z045uZcQZT?= =?utf-8?q?/udrrh9gcBNWOa0cJupB2Do4otB9EvhjFVQSvcMJfZQpNFyjch+Ukhw2a/DXP2Cn6?= =?utf-8?q?tIkrPSpG0IObKqT/JChwvOG2ZJCxNZ9eP+geQWQrPeyaM47xWIpb8flnb4oE2A5Ai?= =?utf-8?q?UsS3PQ9nvU0GpKgKB1mf1KvkYVy+rqFdzf4T1eqZk4ESCK92WcPzMymSTstfB5ud3?= =?utf-8?q?jSSMAyr/xGEXRBdXbCT22VJ1JJgoFUqxECxsYvUSqtQUscgspEivFUDdACYqQ45d/?= =?utf-8?q?zI7KLUzGxBdL0m7zgzBfi2oCBSeZv8a7TonDhrE+3Ly/vb0dz/TZaYu/SypZodN+Z?= =?utf-8?q?9/lgCIZoj5hqWCVrTwZrpbcMhXuowZA0Rcg0JJdv2du5nKE1BIyr4mWQ5jixNx+35?= =?utf-8?q?dGBJ1tQpZFmmJmESdRezsUcgouywQAyszMuh0+0bwqi/xmTZaxW+R9R8UNwzHUdJO?= =?utf-8?q?dMrYed18SBglsp4acXqH/4N1FFbiJr/LJTuEc0M75OxITtOYptK4AhlpnqS+3x7j9?= =?utf-8?q?lpsMxELvlHR46pBRU+CVydOb+3bT24TCkqMhTxUuFm+lHZOTgc1f2IR9YnDt3mQO7?= =?utf-8?q?BmcACho43kPefN13HxmC0MqKWmeLIDoNtkR/uvImA8vosOQb0fK0MCTnSMHL3Yfjo?= =?utf-8?q?hfVrA7t6m7xNLHfCbEdi/YF4CKqUz1jfkKqbB8Eiqm3mlq0M4xIgHJVSTbZAr/wkb?= =?utf-8?q?rRv9xR1AqwWi8r2FHXI/9OzRe6zISaYQEZGj0saKvnPeuVNo2Iq5TSrBsRliygUF4?= =?utf-8?q?9dKWN09BPYPeTmtMkbyTtmbkHrQ3bq8i2km8MpRGaCEjqW0CQvxKEHGyWdudfhm8K?= =?utf-8?q?mQfX1Ux0AEOvzKJ605cGYphlY1QjBx35pn14TJu+1LeLhqBXA0DxbojV9E4dBJiNl?= =?utf-8?q?Z1xQfvDp6sPtKpcu?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7e3b05a-c958-43a1-72c8-08d98fcc0952 X-MS-Exchange-CrossTenant-AuthSource: SL2PR06MB3082.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 11:07:54.3573 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: O8w86TBZ5JAFPXzvRMXnufWN6SvGt/foYQnr/9ufMEv3WhD5JTf1yq54NpRJ16D1FN8hVRHU/Q78FPzj6IRYBw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SL2PR06MB3212 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org show() should not use snprintf() when formatting the value to be returned to user space, snprintf() returns the length the resulting string and scnprintf() returns the number of bytes printed into the buffer. Fix the coccicheck warnings: WARNING: use scnprintf or sprintf. Use sysfs_emit() instead of scnprintf() makes more sense. Signed-off-by: Qing Wang Acked-by: Bruno Prémont --- drivers/hid/hid-picolcd_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-picolcd_core.c b/drivers/hid/hid-picolcd_core.c index bbda231..fa46fb6 100644 --- a/drivers/hid/hid-picolcd_core.c +++ b/drivers/hid/hid-picolcd_core.c @@ -256,9 +256,9 @@ static ssize_t picolcd_operation_mode_show(struct device *dev, struct picolcd_data *data = dev_get_drvdata(dev); if (data->status & PICOLCD_BOOTLOADER) - return snprintf(buf, PAGE_SIZE, "[bootloader] lcd\n"); + return sysfs_emit(buf, "[bootloader] lcd\n"); else - return snprintf(buf, PAGE_SIZE, "bootloader [lcd]\n"); + return sysfs_emit(buf, "bootloader [lcd]\n"); } static ssize_t picolcd_operation_mode_store(struct device *dev, @@ -301,7 +301,7 @@ static ssize_t picolcd_operation_mode_delay_show(struct device *dev, { struct picolcd_data *data = dev_get_drvdata(dev); - return snprintf(buf, PAGE_SIZE, "%hu\n", data->opmode_delay); + return sysfs_emit(buf, "%hu\n", data->opmode_delay); } static ssize_t picolcd_operation_mode_delay_store(struct device *dev, From patchwork Fri Oct 15 11:07:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5pOO?= X-Patchwork-Id: 12561043 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AD13C43217 for ; Fri, 15 Oct 2021 11:08:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F11DD6115C for ; Fri, 15 Oct 2021 11:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238352AbhJOLKN (ORCPT ); Fri, 15 Oct 2021 07:10:13 -0400 Received: from mail-eopbgr1300118.outbound.protection.outlook.com ([40.107.130.118]:14625 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238317AbhJOLKG (ORCPT ); Fri, 15 Oct 2021 07:10:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kdHQzjg5uZKtQ8Yh0T02eCZ5dWwOKkEC9U3Y/Nu2Vd5Tdns3WZKRbauKABmnydbyr5tncfTlEiHaUL7x5r+9hatc/QhII1KIlVCJgvFZUt0RAJzeaMy/RoIUli0HDYFHbWZdmrkBygE7p8jjHK2MXx8u/Uae0JM5DWo2TMc2OJ8GXC2YsN6J1qQp3gse5v7vuQIe1AGE8pEtqxb4L4g56eGE3/FBTjJeLTPQwgGIK7gU6Zm4dWx+H8q9nFqH7iDxE7XQIxbd89Sw5s2RCCOiISLh7ycwGvBNjGq2NMiJIKj1GakoxCCuN8FLLZq5+KKfsEkzM2NYP94XOGGn0r2MJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cIEHJkcjYXVLKCspgsKai63ai8lD/+2pZOGdWaOS9co=; b=KByujjSQbB9b7/fQJiby4qn1MuajkJVxPjtBzIEaXdUxryJVOe4Efom5rv9hM0bKVdx58OU5ax5+fnNzW7uftgsjTXzQRBbMN/J9QLFNfocRncX0Q2z2wiMW1dZvQhokltW/nEZRj44ccvO2cD+Gjge44wAgYg1QBHX75kbjkya9Cn1VMwJP9uc4EKnUAgmaFd81nWu+TLuczOMiJ9ccYz85YC0zuJecTa1Qdu1k0rJ3ppZpuaQS4TxyHsDXe6eQ6AbG2WI3WefDIqLqenVzChXeenBydiQJPIazs4DLWv+ZpOaIBgcN51OQOGSG/jAiNAkFsNh+iIfkMYYetU6JIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo0.onmicrosoft.com; s=selector2-vivo0-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cIEHJkcjYXVLKCspgsKai63ai8lD/+2pZOGdWaOS9co=; b=gAupGPdhjMiOy5J3UYr8T/nph5CNIZn9Ot90Kk2QulM2jxXcre29ysTIJTpQuqotldzvXqHcDaRezyRwOcEJrPMn79y/LiQ/G5kwlGtMEnliRK1yoq/i1VhEgUEXD5xCWqG3mS9towIy0zjjwk1ARxY4EqcNvvZHMzPqEdkrnNA= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=vivo.com; Received: from SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) by SL2PR06MB3212.apcprd06.prod.outlook.com (2603:1096:100:3b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Fri, 15 Oct 2021 11:07:56 +0000 Received: from SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414]) by SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414%6]) with mapi id 15.20.4608.017; Fri, 15 Oct 2021 11:07:56 +0000 From: Qing Wang To: Jiri Kosina , Benjamin Tissoires , =?utf-8?q?Bruno_Pr?= =?utf-8?q?=C3=A9mont?= , Stefan Achatz , Jonathan Cameron , Srinivas Pandruvada , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: Qing Wang Subject: [PATCH V2 3/5] hid-roccat: replace snprintf in show functions with sysfs_emit Date: Fri, 15 Oct 2021 04:07:30 -0700 Message-Id: <1634296054-6971-4-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634296054-6971-1-git-send-email-wangqing@vivo.com> References: <1634296054-6971-1-git-send-email-wangqing@vivo.com> X-ClientProxiedBy: HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) To SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) MIME-Version: 1.0 Received: from ubuntu.localdomain (103.220.76.181) by HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4608.16 via Frontend Transport; Fri, 15 Oct 2021 11:07:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a1c7ca1-c84a-4ab4-e55b-08d98fcc0a7c X-MS-TrafficTypeDiagnostic: SL2PR06MB3212: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YN37jt/U02PzHt550Qu4JaY30CV+edbS05a/N7r4fMCIZqUD834gAz6hdu8OVSS1rMn3B6LHdkDS9lM/A4VMaRpYwZAizRSsFxIz9BdFDSRXKcPlFH8/90hIWrawIm899UbCyrixHatYYXgkcb9DZvH1D4d1zwBZ22DxGtrchRPuecZ6efeLSqDg1xvF5FLH3TfQSsmZ40w3nY9YBjIAB4/v3TyibE4eWx5KShuygZdHEOia0yMb2FfzQni+8FBdg1CkBnk0J+XxLK7PnkSbAQ3mX2KVR6sXSIGgcPLqkX0CZu5RIVefznFq2dG9T+HOzhEZazh9K7blcYbXemToG0NtTYb4jKilrqK5Pudt+TepTI90no+zNB4hf0N1J9j+7AyX9YbbgNhrHWkJHCNVM4YJsZCJF3WYzjleY+dtV8eAaQHOgey1zimgmR3X167bCrOF6Bvvm1S5IuQbmxLsR8PabDPn05stXIqGcn5PVqvP1Hiv128dVVoSp5cu0qMejBHXrioJctHkdbiP181Gt4NrloeTE2SaZ0iYxqt0S3UgF3kBRRM5SnKRsqaTA54nXKAuigdYgAvpV4FTKdAJog6ph0JSU1WflRCDPcWTTtGqu8z7DwqwTki2NArf8YU6fwYXFTH5Mh/bi0QwuKvxrnNJ7tfjb7uMtvKtc+/u4I0f4pLtyas+EvqIK2GJ3yv57g35Xr9U1G1T8GnDwyAdrA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SL2PR06MB3082.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(956004)(508600001)(2616005)(6506007)(110136005)(316002)(107886003)(86362001)(4326008)(5660300002)(2906002)(6486002)(26005)(52116002)(8676002)(8936002)(6512007)(186003)(38350700002)(38100700002)(83380400001)(6666004)(66946007)(36756003)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tNMdoHXQbfXIHBxbi5VqU/xUnE/gAgl8aIC8vXiXMNAURflervtIrtWRAr8KtQxgOmYgukviVOZi11M/jX4biqWRvPZLA1FR5FIO1bb8br6/yfOo3Tb82hmfC9tpIYEebH3fVcSC/qjIH2VYz35mx839hWYiNTAUkh79glFV//Sg9KUH40Y/J1xGC1XNf6TkzwP3iltkicT/iv16sR3CKdATvIA6RDBo9uEhXHOCFwbIWgjI3pjneBeB2uoelxu/8epU2xO1FGIXC4qOLsdETsjEhVk3De1S5Ek450YF7qsHYRXwOKlajBosMIuFJlldOpEwV/0nllyyzqBTs5EL9u8+nVC/ELREj89Be6oacI7l4xUu24N2MiP+AJc/Vu1FDhhg5qVxC09qr9M3ekJ0+gPlcgQ0WEwECEK2VYaspha5PWAf0B6Hw9mnsW+DmWcKdozjYJVusY3qS6EVmjKSOs9NZ5zTxe0NQrf9mUn2Sos0XCcoo8E/MHQcK1gB2fgZIUTtH4/RejIzZsn6bELAc8nYLlph3evUw9pMKCHRANmCVkEY32N6bvmSBQtMHwuA5bxbopchEUpX3DtYu00s14avkuNZIf6Frj++c88v7UjxvovyVsuuCXcvTlP1fpqqegPf4DCsZgRaNCQXDXT+/sFM9r5cSgsyZzNX0lpY/c5nDGjmegmK2F4ZEzn11dOgVsSFlE4fl0ACMj6Eid473GweXr00PlL4H+XdXDKGNYGhndMmbJsAd8csMTySngMPIgdxzK8g1lyN7OjRbHzPs2rXPs3Izs6pYgh57gZc5CPVrAwfvSTmxwbAbAaDkQprXVcq6ZMWhSMParxcaai0G0pZmEsqaXyKFqmKYvyDNPhnDXaF0dfJahjYP5KtbWoBPB9U4LFnHoxDYVSFbf5M4KJDgqEfi4MDG5phwFNDRE/KsA+tI5geJgZLIv9sotZlKqUbFcTe+fnYE8XoDiM7IxJYaDam4NvoAujx5doMrjLN9CYf47/fN9UkyCdGHfeAMmr5UKiIpTVjV6VC5BzcL+4wGJqrMwpV/1c9emvDvtWkn+y8ZX69hTXNiH6enElifYS+x6IUa5YUG394fzEVB7p5a+Vbmcf9pNdw1yifWX7XI47p92b1TOhAmAm+e6SHTsDX2fjb5gzkrHF3+rOA2IJcwQgp+lcmveu73IFwua05KmGS9EwcZXGakILWxFbtTfFOR51gf7ooYw7tJFcjZ1rgXztahPHOgzUevZG4bOPVjT4IBTpRgOqo8J4+3KlBqnPDdwJoGGXCk+Z6DyOF8DpXUsn7e5kXAYjlpMj+8G3/7VsBVj0Cumeh5rnDmFeh X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a1c7ca1-c84a-4ab4-e55b-08d98fcc0a7c X-MS-Exchange-CrossTenant-AuthSource: SL2PR06MB3082.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 11:07:56.2722 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ji8Nc3wq3NOlbUMD8tW4zTd71X+Ry5Hnimi9tSLWnVp6dXEc+sSh31l8FjlCm4rMgeKTfY+Gnxe3ATJNgrhsvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SL2PR06MB3212 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org show() should not use snprintf() when formatting the value to be returned to user space, snprintf() returns the length the resulting string and scnprintf() returns the number of bytes printed into the buffer. Fix the coccicheck warnings: WARNING: use scnprintf or sprintf. Use sysfs_emit() instead of scnprintf() makes more sense. Signed-off-by: Qing Wang --- drivers/hid/hid-roccat-isku.c | 2 +- drivers/hid/hid-roccat-kone.c | 12 ++++++------ drivers/hid/hid-roccat-koneplus.c | 4 ++-- drivers/hid/hid-roccat-kovaplus.c | 10 +++++----- drivers/hid/hid-roccat-pyra.c | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/hid/hid-roccat-isku.c b/drivers/hid/hid-roccat-isku.c index ce5f225..58eb4b0 100644 --- a/drivers/hid/hid-roccat-isku.c +++ b/drivers/hid/hid-roccat-isku.c @@ -63,7 +63,7 @@ static ssize_t isku_sysfs_show_actual_profile(struct device *dev, { struct isku_device *isku = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", isku->actual_profile); + return sysfs_emit(buf, "%d\n", isku->actual_profile); } static ssize_t isku_sysfs_set_actual_profile(struct device *dev, diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index ea17abc..e53d005 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, diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c index 0316edf..9c39b17 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); diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c index 9600128..17581c4 100644 --- a/drivers/hid/hid-roccat-kovaplus.c +++ b/drivers/hid/hid-roccat-kovaplus.c @@ -274,7 +274,7 @@ static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev, { struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_profile); + return sysfs_emit(buf, "%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_actual_cpi(struct device *dev, { struct kovaplus_device *kovaplus = hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); - return snprintf(buf, PAGE_SIZE, "%d\n", kovaplus->actual_cpi); + return sysfs_emit(buf, "%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_actual_sensitivity_x(struct device *dev, { 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 sysfs_emit(buf, "%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_actual_sensitivity_y(struct device *dev, { 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 sysfs_emit(buf, "%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_firmware_version(struct device *dev, &info, KOVAPLUS_SIZE_INFO); mutex_unlock(&kovaplus->kovaplus_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, kovaplus_sysfs_show_firmware_version, NULL); diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 989927d..9cfa003 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 Fri Oct 15 11:07:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5pOO?= X-Patchwork-Id: 12561045 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77D21C433EF for ; Fri, 15 Oct 2021 11:08:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 57C7C61151 for ; Fri, 15 Oct 2021 11:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238365AbhJOLKT (ORCPT ); Fri, 15 Oct 2021 07:10:19 -0400 Received: from mail-eopbgr1300118.outbound.protection.outlook.com ([40.107.130.118]:14625 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238316AbhJOLKN (ORCPT ); Fri, 15 Oct 2021 07:10:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DPbjLRMqWmZZmVmOpea0HSWzHCaXjOSVGmp69vuIjtsPdgeiJ//GBNo6YfZh/hefJ3eLej616dQs+222384YO6NniHkQh6gTzh9bK2l9CE73YVfKDcLGhqgnXnC33U6aB3W4Ww/Srg/kwirK37NP5umjlAb3jUwgASaHJpVDurz1pTh7k9PV8AgkmBNd4Tr0YM12c0arjfKMmUAKUysVIFw8nmjKPybdUJBnQgEmkK0au+p0q7Sm/ITTnxKxxSVVqtLIvsstS6uWsC7A7bRPUhfxA5xKRxCQV7hQdt1WsMa6i7Ijq8h1WaaJX75NDBagrg8jfdiYEgQMcLT0E6ylXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4Bw4yTLLsH0XYih1jVc0KaepZMLLwjcCakk7F+Sy/Wc=; b=DW/yc6WLc+arfRAAVH53bWtmydx7Mr0rjbKvuNXTnVYZXxes5hoGtks5oUW6kC6w0CW7SDlGhZ4OTFk66aoV1/Gs6MRF4wJEYrsomIDvbkAMETxOVCXg/O1dkKNKO5U2wnWjIVZ82rX4tw0KnHfBSYwjjO2yb6vcm+lKWa5Qgx3tnAAHu/Urx4m5W0d4+gIuyHBZR/Mkv1GcHdIsQzrrvMnaBH7jf000ZrnknyMzIdqyi8GxLPMvGDgmdjXzoWKZiJiFCaaxOmBYI2MByBmNOI5KZY5Tm0zItPrLO5p+3Elko4qjZkZm19CjVb3C46WBf3HQ9652D6RLw5EAz9OkPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo0.onmicrosoft.com; s=selector2-vivo0-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4Bw4yTLLsH0XYih1jVc0KaepZMLLwjcCakk7F+Sy/Wc=; b=X6MrGfw+qqRwu4PpmKWXGn6VMYqRfx8pVxO5Or6yIgUCphUV7cQ7gELomkUNRfSix2RvdqyzD3OsZQLZ0IGg97QEbj4xVeOAZjAPoS8CrvXWdOlE5ZJbnbD/H21Bqm4AB1kVHF5Xho3ez9I1+h+/bcxiGMBeEury99UHgM8ZRuM= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=vivo.com; Received: from SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) by SL2PR06MB3212.apcprd06.prod.outlook.com (2603:1096:100:3b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Fri, 15 Oct 2021 11:07:58 +0000 Received: from SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414]) by SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414%6]) with mapi id 15.20.4608.017; Fri, 15 Oct 2021 11:07:58 +0000 From: Qing Wang To: Jiri Kosina , Benjamin Tissoires , =?utf-8?q?Bruno_Pr?= =?utf-8?q?=C3=A9mont?= , Stefan Achatz , Jonathan Cameron , Srinivas Pandruvada , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: Qing Wang Subject: [PATCH V2 4/5] hid-sensor: replace snprintf in show functions with sysfs_emit Date: Fri, 15 Oct 2021 04:07:31 -0700 Message-Id: <1634296054-6971-5-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634296054-6971-1-git-send-email-wangqing@vivo.com> References: <1634296054-6971-1-git-send-email-wangqing@vivo.com> X-ClientProxiedBy: HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) To SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) MIME-Version: 1.0 Received: from ubuntu.localdomain (103.220.76.181) by HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4608.16 via Frontend Transport; Fri, 15 Oct 2021 11:07:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cec318e1-ea92-490c-a232-08d98fcc0ba0 X-MS-TrafficTypeDiagnostic: SL2PR06MB3212: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:291; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VvW61PqNl7Hhr+M8qP8JVh72cqGPPCGMnhdvPV6nsPuTQQjyOscP87F98KDMC9z2t9v0g+nLId8uyl7wokmtq90mbW4GbXSsDUL0MIOPn62arZrOy5UNWXKc2q6pMCALQHvdO8rEdlGhK0orwtehLAqGRVodMLBGAo3HQ+pV1ZpqCsePF8Y5qZlJKfRiS2OlEtzisAo+aaVs0cpa3EjovThlL/6cGeN1y5hK4mX4KhAb0zFSsyw0eP/OI5wsRBRTjWUAfrirclKYsEdmKj2SkM8pbm/ZbKW3Uemsl4qHeB4E/rWF6lLckbue5RXO9ee1B6XKAFZQNbiyOw/LDfr2u/GOpq9X7nUejq1FP7Z3CgF7QmBEtf1SoiwvjbmltwbphhlLNwL+jRSU0Gy+uot6xe7wShFfyhbCqrLrEC5vxqHHBqFgCm57L0SGw3RJfL5spkziowxvph2u4s9p/eaCy178PSMkas/kK1sI9stFliJWrHsQ/79sC/F+oyKtrLujFmT8UbBLJzvOi5ZFxxjUqen8exRU7zjgXtexrngku1MN9Sw7aRRYeK//79y6BVZ3umsPtF142klq6HvXi1DROPnclMkj2TkXf+7qB209vuyOPNQrGWdiwY9XVhcSwxZRHjJAqdKyUIvsAaLID5YZQQYS8Ei5UWbjBSSy7drfO4XIOBDzODFvbwbExYNvadqh3RA9OGdNC3h6KSR9lWdEAg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SL2PR06MB3082.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(956004)(508600001)(2616005)(6506007)(110136005)(316002)(107886003)(86362001)(4326008)(5660300002)(2906002)(6486002)(26005)(52116002)(8676002)(8936002)(6512007)(186003)(38350700002)(38100700002)(83380400001)(6666004)(66946007)(36756003)(4744005)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uiI+LLg1mAsxVz9CvMxjumoE7JsfwbYzWVBRs/hizT2+PmShV9Q23L3t9kZ7jlYubh0Il7GV5422ZXQRiaAFh4bLrveEl4b0sflhHL17UTdiP0EqDcfpUKEvEgBnEq9kxXZSD9l1af7OH7r+X+3D1euWNjdOLHWbx77ENeZWCtDbI1PDeYPPXmJCobwH4fIMf/Aaq6SBHL+WpSeEiJ01Vd+R5z0dJfliceHkDESMERJuSSDHG95TNSQfvJZNPMY9B7KwJvZBLgnPdJoh+xCXSIjvfLohE4WaG+cwgMPL9wqtRzRbstCSvzuprTGGrjuI554DiwYRbha/4tz+/jqv+FfTNh8ASBdKd3DwKGzLCP8j9cywetdYzbduP4LzZYimSCDrXUZXUsn4HkEbVXVh9w1rmRZq56Kxllc/3/T5g89rrDsyga1Ji8Asm2yxHSdRz3zguqC11grs++Wykt91xy7UPXUI2dBk5wlOxuKdz8lVQgPEREzQ3ZcQi+CISIDEVYhQbb1mbmHu2RU9OFNnnkrXTy4KnvHwIp32uUEOnwz6r+DWwmOK4pHjuacQMUC2u9Ay+ghZBj0BeZaTbDz9Kfyvw2LUQmONgGQH6F3/Hrhju8qjJzhrzAIiy1iaiJ7cSwMWPxiNaiCT3G7e3F2PnC+V2FRp2rxh8dtlflw/xwyWkjP9ybPp8Ci36ck+3aWfyLxr3MZ5CWWHGaYjQeYVsZQ4zYZ4igerNfoNQV0jct3EVdWAKVtyXQlaTTMnG/vF1i8gLTnuFZvdFccujcdewIG3KaW40rJmYQmq8/YD59K9PGQQPGEiQU8McyKnpFN+rgyn3LPqCl0XHbdv0BAilCQIT4VrVAl33CmGybRde6WaTtZV1GqYIBdhU5FblupwTAUHzbJJz4iN2VsqCz/37AMMR+ms6v2QpPSiJjtbPbLoEtq9e88QWWmnEgA8m9Y0taPkKXqB1zkgW6/VBdkRzEUxFhmo63H6PVAqPEJW/243NTa1+oNzRg0bdAQ5NZbvELaRkAHUvNeRJuUnbEi7zV6ZsLaVpvYjhojPzqNRRcJ0nDnV/ZD6mPUcEzfL5yRIYnJF8drxC7CH971VqQ37PJte2C3pXp82Kfy9WgQgQzrJmVaejK/8n9OZ4AQB+i3XYNnPM5yfMHef6X/9uzN3aUik7t3PAW5N198HIpQJ7iJw1SLR3zOvg4VMcIjP3weiY7D1ecX8rYJGfTLJJPlAmlfQn8ufYX/osXvk8vobPQ9OFhJdoUvFm1XQGCBnqbm8lkTToTz2oQI6cPSFlmvzncA4lW1M4GJh0C69VYpVDcWZ6CFaHIGcTewqz0r9jrSa X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: cec318e1-ea92-490c-a232-08d98fcc0ba0 X-MS-Exchange-CrossTenant-AuthSource: SL2PR06MB3082.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 11:07:58.2641 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Xt61lWOQNmJyOIxNILAMb7NP8COyz2a+xqeIkTuL5XPCGMzAsW9IIeZ5hsGnMDRddlCzdHbNQyyjH6Fl8JEGDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SL2PR06MB3212 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org show() should not use snprintf() when formatting the value to be returned to user space, snprintf() returns the length the resulting string and scnprintf() returns the number of bytes printed into the buffer. Fix the coccicheck warnings: WARNING: use scnprintf or sprintf. Use sysfs_emit() instead of scnprintf() makes more sense. Signed-off-by: Qing Wang --- drivers/hid/hid-sensor-custom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c index 32c2306..a46481d6 100644 --- a/drivers/hid/hid-sensor-custom.c +++ b/drivers/hid/hid-sensor-custom.c @@ -371,7 +371,7 @@ static ssize_t show_value(struct device *dev, struct device_attribute *attr, sizeof(struct hid_custom_usage_desc), usage_id_cmp); if (usage_desc) - return snprintf(buf, PAGE_SIZE, "%s\n", + return sysfs_emit(buf, "%s\n", usage_desc->desc); else return sprintf(buf, "not-specified\n"); From patchwork Fri Oct 15 11:07:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?546L5pOO?= X-Patchwork-Id: 12561047 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 150EEC433F5 for ; Fri, 15 Oct 2021 11:08:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2F0361163 for ; Fri, 15 Oct 2021 11:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238369AbhJOLK3 (ORCPT ); Fri, 15 Oct 2021 07:10:29 -0400 Received: from mail-eopbgr1300118.outbound.protection.outlook.com ([40.107.130.118]:14625 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S238322AbhJOLKU (ORCPT ); Fri, 15 Oct 2021 07:10:20 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lN7RDoO9ij2fUEPQbS53jGmikJZx9cW7xYlhSz+iay8d5OYgSRnVA9qomf0+kS2KigOdEztbF5qkUsLRcMGjTUm3SubU/UmQKK9tsi3cblelfezlSA65DgZM6/uIUWa1B4sNL7IPsMUjKCFEgJrhofOzuV9RFbyQuxNH+c8KvoSmy8JNZCpWUBA5dwGj04ZrKu9EQThlC0nciNJ5aFhdaXl0oh9coZNCnkx6jjnrx9GTvu0g4u+SnLUHbbYVrz6QrAxC/u14R6Y0aPVCqTK9dskf9k2mOc/rQdV+pFyd2FWmlKp8LkECIq+ltpgfkYAiyGMSizHE3gl4G5Y2qs5Ykw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Cy6B4AhVgYgyaErCxKv69mv2q/sFNND0VpFvBhPXoMo=; b=GgoIF87btidOQcxoUpunjs3cOQkb42X77dBA3BJapwDchM+Zqjv8+ogKWHKvBzz0Um1L5fr08za2dyTnfIup2YXyZI6Kq/BFU/zJWpyREhhDoL6hTfK+7UExf5b6n7f5t6kqVDvQH4VFsQDSRtaVkVVlEdqLguWcZQ6xH8y35u3opdoVrDDl/1rO5OmbdfmJmwLojeBzDK8Wm4JGa53AZTMqR1iQ0CcgkPU8D+AM6LEdrDuQcFpvoKoKqUh9XMS/6yuQ2pc5qq/ewIbQUY6Rk6MGkPUuJ1Bt5kB5gtd/AR7re0mxhKuyFIArd1SuC4cvClrGT/w9DQNvQ/NFuTqs7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo0.onmicrosoft.com; s=selector2-vivo0-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cy6B4AhVgYgyaErCxKv69mv2q/sFNND0VpFvBhPXoMo=; b=hR1S01bxgIVNHDjAKhWFDsB6u9ORc18J3LFXQ23IF7RyH3FDuEGpqfyuSpBXRSUeVDU9/bXhB/mPz2H840CFLMjKsfLPyEMs0uTnOggn/rmAzP0vMGOGBluFtP7OLo2lTbgfmObFT1R/8Q0CgX7MPqEbKE2LBI4xMYpaLDYF0Xs= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=vivo.com; Received: from SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) by SL2PR06MB3212.apcprd06.prod.outlook.com (2603:1096:100:3b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Fri, 15 Oct 2021 11:08:00 +0000 Received: from SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414]) by SL2PR06MB3082.apcprd06.prod.outlook.com ([fe80::4c9b:b71f:fb67:6414%6]) with mapi id 15.20.4608.017; Fri, 15 Oct 2021 11:08:00 +0000 From: Qing Wang To: Jiri Kosina , Benjamin Tissoires , =?utf-8?q?Bruno_Pr?= =?utf-8?q?=C3=A9mont?= , Stefan Achatz , Jonathan Cameron , Srinivas Pandruvada , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Cc: Qing Wang Subject: [PATCH V2 5/5] hid-sony: replace snprintf in show functions with sysfs_emit Date: Fri, 15 Oct 2021 04:07:32 -0700 Message-Id: <1634296054-6971-6-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1634296054-6971-1-git-send-email-wangqing@vivo.com> References: <1634296054-6971-1-git-send-email-wangqing@vivo.com> X-ClientProxiedBy: HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) To SL2PR06MB3082.apcprd06.prod.outlook.com (2603:1096:100:37::17) MIME-Version: 1.0 Received: from ubuntu.localdomain (103.220.76.181) by HK2PR02CA0172.apcprd02.prod.outlook.com (2603:1096:201:1f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4608.16 via Frontend Transport; Fri, 15 Oct 2021 11:07:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61d2bf6f-1ed3-4e5c-7760-08d98fcc0cdc X-MS-TrafficTypeDiagnostic: SL2PR06MB3212: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1360; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y1xLs2QrbJFeT1cuSczgmRcMOeOXenS+AxNF1H/WD0+Iic7HcPmMEgPQWRG5FR1p4ehCzgN+6ewuXb/mlnQHQgjjEi23WAy5/g0KL1Z28MhUhyjbHwhtfUPUQGxhw1TpG2zRfb545aWfiRrmTirlQX/dTblAtOgfTTogSM+gLNvp3hrfv1zlPJLh2JC6bicC3tp+LCVDQ6qL+M338YechThjlrKbUnieUbEkHKrIGF/Cx/DMxCoGY+0rW+AdIZ3VB+qWCVsdveeZ8NSA+5ipL/+yaModYKXCBQL0HjAY5wcSK/iXGJgbpMMBqCh2mpYYlM9iBkH8zzc4/7idNDRJ96OUfZuquJ5sQUAc92q4pRQ17Y5cH4R/F4bbckU4FJJuuqg/CzJcpKmZg4mo8BdrNBUmK/DuEDXGgsjIzKLH/3JsXfP8PNtBMM28r5kg+Yq4x6ZhUF9bp70+yRuBb/Lu2NclyQ+cv0I28bTlZ9zsWl058CgVC3GAOAnz6DdqpaJKp1gr6YpqwDoanGGXcyDYf7yI2/GR9a0R00nINSUmzghmGQoOzdadNiQgq621jAvFofG27itptWieCSceBc3S/K7kwuZ6M8e6RbdkFz7GR5lLzZwYSdOCUICAUodhaKtk6s/njHuXTy5uz6s5IKrSPPkLkCYNKa0bxOpIGMqERAs57RLjm7Pyg/zsHPWbEGMvuZpCjNdCXVNzMkjZ7lyxFw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SL2PR06MB3082.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(956004)(508600001)(2616005)(6506007)(110136005)(316002)(107886003)(86362001)(4326008)(5660300002)(2906002)(6486002)(26005)(52116002)(8676002)(8936002)(6512007)(186003)(38350700002)(38100700002)(83380400001)(6666004)(66946007)(36756003)(66556008)(66476007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nsP8zqNqZdq0+9NLffu9C7Eq0QbYeVmGIsi91vR9AAruadtNld002Fra8zhMkiIa8RPQPud0nqKVXCLaG/7d1Wrxecb+6d+Vgn4dCDKl80Z6knHtfFDnbm3Ct5uwFq7sZ4yvP+zE7g8L7XFu8bKthYIT3Zf0sXegNqZKjFaGAfnJucuvhSi5qzxzt9sBADlFuevkMLoYyoPcWVxV23OFaKd/N6ewj3l3MVWICJXdrZo+vNGEqUtg9S1VWCzHRBemiZY8V10HwPGMaIPSVzu7wbjE1JL60oqMI+XQKkOKg9TDWqacdZfunhoRbBHEBRIxNlLICYzuRBDqz5l36d4p5PGS4YnNU+rz4ATYv1RlIaXD4NJkhD987eT9alzRMvccWLoDCC4Q2j+2DkIAWA+q1NjVveN11XFNhSRdJVJVxw6YveyrGSWWQ1R1VYlqvIfA5SbqxSY4d5F1oWlyapTSHhDyVtsgHnIIlsBu58fnzuSErRZTRnpSHbN9R1ceSBVBHoQ7G3KY9F6CL2CT0dR2K5jroj2FkqC2bGNBpX6VmInKSqxPYWBThECZsgJGpBfIw2XFOrICF3uqKDUw4RPPkplCpN1APTqT867TAHPoNI2F2loV0NZgg+T79z9q4goKRJuA0Xh6+kjrvkeQHMNHIYxrgmL+vvfFaRMBCDBSd8e4nRlNgypep9UiiHnTHzB9Klx5OSCYEDHFa0XyNh+x2nhJDPG7/gyGZitQAdLicKsSL08MZ0424Be7Mf/w3fK0BAZOchUQPnfZKFUhDINQH5jjOVmdhggAHThJV35dP/+z9XUtzHSKfjHjvEzw+5cBCS5dkx7Wu5XTEadqP3bOUI/gvvMHFXqcSUaPtbE0cVbR3y5lTn4Kf3E0mIUKWWQ7U2kEHPHantKrsuynMhclnC2s3/lo1WmnQLQ0vGeVjkuPIs8P/srOoA8dsCAPlwv1qn5s2RahaJ3R0SixdkWePo3zldnHNz28KaBI3ClEIrrXghSOBsCdun+1a1XeVI4yjYYOjXrgNwlGNuKwoFM88cZNhqvCVrY5ahlezdnVcLdx3NQZfOzhyNlV5m5DEoqKhsAn7vXFylR3C+EzKyVEo7m31w2PLDA8ZX1RN+Wgh/vY49lGQu+6whQMjDFsO/z/CLBJIa8kTuZZsDSdAcL2Z27vFQHGyzflR1vxyRCQYX+fPNyNwf7US7NPKz+PAVmYgvbZmvG0iyVGPeSzPLBR0I/yAqzGLPbrbxNMvD4HtKwtzCfnsTkD6nZKe6YdUN2/1nSjWdjiJ6qUlrV6JNkf6AP0YneFwejYqLvPsBhMea0NMfsxv+A1zOP+EGe8hL5R X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61d2bf6f-1ed3-4e5c-7760-08d98fcc0cdc X-MS-Exchange-CrossTenant-AuthSource: SL2PR06MB3082.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 11:08:00.2970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xQn9ifR7itmGGZg5Q+6If6wVSn75fiSCZ0bjpmfRd6A/Ne81K57GGJBdH7Evg27nJY8fQ0RQu9CYY3R7F3udhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SL2PR06MB3212 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org show() should not use snprintf() when formatting the value to be returned to user space, snprintf() returns the length the resulting string and scnprintf() returns the number of bytes printed into the buffer. Fix the coccicheck warnings: WARNING: use scnprintf or sprintf. Use sysfs_emit() instead of scnprintf() makes more sense. Signed-off-by: Qing Wang --- drivers/hid/hid-sony.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index d1b107d..55423db 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c @@ -707,7 +707,7 @@ static ssize_t ds4_show_poll_interval(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct sony_sc *sc = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "%i\n", sc->ds4_bt_poll_interval); + return sysfs_emit(buf, "%i\n", sc->ds4_bt_poll_interval); } static ssize_t ds4_store_poll_interval(struct device *dev, @@ -744,7 +744,7 @@ static ssize_t sony_show_firmware_version(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct sony_sc *sc = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "0x%04x\n", sc->fw_version); + return sysfs_emit(buf, "0x%04x\n", sc->fw_version); } static DEVICE_ATTR(firmware_version, 0444, sony_show_firmware_version, NULL); @@ -756,7 +756,7 @@ static ssize_t sony_show_hardware_version(struct device *dev, struct hid_device *hdev = to_hid_device(dev); struct sony_sc *sc = hid_get_drvdata(hdev); - return snprintf(buf, PAGE_SIZE, "0x%04x\n", sc->hw_version); + return sysfs_emit(buf, "0x%04x\n", sc->hw_version); } static DEVICE_ATTR(hardware_version, 0444, sony_show_hardware_version, NULL);