Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3014947pxk; Sun, 4 Oct 2020 21:46:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRSVH0IDw0zyx6o2Rv2bQ4AdZDpLBqNvSrUTYrbik+vNq1O7pYEqVd855YcCyw6PeYBS5t X-Received: by 2002:a17:906:9156:: with SMTP id y22mr13776284ejw.184.1601873183569; Sun, 04 Oct 2020 21:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601873183; cv=none; d=google.com; s=arc-20160816; b=ZFxUQ6JsFUk89UD4IJRRqkonRYqQBYjNZ95DBZSUYKuU5lc0Av6VorRVkIMjIXzR3w tTtmUFk1bPLMYqDBGkui4ll/dbZUe04t8lNJcXtogjU9OvwAsHNMjg2M1SdkqvCNw8bl 39dKAou4rbO2qhPxdHrcH5kkAXf4euoCeykcfceNJ0FYZnJoh8zIpKlAo7BBpZW7lMj+ GiJLETSuCyL/JBCuKeCXCUtrjC7dsWV9IYPai9U1UspMxaIdRAkrvQpCApfpjJW/zd/B nXKBH2zZv+iv3nz/N9hcLKwkgSnYccpVeI3EhH0l7wq0dWaG6bB0/tDDW0QqEjXRiU/R CeMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=TrIA7YFOcNpa4uHdlUUc/yf24kQXAcWRwvqvatpCVhw=; b=ZwJUtiRxnRtBDftloO67ckuZ6On6SYm/Gb9lJgYfjbdoOyWcTPNzfact6Xzu5+Zls4 O+42m4Dx26FJ47JOsposuiYbx6F8PtkilHJDxUw42vLmGJadnrKuv+m4b0fWihAXv23Z zavYW2dLX1REItbZ2oK7HjaL40ZvDe0V9fj2oyiy+Z0zRV/gtTwTQ7z6xqkX5CbiFPWj FmKTJL+N/9hqM52/QcMZX13lrsOKQeulVQkUEnFc6NyGmNLuVVfMtiRaf0bYyG/qvbNN X/9KOsom+QJ/+30/OJqQevW6pvD2DRWcwP2/Y7LKQlVy1xoACp8qy4FDp7lUW/Zqsgmh lsjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail header.b=ZHp+PqkM; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id wp8si206993ejb.752.2020.10.04.21.46.00; Sun, 04 Oct 2020 21:46:23 -0700 (PDT) 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; dkim=pass header.i=@protonmail.com header.s=protonmail header.b=ZHp+PqkM; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725870AbgJEEoe (ORCPT + 99 others); Mon, 5 Oct 2020 00:44:34 -0400 Received: from mail-41104.protonmail.ch ([185.70.41.104]:44575 "EHLO mail-41104.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgJEEoe (ORCPT ); Mon, 5 Oct 2020 00:44:34 -0400 Received: from mail-03.mail-europe.com (mail-03.mail-europe.com [91.134.188.129]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by mail-41104.protonmail.ch (Postfix) with ESMTPS id A9E1D20035C7 for ; Mon, 5 Oct 2020 04:44:31 +0000 (UTC) Authentication-Results: mail-41104.protonmail.ch; dkim=pass (1024-bit key) header.d=protonmail.com header.i=@protonmail.com header.b="ZHp+PqkM" Date: Mon, 05 Oct 2020 04:44:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1601873068; bh=TrIA7YFOcNpa4uHdlUUc/yf24kQXAcWRwvqvatpCVhw=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=ZHp+PqkMlTA8/bdHRkhv2BUn3YKEGuJhGgsUIHYQK60+BTvqcONCPK/JN0A3kIoIo eVq5aMscY6OYzwWy3hAWM6XXOrqBzmCc4kauyvlVLul/KJWZhWcfPL44AzkNgUy0Tb v7ipsR5kmZ6xGD6/Rl2HXJvrE6FK87tLB0zUshpA= To: Joe Perches , Sebastian Reichel From: "Harley A.W. Lorenzo" Cc: "linux-pm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "wangxiongfeng2@huawei.com" Reply-To: "Harley A.W. Lorenzo" Subject: Re: [PATCH] test_power: add missing newlines when printing parameters by sysfs Message-ID: In-Reply-To: References: <1599199798-27804-1-git-send-email-wangxiongfeng2@huawei.com> <20201003212336.5et7erdf6fihqscu@earth.universe> <472008b94f4b20915425db4714fdb505cb0cbe5a.camel@perches.com> <20201003215029.jsugcgpgrmcmydr3@earth.universe> <9822843f764520e1076a92fd9120294aa393a085.camel@perches.com> <20201004221645.nyaf7jhur4jixo6n@earth.universe> <1g3ecQ7VLlrgKOSHr6teWgw9xcmVVQx1bFp2KpJD7y35lZpaC8ONb-jrPKapmFttEwVg2uhDwmv6mug9z5-GVZbqPbkOjcqjrSHtaW-k6ts=@protonmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.7 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, October 5, 2020 12:19 AM, Joe Perches wrote: > I did not suggest this. My apologies. Revised patch (still diffing from Xiongfeng Wang) here. [PATCH v2] test_power: revise parameter printing to use sprintf Signed-off-by: Harley A.W. Lorenzo Suggested-by: Joe Perches --- drivers/power/supply/test_power.c | 32 +++++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_= power.c index 4895ee5e63a9..5f510ddc946d 100644 --- a/drivers/power/supply/test_power.c +++ b/drivers/power/supply/test_power.c @@ -352,9 +352,8 @@ static int param_set_ac_online(const char *key, const s= truct kernel_param *kp) static int param_get_ac_online(char *buffer, const struct kernel_param *kp= ) { -=09strcpy(buffer, map_get_key(map_ac_online, ac_online, "unknown")); -=09strcat(buffer, "\n"); -=09return strlen(buffer); +=09return sprintf(buffer, "%s\n", +=09=09=09map_get_key(map_ac_online, ac_online, "unknown")); } static int param_set_usb_online(const char *key, const struct kernel_param= *kp) @@ -366,9 +365,8 @@ static int param_set_usb_online(const char *key, const = struct kernel_param *kp) static int param_get_usb_online(char *buffer, const struct kernel_param *k= p) { -=09strcpy(buffer, map_get_key(map_ac_online, usb_online, "unknown")); -=09strcat(buffer, "\n"); -=09return strlen(buffer); +=09return sprintf(buffer, "%s\n", +=09=09=09map_get_key(map_ac_online, usb_online, "unknown")); } static int param_set_battery_status(const char *key, @@ -381,9 +379,8 @@ static int param_set_battery_status(const char *key, static int param_get_battery_status(char *buffer, const struct kernel_para= m *kp) { -=09strcpy(buffer, map_get_key(map_status, battery_status, "unknown")); -=09strcat(buffer, "\n"); -=09return strlen(buffer); +=09return sprintf(buffer, "%s\n", +=09=09=09map_get_key(map_ac_online, battery_status, "unknown")); } static int param_set_battery_health(const char *key, @@ -396,9 +393,8 @@ static int param_set_battery_health(const char *key, static int param_get_battery_health(char *buffer, const struct kernel_para= m *kp) { -=09strcpy(buffer, map_get_key(map_health, battery_health, "unknown")); -=09strcat(buffer, "\n"); -=09return strlen(buffer); +=09return sprintf(buffer, "%s\n", +=09=09=09map_get_key(map_ac_online, battery_health, "unknown")); } static int param_set_battery_present(const char *key, @@ -412,9 +408,8 @@ static int param_set_battery_present(const char *key, static int param_get_battery_present(char *buffer, =09=09=09=09=09const struct kernel_param *kp) { -=09strcpy(buffer, map_get_key(map_present, battery_present, "unknown")); -=09strcat(buffer, "\n"); -=09return strlen(buffer); +=09return sprintf(buffer, "%s\n", +=09=09=09map_get_key(map_ac_online, battery_present, "unknown")); } static int param_set_battery_technology(const char *key, @@ -429,10 +424,9 @@ static int param_set_battery_technology(const char *ke= y, static int param_get_battery_technology(char *buffer, =09=09=09=09=09const struct kernel_param *kp) { -=09strcpy(buffer, -=09=09map_get_key(map_technology, battery_technology, "unknown")); -=09strcat(buffer, "\n"); -=09return strlen(buffer); +=09return sprintf(buffer, "%s\n", +=09=09=09map_get_key(map_ac_online, battery_technology, +=09=09=09=09=09"unknown")); } static int param_set_battery_capacity(const char *key, -- 2.28.0