From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 41E80393DC7 for ; Fri, 15 May 2026 10:31:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778841062; cv=none; b=Xzacv36fFDHc26Ut9KySFJyfO3CDqW9IWy9SCuRbqoMsVDzNqrR79rIlGAWxHXgUJGoumbSK9xFGvIAjjlIhMEySEK2QCBcWr/mUB9j7CYmfONOZXtINRMgsoXTVM6W8GnP91Vo/8Jc7TvcZ3ubORNV80xu5m/KPgNQceusYB2M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778841062; c=relaxed/simple; bh=1VWoNTF7TxdpeGKuBFIKZonK8LO5rmibueFPo9o1QII=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=GW6FHbKiA9uAP0UWAkH78A+6spd0ESOL/NFqF37WovHSbKN/8n40JakvZ7jsnryfMvFoefYoQsuGXpc7VDLSPHU/MzHR4wUx6WgkaNkWkccPDIQ86JJH4Pf1+27rxhG09f9q1PpYLJlZcPKHX6h8q81U97d5DGiPfaY9QtkI4i8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=lUz4Ym2k; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Nyia6e/N; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lUz4Ym2k"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Nyia6e/N" From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778841059; h=from:from:reply-to:subject:subject: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=Vi6CDOAAmYhlQX0++JclLXMWcdBFDAb+mDSS5wOkDKM=; b=lUz4Ym2kunkkn8tl/w0eidQN1WWJVhujIXVVmIZvVtdSewUTW7Szrab7bahjajlozc9h2e bdZkTBs5tO2HbqvgN5KDIdh4FVyTUV7cMc/rUZSrMCQxAolSZ7IAAF/kz7qbNgrEJZNL2+ n5Sm/VjHD+cuDrNM1+1nlJqgGW665zRZYeRRSWMX27GA6ySVAWZTNsGJqOXuxS8/Pi7fk4 qUWz8VT2LO/MZhHaJah7ipy/yIWaeclK3Docq4wnETZkoaPom1a1phcP+PPbemb9A2u4fS JAQ1SRhy3rpv0gj2wAWlGlVVW0D8MwPb/HykOa6FnewVx2/HyxoFF28viUyihQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778841059; h=from:from:reply-to:subject:subject: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=Vi6CDOAAmYhlQX0++JclLXMWcdBFDAb+mDSS5wOkDKM=; b=Nyia6e/NqNE5eLSqNv48k7fti7S/z5oyCyboUm0ieTjmICMP+buP9MzqAFDVo+UVXqmTID HQpSr/Y5nwjvYnAQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Marcos Paulo de Souza , Chris Down , linux-kernel@vger.kernel.org, Petr Mladek Subject: Re: [PATCH v2 3/9] printk: Separate code for adding/updating preferred console metadata In-Reply-To: <87o6ih6kfh.fsf@jogness.linutronix.de> References: <20260423130015.85175-1-pmladek@suse.com> <20260423130015.85175-4-pmladek@suse.com> <87o6ih6kfh.fsf@jogness.linutronix.de> Date: Fri, 15 May 2026 12:36:58 +0206 Message-ID: <87lddl6k2l.fsf@jogness.linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On 2026-05-15, John Ogness wrote: >> + if (!pc->name[0]) { >> + strscpy(pc->name, name); >> + pc->index = idx; > > Here is the copied code. This block is about setting the name. > >> + } else if (strcmp(pc->name, name) != 0 || pc->index != idx) { >> + pr_err("Updating a preferred console with an invalid name or index: %s%d vs. %s%d\n", >> + pc->name, pc->index, name, idx); >> + return -EINVAL; >> + } >> + } > > I would put the index setting here as it is relevant regardless of how > the devname or name was updated. > > pc->index = idx; Ah, I guess you only wanted to update @index if it is a new entry (because otherwise it will already have the value of @idx). If you want to keep the index setting in the devname and name blocks, maybe just adding a comment to clarify it is a new entry: if (!pc->devname[0]) { /* This is a new entry */ strscpy(pc->devname, devname); pc->index = idx; ... if (!pc->name[0]) { /* This is a new entry */ strscpy(pc->name, name); pc->index = idx; John