Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp150465pxb; Tue, 15 Feb 2022 10:12:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKgRwREaif5nrofd104TxMF2vOWjFYqEOkF+Irg001RhGu+FUPlarpawCmtGRcCc5xNzGr X-Received: by 2002:a17:90b:1e08:: with SMTP id pg8mr86073pjb.52.1644948719838; Tue, 15 Feb 2022 10:11:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644948719; cv=none; d=google.com; s=arc-20160816; b=Wmo/GeQtAk5Uj1uMA1Q0gd5P5AndhnKslrT5cj0X+BNri41DvLJdKSznUmv77NwkY7 GJ3+YKd60EuBuULUgKXqbygnGoKyHaoYwLJMvHY5vppt1cC4WBbR/Q/d8AoM8KR8NieY TNoapgD7UbU3Ca9SsWLCl2k9VejJm8IBwANYW29gkYwiKNgc2c5yQV3EU6DPyVrKk6Kw NX00p6uZq5AVk/fUfBbEgbiQZ4ddoI47Sihtn5FPyqFU5Fvxn/uPKs6avBDroi3+p3UY BSclJPpk5GEnC0q9eELbM0kBHms4tZAiv3nLUSmElZFXG761yo2RAjOdizUYiUMYK7mA DnYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PWnIgritZWDbPqJt4NsgSR71vtgK2UWzhthhnP5o4N8=; b=PBICrYWLw3hbyuzdhr0ngPyfBrSr9mJ4Ske6UD1auvTNU7Yu+TRpl35sDa5go/C3Bm v72lzNJAze5LTq+pxS4GRNs40I4TiiAbOZtpIwjnV/gbPl//Ougwq6ecMFGtH7h7fgDf AtxysjJ4jfaN0luUwCNmHF4wFrKEP0tJUmVdpmei1o45o8TaXbFLGvsvQkZP6yzHmaT5 8LSYGJJ/mG6qKttk2YcIgZGpJJXCB8uCc3H7MtMpaVWYCSc0YA/VRJYOs1tMcOt4M2Sv eTLP2sor0nDF24ONcN+DApDP3toWEPoNlukcfUMQd0i9NVzJYGn+Yzgt/IvPTTVctpKo zvug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ANXyuW7p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k93si15615037pjc.86.2022.02.15.10.11.42; Tue, 15 Feb 2022 10:11:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=ANXyuW7p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236198AbiBOR62 (ORCPT + 99 others); Tue, 15 Feb 2022 12:58:28 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231445AbiBOR61 (ORCPT ); Tue, 15 Feb 2022 12:58:27 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC51CB90F for ; Tue, 15 Feb 2022 09:58:16 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 1F0061F37B; Tue, 15 Feb 2022 17:58:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1644947895; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PWnIgritZWDbPqJt4NsgSR71vtgK2UWzhthhnP5o4N8=; b=ANXyuW7pa1fRxyk4Wi82kyjZCJBuqKX1zYvsPJuG/UniPdAKijCFcYg1yLlU+7XXtpIhMv 0CfdkivBt3YJc2YGKg4twu+MOatTDOXUrcl3jlvvw25cHxsarePAEQsuZz0UOWD5x7EPgY rGuJDycszjodPi/gitL3YyXISA8J4vU= Received: from suse.cz (unknown [10.100.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id CC322A3B89; Tue, 15 Feb 2022 17:58:14 +0000 (UTC) Date: Tue, 15 Feb 2022 18:58:14 +0100 From: Petr Mladek To: Sergey Senozhatsky Cc: Andre Kalb , john.ogness@linutronix.de, linux-kernel@vger.kernel.org, rostedt@goodmis.org Subject: Re: [PATCH v2] printk: Set console_set_on_cmdline=1 when __add_preferred_console() is called with user_specified == true Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2022-02-15 12:15:58, Sergey Senozhatsky wrote: > On (22/02/14 14:21), Andre Kalb wrote: > > +static void set_user_specified(struct console_cmdline *c, bool user_specified) > > +{ > > + if (!user_specified) > > + return; > > + > > + c->user_specified = true; > > + console_set_on_cmdline = 1; > > +} > > In original code we always set c->user_specified. Is it guaranteed that > ->user_specified is properly initialized to 0? Maybe can do something like: It is guaranteed. console_cmdline is a static array initialized with zeroes. The 2nd set_user_specified() call is done for a not-yet-used slot in the array, so it must be zero. > static void set_user_specified(struct console_cmdline *c, bool user_specified) > { > c->user_specified = user_specified; This will change the behavior for the 1st set_user_specified() call. It happens when the same console is added more times by device tree, SPCR, and/or command line. c->user_specified must stay "true" when at least one __add_preferred_console() call added it from the command line. > if (!user_specified) > return; > > console_set_on_cmdline = 1; > } I agree that it is not obvious. It would make sense to add a comment into the code. I am going to propose something in a reply to the original post. Best Regards, Petr