Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp887505rdb; Tue, 30 Jan 2024 01:18:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTkdjLCgd5BCGULZpG6Fqb6Db8JYLEdveRdi+cnytbkk24PNNwa6vXMA8AGzOA0UB4EVAK X-Received: by 2002:ac8:7e8f:0:b0:42a:b24e:f735 with SMTP id w15-20020ac87e8f000000b0042ab24ef735mr1663846qtj.0.1706606283992; Tue, 30 Jan 2024 01:18:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706606283; cv=pass; d=google.com; s=arc-20160816; b=dXX174hQZ8T2ityLeJubq2nthS/3c9D6TpENPIBIFzPdw+8Tvm5ZOpMOWoSCSnF8Ox IulRNZZzJz+lixFzYhptVkF2ouJATQnQCYt9s+5ephx6vwq6fpS8R4DKRHzJLvgnAD96 PZdEuTDEofaL2Is6aDZTIN5zMDwmrZNoqX+J0oLEPt6EFotFZdHAnK8o3CAf+Nmh0fzH L5nPsSVC8YlX4o0qH27r4aBV4xYW+UCZVccnNyzW3jf9fY+6AGk/Y3uSP6jZPo8pdiGX ta0FHm7dV4fVJeHKK8L1IzqtDjMyElpn3wxptrow8K9reiEOqnEfILahuXRRvclb42Ok nieA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=OkAPGBSFsncR9iMdVmIGrDJoGNEAVTETra2CiW5bl7o=; fh=BNPxr7WUHmOJJ9gJRxjwgksqhnrQNB0JjnfZM/5gJDY=; b=MtC4RyLeJQMXmQBLXUSUFkqePNyQ4hD2900o01BNulgsxp0hVNldH09hXqaVyTsxq9 PQorHNWBp+vmeZvx589cZKFBK+uXOdbcfVzBFHH4JeHjne5i0d1nnny1UqQYzNg1P1oS 76W5CdfKgdIfUS3pIZiCFSan0mr6zCvt8yZ1L6f8KJF63KcuZVogbdVrXyWEpOKR1yUk yyF2bg0zqMkjzDS5DuVbi0U+H9XuOAGxr8vDthobtDubNvD9inIVNlxu4SQ8cMfiN08t 1ovmLuQXLLeGtt6+Zb1uZvty/ayItUbNXLvBegGPkZ/gShTH6kXt1MtTdqp1s68XI1mJ XQhQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-44231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44231-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w6-20020a05622a190600b0042a67eca0f8si9689452qtc.169.2024.01.30.01.18.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:18:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-44231-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44231-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 759701C2441A for ; Tue, 30 Jan 2024 09:18:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69F2460BA8; Tue, 30 Jan 2024 09:16:30 +0000 (UTC) Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3696F57864; Tue, 30 Jan 2024 09:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706606189; cv=none; b=NUyb0jguZRq82b2Fge04q+zBYNqEVlO1bb2T6qzYEpi9aItWniCmfdJk+xMUp8JPcKzixw8GNNxl99CsDzEcJC79H0q4lm62h+w34xblc0hVB7NTujXIRUmFj7rS9h0cnp7Bexqrso2HahwLUxHGhpDMagc/6X+SSk927LcAzt8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706606189; c=relaxed/simple; bh=rOTYB4EklsfZYfMHWnc0rtCZ9py8ZixyPnAzjcJFpVg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DfjCWWfx9iya2e0Vw7IDumybVcY/fPf64eLEX3z7kp2SRBkkmy62qvrcpDVM2auWite6XgZD5TKQTH1cFycFDVf23jF14I5WGZr1ee33qW94ipmzXtJ3cyTzE5rgUwrTTdbPd1OeyZBHABzOH6Rs8jFavCZNo8+TtoCs/Ilewto= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a315f43ecc3so362337566b.0; Tue, 30 Jan 2024 01:16:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706606186; x=1707210986; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OkAPGBSFsncR9iMdVmIGrDJoGNEAVTETra2CiW5bl7o=; b=OxQTHH/+HGkuH2XpxkJNzw2S0Dz6s/Avnn+yyWZYhqer9tisBimDRASwcfiR6CWEMg 9rKDJ6MCq32CXMwnrnsSaUkgsDH/qths/aH2JWClhH1cNiafPxUxDq8HgTRU8AqdigEt QrFLgYpUq0KK2KjzSWl7zZQ+pKGchBe/9GjNP3briI0DE2Fjywtx2lljXEa2ZA/P73vp fWCElaq5J5Jc0+/HTUD+9PGykkyZQnV5ahjFxH5mMDGtn4spZ125sGbm1xqUULjcTgRL VS10NQ/1zulNEC8POgBvq11mQMUnJs97bpTHeaqPRM37v1sO4G92dq64H4CSj+gN8NpV DMDg== X-Gm-Message-State: AOJu0Yxo3upOz/4WUlizsJYoY6mbyiuaB2cN7u1Oezi+7wyd9nhdof+Y goVU9ps2D8C/19e+BKFhWKL+yAHj5PQhTN+HA5nrY1sQeU/tl84dDNYbm2lUhdHOzQ== X-Received: by 2002:a17:906:6716:b0:a2e:998b:775 with SMTP id a22-20020a170906671600b00a2e998b0775mr5914963ejp.5.1706606185996; Tue, 30 Jan 2024 01:16:25 -0800 (PST) Received: from gmail.com (fwdproxy-cln-118.fbsv.net. [2a03:2880:31ff:76::face:b00c]) by smtp.gmail.com with ESMTPSA id lr10-20020a170906fb8a00b00a3177f658afsm4888148ejb.206.2024.01.30.01.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:16:25 -0800 (PST) Date: Tue, 30 Jan 2024 01:16:23 -0800 From: Breno Leitao To: Matthew Wood Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2 3/8] net: netconsole: move newline trimming to function Message-ID: References: <20240126231348.281600-1-thepacketgeek@gmail.com> <20240126231348.281600-4-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240126231348.281600-4-thepacketgeek@gmail.com> On Fri, Jan 26, 2024 at 03:13:38PM -0800, Matthew Wood wrote: > Move newline trimming logic from `dev_name_store()` to a new function > (trim_newline()) for shared use in netconsole.c > > Signed-off-by: Matthew Wood > --- > drivers/net/netconsole.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c > index 085350beca87..b280d06bf152 100644 > --- a/drivers/net/netconsole.c > +++ b/drivers/net/netconsole.c > @@ -230,6 +230,16 @@ static struct netconsole_target *to_target(struct config_item *item) > struct netconsole_target, group); > } > > +/* Get rid of possible trailing newline, returning the new length */ > +static void trim_newline(char *s, size_t maxlen) > +{ > + size_t len; > + > + len = strnlen(s, maxlen); > + if (s[len - 1] == '\n') > + s[len - 1] = '\0'; > +} I am thinking about this one. Should we replace the first `\n` in the file by `\0` no matter where it is? This will probably make it easier to implement the netconsd, where we know it will be impossible to have `\n` in the userdata. Maybe something as: static inline void trim_newline(char *str) { char *pos = strchr(str, '\n'); if (pos) *pos = '\0'; } All in all, this is a good clean up, which make the code easier to read. Thanks!