Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp334404ybh; Mon, 20 Jul 2020 18:23:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwunuDr+e5DG4XRYIlYNwNS+0+/2Yp846H1PLEEJwMHvcOpFtLJDB9FchCAcDW1zBTGiNSe X-Received: by 2002:a05:6402:354:: with SMTP id r20mr25054029edw.32.1595294610743; Mon, 20 Jul 2020 18:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595294610; cv=none; d=google.com; s=arc-20160816; b=bm9uuNOoFly0jf8iNVJ1NL37kxB3+jsBQOc06Gs6psK0DbRlKWPbK8DM5WhtPbzfkA 5c+XIX1nSsQ622YxURy0Unpm5063OzcriD3Mq+lkxjmMdFnaN69XN4ATF0C3HgtVi8yS SsEbxVi9i+b/rpv+5+ZPiAVFYJsmYV3s2apf+0+p5Bmjw6QynwC7hiqeAGi7hn+MwtSy TezLp6BctHbiu/tyQwa2oO6ffBG/roLuc2bFblqhhq7mCE36KrtmZ7R3QDVVjOqzXqK3 XHh77A+62MYZzLp1k/vBAFxBH20Sp97pm7Na77yYgrwvKXjayK0hFbsjFA2+bpedPXOy 870w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=CvMtbAjoXZgcnSs5DoTPTjWd7j236BpIH6VjnAoGZ7E=; b=YIFOQJgvU5heMVF6n79U4GNuoiYiLzIKwJAQD0aqvN/Y0mS2mo96xG/DSw97bQkxOY 01kLABXdW+EznTjCfz7Wov3QgmGP3i3Yk0HxHN0G3/gCkpBTPGbS7UODS/8OSn1VVlQp aNTndc+ayhxp7aE0Mts3yP+jMtGYBMzKxXTTOYNI6ohDkBQiT1fLkEREfPCS6p5w9mJ8 w23FASg/7i8Ixx8NoYJy2JsChPeRFGcJ87kzjM9tK9UbXziQI3GGRaZeQTWziyLNLP3P YO4gKwUcFu9VbalHWZbtWPRBkjs5+cTZP1/TGr7LJL24BtR16X1Jo2ISZFkvTFkzlNir 5xyA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt3si11376672ejc.325.2020.07.20.18.23.06; Mon, 20 Jul 2020 18:23:30 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbgGUBUc (ORCPT + 99 others); Mon, 20 Jul 2020 21:20:32 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7799 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726016AbgGUBUb (ORCPT ); Mon, 20 Jul 2020 21:20:31 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CDA83C04CAAF79530EFA; Tue, 21 Jul 2020 09:20:27 +0800 (CST) Received: from [127.0.0.1] (10.174.178.16) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Tue, 21 Jul 2020 09:20:17 +0800 Subject: Re: [PATCH] ipmi/watchdog: add missing newlines when printing parameters by sysfs To: CC: , , , , References: <1595210605-27888-1-git-send-email-wangxiongfeng2@huawei.com> <20200720195234.GC2952@minyard.net> From: Xiongfeng Wang Message-ID: <908fcbf2-efbb-b3f4-0666-2da79fbe99c4@huawei.com> Date: Tue, 21 Jul 2020 09:20:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200720195234.GC2952@minyard.net> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.16] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Corey, Thanks for your reply ! On 2020/7/21 3:52, Corey Minyard wrote: > On Mon, Jul 20, 2020 at 10:03:25AM +0800, Xiongfeng Wang wrote: >> When I cat some ipmi_watchdog parameters by sysfs, it displays as >> follows. It's better to add a newline for easy reading. >> >> root@(none):/# cat /sys/module/ipmi_watchdog/parameters/action >> resetroot@(none):/# cat /sys/module/ipmi_watchdog/parameters/preaction >> pre_noneroot@(none):/# cat /sys/module/ipmi_watchdog/parameters/preop >> preop_noneroot@(none):/# > > Yeah, that's not consistent with other things displayed in the kernel. > >> >> Signed-off-by: Xiongfeng Wang >> --- >> drivers/char/ipmi/ipmi_watchdog.c | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c >> index 55986e1..3e05a1d 100644 >> --- a/drivers/char/ipmi/ipmi_watchdog.c >> +++ b/drivers/char/ipmi/ipmi_watchdog.c >> @@ -232,12 +232,16 @@ static int set_param_str(const char *val, const struct kernel_param *kp) >> static int get_param_str(char *buffer, const struct kernel_param *kp) >> { >> action_fn fn = (action_fn) kp->arg; >> - int rv; >> + int rv, len; >> >> rv = fn(NULL, buffer); >> if (rv) >> return rv; >> - return strlen(buffer); >> + >> + len = strlen(buffer); >> + len += sprintf(buffer + len, "\n"); > > sprintf is kind of overkill to stick a \n on the end of a line. How > about: > > buffer[len++] = '\n'; > > Since you are returning the length, you shouldn't need to nil terminate > the string. Thanks for your advice. I will change it in the next version. > > An unrelated question: Are you using any of the special functions of the > IPMI watchdog, like the pretimeout? I am not using any special functions of the IPMI watchdog. It's just that I cat the parameters below 'ipmi_watchdog' and find we can add a newline here. Thanks, Xiongfeng > > -corey > >> + >> + return len; >> } >> >> >> -- >> 1.7.12.4 >> > > . >