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: 12561053 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4ED2C433F5 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 AD6BA611C2 for ; Fri, 15 Oct 2021 11:08:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238334AbhJOLKI (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-input@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,