From patchwork Fri Feb 2 06:56:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 195659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp257155dyc; Thu, 1 Feb 2024 23:12:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IH9CPuwv9+ZUvMzOC7dou9JNvuwKapQKRNsB0NLw/hyttYIB9iZOVOXePfXH+Nkh+SgWhuZ X-Received: by 2002:a92:c0cf:0:b0:360:d904:4419 with SMTP id t15-20020a92c0cf000000b00360d9044419mr8323049ilf.28.1706857952454; Thu, 01 Feb 2024 23:12:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706857952; cv=pass; d=google.com; s=arc-20160816; b=dySCYtM4FeCpERm9IZ6vxBuh5xDtp5/BQYUkMUtAoxe04Ul0hN2npTYNgqU7Q6xlLz g+1PLwh4/laeugXYCAuCo/Wb2Sd0W0m6OAJVhpKCelqBAGeAq2pEJcNOr1bEz6EHdxhp KOm4D9VDSPn4uLim0myPCX1J038XgTDD+nZkeeZRBf1muwG9q/561TvXDvvcTkdv+FbX 0/9j1fHaB+osb9BwC9Wm7aFPJYpeeHk1TwS9LuPWetqzASsZdySbHkKaIzH963sBiKEU 1ysEbzNefZRvy29qlAYq9j9koqZcNNj74O2R+rwn/+7ld9jNKA5h70TmTipj9rD+Ux/P PXRA== 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=a/k2tWcXRTpE89oU0NJSF3ba0JXt1bpeVDvH7jPLV8Q=; fh=UtQRvcDEm6iLb6HKmASmBofcezGd1Ugh08Ple12iNzk=; b=fqxtipj2hvRwI+6F0E9jlo+Z486ckUE/a18DZf+8FEuin1ACTNEHTAkl0U3mDRVew3 vNAXPWGhDe+tekNpn0mCpkUTgKdhdONoctrvdy8faWdjyye01zxHZnk4UZj+EcLW2Qj7 0gVxNToIIe6mJv9RM707JMVeULGH8z9UiMGxj5Iob5qrKKcOs3emzFm9R798bPp0YEKq kxwUh+V/CY6tByuxkIhmGVv9OB89ihTCu8JNRLCaADH9qyi2n3wlBjigXhULneHzIGdp F/0/YMG4amUfZny+uuqA3nPFmY+x7AcykmLHYPj7ADjOTQcRoD/58wH3lepMO6zqgMOg Ztcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7ZxXwSn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUfAFYNv9TbU/vMqGHB7tKavHT+ECLltuYLaMcYYDrnrf84eB9MRzYsYp9pEUSAGc+XmKqiOWkqkbrVm9g9M1K+YFhAww== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id v21-20020a63d555000000b005d18fd425f6si1176102pgi.68.2024.02.01.23.12.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 23:12:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M7ZxXwSn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-49334-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49334-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 69302B26C67 for ; Fri, 2 Feb 2024 07:01:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 47529487A7; Fri, 2 Feb 2024 06:56:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M7ZxXwSn" 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 90452482F1; Fri, 2 Feb 2024 06:56:39 +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=1706856999; cv=none; b=CGBZ9vZTznceiWvlFmtsEVy0/523lTTPGWZ03L7+Dg7YySkGqmeiDby7DQdbISRD2zn5b5GHMt8zHBFEi1xmDCqyvfdP1Knjw8C06WvOFXmWV1ceNu0mtX7enjeBm6cMgk70N/l4Mulo+6tjFqKDoBEyU77BWMFUKVK1obn5OW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706856999; c=relaxed/simple; bh=f1BOAc650vN/wZSXPoFGQMv1ubutbNRxF0vqxh4BsrY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NwIvAXxzvUKfL+GCv3Jbo5UdllMYHlUb+S5qTaZ0zUV+74RIshmL/05BTMuKJf5XBKlK3vO2r9ry1/o6oIrWTpO4Bimumk45OVKvudU82fMI6aCOwFZUQPHW2j4E5Ptk1Vc3U67F4MhrCAVGNdBOQw3jqBsjgCc++xCqDsxmZEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M7ZxXwSn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A8FEC433F1; Fri, 2 Feb 2024 06:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706856999; bh=f1BOAc650vN/wZSXPoFGQMv1ubutbNRxF0vqxh4BsrY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M7ZxXwSn6t/o6IcTt2O/lgEkqG7p8eTQGR3uTgShc3uXD8hdci7keg1scFmervl94 YIou5trwftdSLC09lwe7zetKNMl88kCLhSq+P0LHcNlk2UVvo6ijc9FjV5600gGeN+ yPtt0deFW8xHdOnW0rdjRdtNQTx5nAoiaL6hbOAZa0f2cadjhoHyN25dDFOVo2fwRV 5aCb8X+3cQLKm2wBbxcc5nAge1//xdMkWpLCVMN2cL5hQI7J5+b/kdriNV0p9a8NWH pXu/NadI9jdJu2TYFuDRZBx5ARaGqVfU4c2saN1PlO54SLZjvgWGb8hQuEH7pEjtEN A8gtvYRMubGnw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 18/22] tty: vt: add new helper for reseting vc parameters Date: Fri, 2 Feb 2024 07:56:04 +0100 Message-ID: <20240202065608.14019-19-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: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789770284325749511 X-GMAIL-MSGID: 1789770284325749511 The code to reset the vc parameter parsing is repeated on two locations. Create a helper vc_reset_params() and use it on both of them. And instead of a 'for' loop to clear the array of parameters, use simpler memset(). Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/vt/vt.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 4d020a9967a2..b0f691d79bf2 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -2548,6 +2548,12 @@ static void csi_ECMA(struct tty_struct *tty, struct vc_data *vc, u8 c) } +static void vc_reset_params(struct vc_data *vc) +{ + memset(vc->vc_par, 0, sizeof(vc->vc_par)); + vc->vc_npar = 0; +} + /* console_lock is held */ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) { @@ -2568,9 +2574,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) return; case ESnonstd: /* ESC ] aka OSC */ if (c=='P') { /* palette escape sequence */ - for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) - vc->vc_par[vc->vc_npar] = 0; - vc->vc_npar = 0; + vc_reset_params(vc); vc->vc_state = ESpalette; return; } else if (c=='R') { /* reset palette */ @@ -2599,9 +2603,8 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, u8 c) vc->vc_state = ESnormal; return; case ESsquare: /* ESC [ aka CSI, parameters or modifiers expected */ - for (vc->vc_npar = 0; vc->vc_npar < NPAR; vc->vc_npar++) - vc->vc_par[vc->vc_npar] = 0; - vc->vc_npar = 0; + vc_reset_params(vc); + vc->vc_state = ESgetpars; switch (c) { case '[': /* Function key */