Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp154581ybh; Mon, 20 Jul 2020 12:53:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrntdY9FuL+i2M30L0EWaS6e8Q3kQJUdWi/XOI70MSodJ1wPj5x79vePsm7A77DJwtPVIH X-Received: by 2002:aa7:da58:: with SMTP id w24mr23371409eds.385.1595274803706; Mon, 20 Jul 2020 12:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595274803; cv=none; d=google.com; s=arc-20160816; b=fGIWjtBJnaFjTRw//1q3yTSiQ1KV+PkvOp/H5SndslckvZ8SN1JpCgamDg5USSCmwm rYoMCV2J7xXsJL1CgD8DxD1vE+0h5V/a4ue+Cxs+vIHCs1qmCqlb0qYjosgwsjio8vny kvSLng4ypjE6lrJFGTQ46zakcfaqmp5pnml2KE06KrDIfOGNEGVppSlArUqpmCaFGJMH 4t4PG567/EzSCHJaJhcSi7A3WMXXeYp3jd5hoPKslqU+DUrEQFpFYAb/Edvk6V7FFndJ xSRrHuSGr4jQnIXdhLk6OkA0nHEtImCBcFLRgivByNh9ZACDPBpWyrCZBwKqGlxlE0hn 5bQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=atKBBWcnU++49tmxsg8oq4hs4l/FvwBwr9+f5kHrPQE=; b=KjUwh7w+3AJBqlVq5VuD86TcKSqKNSkncWrj/imDgvsTaPhtuqU9ER2Bz91qbWiRPe HOzhvsmsqGN+ESpZ+Rw6dTPUwG5VBnJQKYa/ZnAUQXQqcgbtQHORIvxJXmbzrlP9N92B rk7WX5Y7CgUkiAwYh1Zzl6HlZAqjMVZDHJGncNli2BRgxgjYJXGdiXHOIFsmXJE4CYo8 xwQ37BHUDNwYWPWhpQC/4r7yn7nT4fjMU39n7HnXPVWKGzmSq5aEjI55cRdxhqf3j1Fo 21UM9h23peFg7xA6R2pbt6ZFldVlVZKoEWE+IK9BJNAE8Kruf13BcCB0KerXu9NKPK2+ zb+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=ZJgoG2v9; 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 q22si10630258ejx.87.2020.07.20.12.53.00; Mon, 20 Jul 2020 12:53: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=fail header.i=@gmail.com header.s=20161025 header.b=ZJgoG2v9; 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 S1729333AbgGTTwk (ORCPT + 99 others); Mon, 20 Jul 2020 15:52:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbgGTTwk (ORCPT ); Mon, 20 Jul 2020 15:52:40 -0400 Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F334C061794 for ; Mon, 20 Jul 2020 12:52:40 -0700 (PDT) Received: by mail-oi1-x242.google.com with SMTP id k6so15286221oij.11 for ; Mon, 20 Jul 2020 12:52:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:reply-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=atKBBWcnU++49tmxsg8oq4hs4l/FvwBwr9+f5kHrPQE=; b=ZJgoG2v9a3cZM4UqmYfn++N0kaA7KzoYlCD9aks8VYOBn6rR2+oadW4WeaetOwqXtK 9wtVNkYUeRNpdgZdpD+4e+Mag6dOG1iYFX6G23w8cUWbC4x9lIkJXTKEcABwlW9RoBta cveGXS4ay5iUd+m/7R2K4Ua8LV51xZIjRokaakCsIUNSsba1YZzoXl5gD1PMqOvCC1Dc r3vPcnm9E+/TXxURYhySdwQtwm4D6sJxEsJgc8i8nDHRhKYeLQbSk/rBHS2MNcl3pujD hPHIV/HsqNZTwXWDJYKxAx8bnhhzRuLkzkCDoyVOKtqrIdVIuO7wAzcKwn0/dCVo5Pc8 Bg2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :reply-to:references:mime-version:content-disposition:in-reply-to :user-agent; bh=atKBBWcnU++49tmxsg8oq4hs4l/FvwBwr9+f5kHrPQE=; b=XGZcun6a1ZxWXIgbRlCwYZ+3cgqmq1Iuzuzr+cEeyKcapbdAzjq2d0vBmpPop3GapQ rsgyGmkRcgD2oTPRTmItOVjAcNDcF72fkYSFbTRU5qJzm50hB0xRzgABoIp/6YXCrvkI 0QBcCwpAx0jIvOOKulXCaH89+9JNbu8LGwff82l5za90f/NgUybuK3NRFtn9h9vAiv04 KaFz9pasf9kIfYaZOgmnZRp40e6iDac7aUSufNvRsc0kYIKB2hlree9KoJ8/9+50j81u AN+WPMdjRgZrokYVdH9OzKhU2G1w3HM56LnMEbNAFEKzJsMBFABihFZNqOyrUaQS3Y1c kG/Q== X-Gm-Message-State: AOAM531zRaQxj3BxNB+a3sA2511h/yZGhPKpmQUie+puhXrlIzFNx1uW l2UdgyGqDfulgVW5fVxloQ== X-Received: by 2002:aca:57c5:: with SMTP id l188mr725424oib.154.1595274759308; Mon, 20 Jul 2020 12:52:39 -0700 (PDT) Received: from serve.minyard.net ([47.184.146.204]) by smtp.gmail.com with ESMTPSA id s4sm4573610oom.15.2020.07.20.12.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 12:52:38 -0700 (PDT) Received: from minyard.net (unknown [IPv6:2001:470:b8f6:1b:70d6:b947:41f4:6e7e]) by serve.minyard.net (Postfix) with ESMTPSA id 1B9E5180050; Mon, 20 Jul 2020 19:52:36 +0000 (UTC) Date: Mon, 20 Jul 2020 14:52:34 -0500 From: Corey Minyard To: Xiongfeng Wang Cc: arnd@arndb.de, gregkh@linuxfoundation.org, openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, guohanjun@huawei.com Subject: Re: [PATCH] ipmi/watchdog: add missing newlines when printing parameters by sysfs Message-ID: <20200720195234.GC2952@minyard.net> Reply-To: minyard@acm.org References: <1595210605-27888-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1595210605-27888-1-git-send-email-wangxiongfeng2@huawei.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. An unrelated question: Are you using any of the special functions of the IPMI watchdog, like the pretimeout? -corey > + > + return len; > } > > > -- > 1.7.12.4 >