Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp351871ybh; Mon, 20 Jul 2020 19:01:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsTtuVCTj0+PS4w5ImcqGbMenoVLV85iyt/p29p8UPdM8L5KNqeA3fjbhApxtLf9VsmtEr X-Received: by 2002:a17:906:dbed:: with SMTP id yd13mr22690202ejb.419.1595296863287; Mon, 20 Jul 2020 19:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595296863; cv=none; d=google.com; s=arc-20160816; b=IPsHwQn7i9ro6Mz7EkKv8uOAvsA9rFHZrbEGJiV6keawbu1lv6I//Vyk54dzIBilir uiA6cu1k5iuBo3UcVvsCSS9DUkdQ//q125eTl+LUrxFhRmnAOMfZQHU08k9+PqWl8nKo g2VRVRoU1f3v8YFPRFIIn5MsOTUw0J+nMzQsoWJ2JAKzvLXiWTYTg785Ah+aAwCQQyYO 8o6QNOfqrKxGK0x+PVKPtfORgbCrjzNlDcOK/3Pmx4iFP35s0FDJ6beVZBFc6liFpktT TtFFW/PT8Jyoj7ATSoqWQf1X1U6SYeDkfI0DvF+wy+cWgv+FjkDAIEq0We3a3m01pHk6 xjmA== 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:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=7x+Iqwwft/FdZB32WEzkbRJCLmyIOk++60X+k8h/fvk=; b=lyQKOqURfpJe0R2twuXK6orN3oTKtsVV4dertheczQ4yYYe55yCznQrHG+TKmUpwQH tRJ5OEI/k8mWKsCUhlul4OhnttZT17h7xsjUuMnrdIV8WrxTDZhrrGsIdFYEawjtHJgH yxUWWEnbtJm5bPB2kNBXRgn8+U8yqHCDkZXJwla8Gys0wjKeYwicARHoLRfTs5ABWVCn EHvajP6i0YqSiMPKxhYCd5wCIKD7426rIiqft/R9TFaDJ7FxIr4OFbRcBhzZbV4+Z6UY GA09yunllNg5oBq1CGjRH//xZgEYpCk15up86WfNXN7bE50tL4ftL3hBRNXruqY+7SFc R5Sg== 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 p14si11822320edq.301.2020.07.20.19.00.39; Mon, 20 Jul 2020 19:01:03 -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 S1728166AbgGUCAY (ORCPT + 99 others); Mon, 20 Jul 2020 22:00:24 -0400 Received: from smtprelay0252.hostedemail.com ([216.40.44.252]:38822 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726177AbgGUCAY (ORCPT ); Mon, 20 Jul 2020 22:00:24 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay05.hostedemail.com (Postfix) with ESMTP id 3BA2118020C26; Tue, 21 Jul 2020 02:00:23 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3870:3871:3872:3873:4321:4605:5007:7901:7903:9038:10004:10400:11026:11232:11658:11914:12043:12296:12297:12740:12760:12895:13069:13161:13229:13255:13311:13357:13439:14659:14721:21080:21627:21990:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: sheep38_3d1250f26f29 X-Filterd-Recvd-Size: 2277 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf14.hostedemail.com (Postfix) with ESMTPA; Tue, 21 Jul 2020 02:00:21 +0000 (UTC) Message-ID: Subject: Re: [PATCH] ipmi/watchdog: add missing newlines when printing parameters by sysfs From: Joe Perches To: Xiongfeng Wang , minyard@acm.org Cc: arnd@arndb.de, gregkh@linuxfoundation.org, openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, guohanjun@huawei.com Date: Mon, 20 Jul 2020 19:00:20 -0700 In-Reply-To: <908fcbf2-efbb-b3f4-0666-2da79fbe99c4@huawei.com> References: <1595210605-27888-1-git-send-email-wangxiongfeng2@huawei.com> <20200720195234.GC2952@minyard.net> <908fcbf2-efbb-b3f4-0666-2da79fbe99c4@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.3-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-07-21 at 09:20 +0800, Xiongfeng Wang wrote: > 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. [] > > > diff --git 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. You never quite know for sure so I suggest making the string null terminated just in case. i.e.: buffer[len++] = '\n'; buffer[len] = 0;