Message ID | 20240202065608.14019-17-jirislaby@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp252146dyc; Thu, 1 Feb 2024 23:00:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmOUaPayAP1UubCHAaE6Yc45gbUw92lzJ2p19V7EN3r6AtGm6C8FKkpFSmw4c+phhb/HdE X-Received: by 2002:a05:6870:ce49:b0:215:22fc:a1f2 with SMTP id xd9-20020a056870ce4900b0021522fca1f2mr9397368oab.3.1706857255391; Thu, 01 Feb 2024 23:00:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857255; cv=pass; d=google.com; s=arc-20160816; b=hYoAlmSH/d85b7qVrFhihYRnB+nyUQBWI2hhHch/O0KBgskmqZQPh3YwFGUbmLClx8 AkUTOWZSYIxn9miqjGHMcIr2RoYl/VM3leckRQnDVvz3ATuFTCSam9QLTo2CR1DGRxOe XbpMMlvpTX4+Qd6FAeUZMXKFFDMga3h5IUFB36TlROOkxDjuCKwXkIUFUH+QAj0RApTA 4yN88QEuaB1dtUGrWQ41NFlS59XuThWO45T9IXbV0wSFOIEstUA/0tweX15wuqwe3wvN mB8qT9SQCahHELqa2n0XopEEATa3OHQRTmscCwD8vq3y3G+fGFfefPrYJ3QSYNr3vgm5 jLNQ== 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 :date:subject:cc:to:from:dkim-signature; bh=v/9CC7zKBiR4CeF7miMokhp8H66NmBbYssUSBbo5mks=; fh=Bu9IjWclO49eGkEQN0EVq110Etbf9i2ju4H/PPKpUQw=; b=LmkiSUPI/uHRqu6HgPKtNeJwbXdqPS1H1IN2pTcgbBZZ4Qq9neQ3gOCOAq8bep8dtO Md1OnSWeBYUxZR0AGegtwnW0uem8CXEQZrJlYe/daJx3McPOHepttq7rVNM83RDVNqiD Q5+3ol4Zya85mUnaVJr/hI+XPvyJoFfaIC4L3jvJmuw9OWbiQhSKjH8LMJuBPmmjLsU3 t7gP3lZckTJgrsHDA1gSDWVtKvoeVDczebU2YTR3d+yI32+h8l7I6XRKTC/uaCMpu9Tz IF2fVnEtp3q+i5IpKz3FRQH2ZjWljPKpHbM7RGr91HSelZTMrR8jQmrgcKdpGm/E8y+Q Qiqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ajng1D+q; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWDPQl7S3wVZkryC0OMiYrr6L8UBL4FbvQA49Pn3tdTcqJbN6o8tOMynBVI83fqQwuDkymOOFfCdMOZB6Tyeo0o/R/r4g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e18-20020a635012000000b005d8bdc6258fsi1071637pgb.679.2024.02.01.23.00.55 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:00:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ajng1D+q; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49332-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49332-ouuuleilei=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 2716C292BCB for <ouuuleilei@gmail.com>; Fri, 2 Feb 2024 07:00:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFDA0482E4; Fri, 2 Feb 2024 06:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ajng1D+q" 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 40CD3481A5; Fri, 2 Feb 2024 06:56:36 +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=1706856996; cv=none; b=KC9G1gLYYyIBzAt371rrHntkzQfkHhXvufHo2Glg4gzOOTg1wbIdQfquTg3dbF688ysdDQ1+ZnMyY9TibCXfLHgnlNOyiAJBfnmt71X+p2Exbmt9t99tCoOo6lR2GJWJml0ccV7qesuN+Qg/Ca6wLX1vgD8LVaJ6tRvWOBUZWxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856996; c=relaxed/simple; bh=jceecDRmdMOBljAQEyGtk+60sTp3SXvkt+2y39jsxjo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z+X5f4uwxLneDcvxYHnstEWAnh/L4bI9lqpo7kXWVZuoLf+RG/CCfYJPgePNyozKsJ1RkHQWnYZOaDMLdGoZMB2oDGWbFCohEgkE9H+7Zs1SfL35TuW3RPSP5ijgxbrSyfMw/RNPR5lF4LevoM4nl8avlxWi3tgDrchlhVBO/xg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ajng1D+q; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 091F4C43394; Fri, 2 Feb 2024 06:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856996; bh=jceecDRmdMOBljAQEyGtk+60sTp3SXvkt+2y39jsxjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajng1D+qyLcEo3NKj2TKAFekEQK4OpTjcATlGAi0UzAzndbu42IXqlyD9TSS/lS/g 5zCrj6DZmV30SnJp2o3z0//gq1U600DsBmfu4uPpdRjXbOJ/D8eAT8WYQkfFYX+lsV eP1KsbWgZ5aOXxQTi/UQhWbnAkam1yVy29rjQqlt2IkuutOLnNlwRA9sWy3TsDvlUa UdlqV4kKirAILgxYbKCSsw9H6aSM+ZcmAAxXHGBrVg0uVRP/nptJPXmneHq95BN33v 1oHUHLWvDekjHvWxgdRGPxpwVriFdzUA79uPCZ/znwPz7hL0GLxBQy05rGwUCfQs45 FQxiNu6/KLH8w== From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Subject: [PATCH 16/22] tty: vt: simplify ansi_control_string() Date: Fri, 2 Feb 2024 07:56:02 +0100 Message-ID: <20240202065608.14019-17-jirislaby@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202065608.14019-1-jirislaby@kernel.org> References: <20240202065608.14019-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789769553072893457 X-GMAIL-MSGID: 1789769553072893457 |
Series |
tty: vt: cleanup ESC sequences handling
|
|
Commit Message
Jiri Slaby
Feb. 2, 2024, 6:56 a.m. UTC
Given all the ANSI control states are sequential in the vc_ctl_state
enum, we can define first/last constants and use them in
ansi_control_string(). It makes the test simple and allows for removal
of the 'if' (which was unnecessary at all -- the 'return' should have
returned the 'if' content directly anyway).
And remove the useless comment -- it's clear from the function
prototype.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/vt/vt.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 6d08290fdfdf..e1cbe966bc84 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2107,9 +2107,11 @@ static void restore_cur(struct vc_data *vc) * @ESnonstd: OSC parsed * @ESpalette: OSC P parsed * @ESosc: OSC [0-9] parsed + * @ESANSI_first: first state for ignoring ansi control sequences * @ESapc: ESC _ parsed * @ESpm: ESC ^ parsed * @ESdcs: ESC P parsed + * @ESANSI_last: last state for ignoring ansi control sequences */ enum vc_ctl_state { ESnormal, @@ -2125,9 +2127,11 @@ enum vc_ctl_state { ESnonstd, ESpalette, ESosc, + ESANSI_first = ESosc, ESapc, ESpm, ESdcs, + ESANSI_last = ESdcs, }; /* console_lock is held (except via vc_init()) */ @@ -2202,12 +2206,9 @@ static void vc_setGx(struct vc_data *vc, unsigned int which, u8 c) vc->vc_translate = set_translate(*charset, vc); } -/* is this state an ANSI control string? */ -static bool ansi_control_string(unsigned int state) +static bool ansi_control_string(enum vc_ctl_state state) { - if (state == ESosc || state == ESapc || state == ESpm || state == ESdcs) - return true; - return false; + return state >= ESANSI_first && state <= ESANSI_last; } enum {