Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp114465lqn; Thu, 11 Apr 2024 16:09:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPqua1RPojtAaYwOH69MzzlMNFyzr3DWsayeU4pLhLqa+W2P1M9SlspKqgjlrkExFYBVzjf+qnBbaCfUd6dFaynhDhnVrBbsxK4C7UoA== X-Google-Smtp-Source: AGHT+IEDyXw4/lmp1gbPzfgei2pyoJwjDo81ZL6nKEXTcpToXlPlWLylVgkGnquAEbMv48Zu6pBf X-Received: by 2002:a05:6a20:3251:b0:1a7:5614:a8a0 with SMTP id hm17-20020a056a20325100b001a75614a8a0mr1203425pzc.44.1712876941955; Thu, 11 Apr 2024 16:09:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712876941; cv=pass; d=google.com; s=arc-20160816; b=p46Oy+gmHKvvp0S2B2Vn0ZW4ob+aaBk/kaAia/EHpuc4lRDOjxeL6Ex9ckk1r1Oyx2 ZVqlQj6Dkay+e6BWUZYAUKLsw3sxRU9iRDn68TD77B5vq4KuPC9mbAUupQEaCldho0/J p5WzdGJldgD2+wLeOEVmaTF8IJ64DAcWj43QnhN4JwbBdalFCSUvk7n/8T+XzS9xLSYc acgu+5fTr9NE378Xw9jB6nv0jltzTQaqJWhZLEG8sGdy+Arkrlz/obi2x5Uzg6dEnyDb 2EwMkbV2tFycn8LSOKk+ZwRjZsz59h6aoiUoAmLOH/kpwcHkoNBjShcoWsurgFjMBcMy nHOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=hnt1PtRZfSD7S6LfYeDQRJLnJ5MRQBwYquIg0WtGvek=; fh=LcA7QbbK2c2lk6ll+IhElNewdY8ZLFZztb4g7jkaV94=; b=HrtTAmfpzXZ1nmAhMITaujQvmV313FZqicuc+Q87i+EV+9i/32Eq1rNsU5XuAlgsUk I/IZ9WtvmqA/tfltBv6Hzs7NA3gAShqqSna35020da6VVt7Y+TpaWgB0tZsULN/2OYsf mlEIVJqETDiSE9jQViBw+9fq0Y2e38xcL0GgQAKiimhEra2cXdpnm2+JlkxGVpaR7U9B gQbsoSIIK/fCUpaBPf7FABq5kDvyEf511/6tLPu91clqot7+r7uSBMpPllUBMAuaztE0 LhFDPL/JRdffXJcYucykMkUm5OH8yiS8eBAJqC+a/AOk6buXfSYf0HXb1f9lFdk/zA/y CMSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cmDNdbLn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-141699-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141699-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h1-20020a656381000000b005dccf9c665csi1989996pgv.664.2024.04.11.16.09.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 16:09:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141699-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cmDNdbLn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-141699-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141699-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9EFC32881FE for ; Thu, 11 Apr 2024 23:09:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B6423D39B; Thu, 11 Apr 2024 23:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cmDNdbLn" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38F4847768; Thu, 11 Apr 2024 23:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712876925; cv=none; b=hG6hjEzIAf2YedLd8WT+YdXYjgVILWa/7OrwJaGB4W/g8zNeecSIuraYQve69NXZt0ruzm6tf3R1XuZyI4/QAfCRQFhmniLZoXJMfgEkkdu5WHjBL3zz9jdQ3eMKpXLR84XDft320rK1LER9LBpwcgzw05azCnh6XOMIp8QbMw4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712876925; c=relaxed/simple; bh=9Be3q6JYHjv6MccnxSgMKyVuxFPrHvQDF/b6XL6yv+4=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=gqAOLdvoTmdfkPATTQJhTY7E/g2ElDYgYp32tf/Pdy36N6eh6V11yxzAhPCcfWcnB/obxuggAllklGEycKgYf6eMdBv1guKIgNFpr7q3cPSHiY+zjUawY2cRByBS3drd7v64AEIkoHgVyEvolgEaNPCiQzPY11JSptJgyaXzqWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cmDNdbLn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B53F9C072AA; Thu, 11 Apr 2024 23:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712876924; bh=9Be3q6JYHjv6MccnxSgMKyVuxFPrHvQDF/b6XL6yv+4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cmDNdbLnPV87ajGBPNUro9DeMRZXbKxg7Wz+kQadT70xWwn7eOKrD8ctGTrBs2tEd BpZHZNTK1BVLwfiOzjvQz88Piqpv3Gr7D3rkcdr8lSVFs6RM5pBzKNLJjiB8ZlDEkq fv8AF8uDhMqQ/n17o6Ktst2/vjHLZWmThH4cpARc3bGP5xJQeCoaTzHq1BCcA/0nEP 2K8h+QD885Ys0FyDjZxRgldz5hnmdtpl/2LThnQplOaATtf0SeJu/6pTnE3AHXIR86 qjF9hR6VSIORHVizuWpGcQNXCEaAhCRT1SRFhQ743rw3iBU6Fmjt+J1N26GM+Eob8Y t14TcyC8lnEug== Date: Fri, 12 Apr 2024 08:08:39 +0900 From: Masami Hiramatsu (Google) To: Yuntao Wang Cc: akpm@linux-foundation.org, arnd@arndb.de, changbin.du@huawei.com, christophe.leroy@csgroup.eu, geert@linux-m68k.org, jpoimboe@kernel.org, kjlx@templeofstupid.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, ndesaulniers@google.com, peterz@infradead.org, tglx@linutronix.de, tj@kernel.org Subject: Re: [PATCH] init/main.c: Remove redundant space from saved_command_line Message-Id: <20240412080839.c903a0058bd6594d31bc1d3e@kernel.org> In-Reply-To: <20240411152941.256666-1-ytcoode@gmail.com> References: <20240411230745.dba6cfa97ec068d909550fd5@kernel.org> <20240411152941.256666-1-ytcoode@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=UTF-8 Content-Transfer-Encoding: 8bit On Thu, 11 Apr 2024 23:29:40 +0800 Yuntao Wang wrote: > On Thu, 11 Apr 2024 23:07:45 +0900, Masami Hiramatsu (Google) wrote: > > > On Thu, 11 Apr 2024 09:19:32 +0200 > > Geert Uytterhoeven wrote: > > > > > CC Hiramatsu-san (now for real :-) > > > > Thanks! > > > > > > > > On Thu, Apr 11, 2024 at 6:13 AM Yuntao Wang wrote: > > > > extra_init_args ends with a space, so when concatenating extra_init_args > > > > to saved_command_line, be sure to remove the extra space. > > > > Hi Yuntao, > > > > Hmm, if you want to trim the end space, you should trim extra_init_args > > itself instead of this adjustment. Also, can you share the example? > > > > Thank you, > > At first, I also intended to fix this issue as you suggested. However, > because both extra_command_line and extra_init_args end with a space, > making such a change would require modifications in many places. You may just need: if (extra_init_args) strim(extra_init_args); > That's why I chose this approach instead. > > Here are some examples before and after modification: > > Before: [ 0.829179] Kernel command line: 'console=ttyS0 debug -- bootconfig_arg1 ' > After: [ 0.032648] Kernel command line: 'console=ttyS0 debug -- bootconfig_arg1' > > Before: [ 0.757217] Kernel command line: 'console=ttyS0 debug -- bootconfig_arg1 arg1' > After: [ 0.068184] Kernel command line: 'console=ttyS0 debug -- bootconfig_arg1 arg1' > > In order to make it easier to observe spaces, I added quotes when outputting saved_command_line. BTW, is this tailing space harm anything? I don't like a cosmetic change. Thank you, > > Note that the first 'before' ends with a space, and there are two spaces between > 'bootconfig_arg1' and 'arg1' in the second 'before'. > > > > > > > > > Signed-off-by: Yuntao Wang > > > > --- > > > > init/main.c | 4 +++- > > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/init/main.c b/init/main.c > > > > index 2ca52474d0c3..cf2c22aa0e8c 100644 > > > > --- a/init/main.c > > > > +++ b/init/main.c > > > > @@ -660,12 +660,14 @@ static void __init setup_command_line(char *command_line) > > > > strcpy(saved_command_line + len, extra_init_args); > > > > len += ilen - 4; /* strlen(extra_init_args) */ > > > > strcpy(saved_command_line + len, > > > > - boot_command_line + initargs_offs - 1); > > > > + boot_command_line + initargs_offs); > > > > } else { > > > > len = strlen(saved_command_line); > > > > strcpy(saved_command_line + len, " -- "); > > > > len += 4; > > > > strcpy(saved_command_line + len, extra_init_args); > > > > + len += ilen - 4; /* strlen(extra_init_args) */ > > > > + saved_command_line[len-1] = '\0'; /* remove trailing space */ > > > > } > > > > } > > > > > > Gr{oetje,eeting}s, > > > > > > Geert > > > > > > -- > > > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68korg > > > > > > In personal conversations with technical people, I call myself a hacker. But > > > when I'm talking to journalists I just say "programmer" or something like that. > > > -- Linus Torvalds > > > > > > > > > -- > > Masami Hiramatsu (Google) -- Masami Hiramatsu (Google)