Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp22217362ybl; Mon, 6 Jan 2020 21:21:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyT83rjDrZ54aG3Paxk/5YlQrteJz5CZ1ZINHmgzYSccD1EmbzvYbW96orO9Y3K0tsLEgj/ X-Received: by 2002:a9d:4f0a:: with SMTP id d10mr104717357otl.85.1578374508738; Mon, 06 Jan 2020 21:21:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578374508; cv=none; d=google.com; s=arc-20160816; b=CGtzI0CW4dWQMAQRAxweztdj9qbNUgHOLoUEgBjy1Sm6jhjcOh+5uMFmLXzbPYo1QR 9xZc5OJzkYMjbHraouBzCq6KsvijFrB3l0pM2XRvkjjQruM22/tCRSX0NuIn2yQV/+yV h47+eAqkOndodTfxHvEyHJYoyYYHWxjrCvcOIvi+C85rFEWZ7mWTyHDGf0Vaq/JX5sPT AINfPi+LKuLmVkoVm2L797okrhXD2j41JNCVorvlwvboQe2vFWXiZy9WQ9Ey0p+Mz0Gg XqcZxpHWCCpzHwoHnAQH7KFWYp+xf5KeIeNf9lpZbNlPaQdxiIsrlwuZtXaAHBf0tKeA i51g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=o424RCYfUnkY205fqTDroBAVPlaoUOrgoI5FseVpUN0=; b=NZk8bNO87g6MW3Q7YKTDNWpTjae2Ry0J9NkSrUdxAfaAmtUYCnxdy4RDxonIIIDDop kPZSRm9vX6TbOXVyliqgxk3zx5cG5JYYDaqL7IQ4DT4+Q+21anGoPQ1H8JqvIEh6kWfx sH3WECbjB/B24yTtvR/4GAxFqXi9iCfzYSiLpcVMOps7zlk8Sy6Xfc7rRl9twMRFi4da /bNvX3UdEE82EtZvaxXMZtQt5wZ3o0Qtv38n6Zc+pfLyu/ZyfqBr6kSxaMy0ojkNBg7A GFdPjtwm1DnvWbUlfO3gqWAQk+2iTAnlIDtlI9jfLDsVFIg4uphrt4dx0rrEI/GAp/YF jRsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTke3Cc+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si36535594otq.95.2020.01.06.21.21.36; Mon, 06 Jan 2020 21:21:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTke3Cc+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725987AbgAGFT5 (ORCPT + 99 others); Tue, 7 Jan 2020 00:19:57 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:32906 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgAGFT5 (ORCPT ); Tue, 7 Jan 2020 00:19:57 -0500 Received: by mail-pj1-f65.google.com with SMTP id u63so4934894pjb.0 for ; Mon, 06 Jan 2020 21:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=o424RCYfUnkY205fqTDroBAVPlaoUOrgoI5FseVpUN0=; b=qTke3Cc+OKnCWiGKR/Q0maKi0YSJRPT9Y774n9qyP7g04f5Xo2B5ex+fObXmEAPzr2 U/ruLoaIegItXTcUrJk4b0MGJY/txM+7poyXtNyWLxUUa3eDJMrtIYXjjQZTFsO4btFe 3UstS7AK/HbX5zLber8BthVJBmZ+n3edew9DVUtupbvMtLNOmBtTSJhs/kSUiEpatXT7 KpjPVVFwcT26EU9m+Sy/lj1MnbSoSdBMHW3H2O+qxks62i2kCJOrfdWgGPTPSI10hPxK 7Ih7DGwoXKyb2DeaQkvmEQso7JnOiMgGFwAtPksGdV9C8XPfueC0JDT+Ux5PgxHx1Hja oCtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=o424RCYfUnkY205fqTDroBAVPlaoUOrgoI5FseVpUN0=; b=dHHAzDNwVLi2oXrHQ5VvFvcIQg7NkFXDuinSQJyR+I40RAnzcUsox8cV0c/XiPGE2L bEFK23pvR8SJ/AU8PJlmUr6IrsfTPTLe0FAaHfqS7x/Qw1YihetoHLxQwkMSEI0G3kEh mvhbFv+b0MaVD04rJPlYV3+DS9hTPLgyJwmD1BiSrnb4Q938Rr2hSfGrcPM7Fxt2b3HB PZK+XO//xhbTiR+dV9Wf/Zbk0zqc0O/6Lgds74RIEoIfIJ12a8XaLReKElz6ClyRfQD5 zxj0GJdfdTqB8om023G+80yFOJDxLWkpOXFB1LvRNpYL/l4+0ryfVZxdebnIRSsmN9pA OMuA== X-Gm-Message-State: APjAAAVeCoki1WLENBBKS6D7fDGIJ6PI/mjuktYo5ZFWHyyzc3HF4PHL S8dqn5S/YcV5Fa175vJa5+U= X-Received: by 2002:a17:90a:e291:: with SMTP id d17mr48255384pjz.116.1578374396521; Mon, 06 Jan 2020 21:19:56 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:250d:e71d:5a0a:9afe]) by smtp.gmail.com with ESMTPSA id 7sm70774607pfx.52.2020.01.06.21.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2020 21:19:55 -0800 (PST) Date: Tue, 7 Jan 2020 14:19:54 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: Sergey Senozhatsky , Benjamin Herrenschmidt , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Steven Rostedt , Linus Torvalds Subject: Re: [PATCH v2] printk: Fix preferred console selection with multiple matches Message-ID: <20200107051954.GA205756@google.com> References: <2712d7e2fb68bca06a33e2e062fc8e65a2652410.camel@kernel.crashing.org> <20191219135053.xr67lybhycepcxkp@pathway.suse.cz> <32fde8cd451ea0eaff38108d9f2f2d4a97a43097.camel@kernel.crashing.org> <20191220091131.4uifcbudwppjspf4@pathway.suse.cz> <20200106051508.GA17351@google.com> <20200106102537.nirnfcauqdh4olgv@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200106102537.nirnfcauqdh4olgv@pathway.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (20/01/06 11:25), Petr Mladek wrote: > On Mon 2020-01-06 14:15:08, Sergey Senozhatsky wrote: > > On (19/12/20 10:11), Petr Mladek wrote: > > [..] > > > > > > +enum con_match { > > > > > > + con_matched, > > > > > > + con_matched_preferred, > > > > > > + con_braille, > > > > > > + con_failed, > > > > > > + con_no_match, > > > > > > +}; > > > > > > > > > > Please, replace this with int, where: > > > > > > > > > > + con_matched -> 0 > > > > > + con_matched_preferred -> 0 and make "has_preferred" global variable > > > > > + con_braile -> 0 later check for CON_BRL flag > > > > > + con_failed -> -EFAULT > > > > > + con_no_match -> -ENOENT > > > > > > > > Not fan of using -EFAULT here, it's a detail since it's rather kernel > > > > internal, but I'd rather use -ENXIO for no match and -EIO for failed > > > > (or pass the original error code up if any). That said it's really bike > > > > shed painting at this point :-) > > > > > > Sigh, either variant is somehow confusing. > > > > > > I think that -ENOENT is a bit better than -EIO. It is abbreviation of > > > "No entry or No entity" which quite fits here. Also the device might > > > exist but it is not used when not requested. > > > > Can we please keep the enum? Enum is super self-descriptive, can't > > get any better. Any other alternative - be it -EFAULT or -EIO or > > -ENOENT - would force one to always look at what is actually going > > on in try_match_new_console() and what particular errno means. None > > of those errnos fit, they make things cryptic. IMHO. > > I agree that the enums are more self-descriptive. My problem with it is > that there are 5 values. I wanted to check how they were handled > and neither 'con_matched' nor 'con_failed' were later used. Right, I also saw that not all con_match were used, but I didn't consider it to be an issue, con_match describes all possible cases (completeness) but not all of those cases exist in the code. try_match_new_console() is going to return multiple error codes anyway, all of which should be handled. Switching to `int' (4 billion possible values) probably doesn't really help us. > I though how to improve it. And I ended with feeling that the enum > did more harm then good. -E??? codes are a bit less descriptive > but there are only two. The meaning can be explained easily by > a comment above the function. I understand it. It's just we don't have appropriate errnos. So instead of only documenting the logic (because enum is self-documenting), with errnos we also need to document the return values we check. IMHO. -ss