Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp133237pxb; Tue, 2 Feb 2021 00:54:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRAnhv79BRIuIZRWfAmCwvW+inD0zMCzDNSgXHqf9Z+JafgMVxGuOStgYVbzMlUe6uRVZw X-Received: by 2002:a17:906:f85b:: with SMTP id ks27mr20921285ejb.20.1612256088960; Tue, 02 Feb 2021 00:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612256088; cv=none; d=google.com; s=arc-20160816; b=q4KSScnfY+5OVWAcLvyK6FoXnoThcDWeoUb8gDdlNt7qNWcS1sjUJEvL3Ct5q8p4To qHaON1VOyNKIYNvIFx9xA2assyg4SLzVIU5xSTxr4vxNg0C1rlCCMirv+CrBRWnusf96 6Cwd2CdWCMM7uXusoAamqB/knRrieiaMLQg92wEXnSqI7nlcGSaHV1weq/ALsk+V+bPl mNCSlcMi1/Ng98Pd28vtMH+ruVfU5DBqVt/XVWTwRsF7ZuKU0MN0DmM46vEMK8wUOakQ NJ4ZqmDF8bpKUFPsC/lpwBNrpc97p8lV7G/VyX+N7j0eAdjIgGu50kCo50X96Px30/72 BQKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=t9iExEcJvjsN6a0KocpjvvOF3o3uG4wDkqBL9vR9liE=; b=LPz1JB2ELhasP0RG7LP4VO4rsD0Ls8TFMlsVk8lHs9SuYBGcVxvRjTRbvgqOENzMKe Upu9JtQ3mdtf4PWLEm4dp4JRRxf0HEUNRd/I0mEzAPufTHMAIj/c3YnZbizEpiZIQbF5 pf04syacRboLtEd1ob1YvKZDbqn3Y9uUgse+47JuCwhpfCKrAzO14s+q3WYJPmHlWXtR 0hxiVHpj1cMAPA6+pZDCViXS1/R9Xl0X0WPG2ElonTAAi3Uk1aDjoh5VzBAkCx2Q/0A6 pPHb03yQildms7hQ2GIxMxOKuL8peugdWBU3fG6ysMeJ+puBOxSwR4OTBUd9JwZWpl9F ahVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si11839665ejr.533.2021.02.02.00.54.24; Tue, 02 Feb 2021 00:54:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232750AbhBBIul (ORCPT + 99 others); Tue, 2 Feb 2021 03:50:41 -0500 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:51579 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232744AbhBBIuR (ORCPT ); Tue, 2 Feb 2021 03:50:17 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0UNfEMIj_1612255745; Received: from j63c13417.sqa.eu95.tbsite.net(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0UNfEMIj_1612255745) by smtp.aliyun-inc.com(127.0.0.1); Tue, 02 Feb 2021 16:49:11 +0800 From: Jiapeng Chong To: linux@roeck-us.net Cc: jdelvare@suse.com, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Jiapeng Chong Subject: [PATCH v2] hwmon: (pmbus) convert sysfs sprintf/snprintf family to sysfs_emit Date: Tue, 2 Feb 2021 16:49:03 +0800 Message-Id: <1612255743-52579-1-git-send-email-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the following coccicheck warning: ./drivers/hwmon/pmbus/inspur-ipsps.c:73:8-16: WARNING: use scnprintf or sprintf. ./drivers/hwmon/pmbus/inspur-ipsps.c:114:9-17: WARNING: use scnprintf or sprintf. ./drivers/hwmon/pmbus/inspur-ipsps.c:94:8-16: WARNING: use scnprintf or sprintf. Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong --- Changes in v2: -Modified code space. drivers/hwmon/pmbus/inspur-ipsps.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/pmbus/inspur-ipsps.c b/drivers/hwmon/pmbus/inspur-ipsps.c index 88c5865..bf593fd 100644 --- a/drivers/hwmon/pmbus/inspur-ipsps.c +++ b/drivers/hwmon/pmbus/inspur-ipsps.c @@ -70,7 +70,7 @@ static ssize_t ipsps_string_show(struct device *dev, p = memscan(data, '#', rc); *p = '\0'; - return snprintf(buf, PAGE_SIZE, "%s\n", data); + return sysfs_emit(buf, "%s\n", data); } static ssize_t ipsps_fw_version_show(struct device *dev, @@ -91,9 +91,9 @@ static ssize_t ipsps_fw_version_show(struct device *dev, if (rc != 6) return -EPROTO; - return snprintf(buf, PAGE_SIZE, "%u.%02u%u-%u.%02u\n", - data[1], data[2]/* < 100 */, data[3]/*< 10*/, - data[4], data[5]/* < 100 */); + return sysfs_emit(buf, "%u.%02u%u-%u.%02u\n", + data[1], data[2]/* < 100 */, data[3]/*< 10*/, + data[4], data[5]/* < 100 */); } static ssize_t ipsps_mode_show(struct device *dev, @@ -111,19 +111,19 @@ static ssize_t ipsps_mode_show(struct device *dev, switch (rc) { case MODE_ACTIVE: - return snprintf(buf, PAGE_SIZE, "[%s] %s %s\n", - MODE_ACTIVE_STRING, - MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING); + return sysfs_emit(buf, "[%s] %s %s\n", + MODE_ACTIVE_STRING, + MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING); case MODE_STANDBY: - return snprintf(buf, PAGE_SIZE, "%s [%s] %s\n", - MODE_ACTIVE_STRING, - MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING); + return sysfs_emit(buf, "%s [%s] %s\n", + MODE_ACTIVE_STRING, + MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING); case MODE_REDUNDANCY: - return snprintf(buf, PAGE_SIZE, "%s %s [%s]\n", - MODE_ACTIVE_STRING, - MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING); + return sysfs_emit(buf, "%s %s [%s]\n", + MODE_ACTIVE_STRING, + MODE_STANDBY_STRING, MODE_REDUNDANCY_STRING); default: - return snprintf(buf, PAGE_SIZE, "unspecified\n"); + return sysfs_emit(buf, "unspecified\n"); } } -- 1.8.3.1