Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2109806iof; Tue, 7 Jun 2022 20:03:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPi9QKHysajnOQ/4sF7f4+ckjWbUArIiz/hnwX+3JvyTbfpsjJi6KTY/yN5y6zh4NbDFjF X-Received: by 2002:a62:6411:0:b0:50a:81df:bfa6 with SMTP id y17-20020a626411000000b0050a81dfbfa6mr32892213pfb.26.1654657422908; Tue, 07 Jun 2022 20:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654657422; cv=none; d=google.com; s=arc-20160816; b=LB7S+J5Ds6DxbhdUGLe9ufuMuq4iRXFYnh7Y9qYfMFQw9cFCbflq6SB6J80qABLi4/ 2tGNDG9t8/iCSfxcaopIzFCaLhGASrRtYfeRHc5mKn8oD/HrqJywHX9UDo1C3ndmbBR2 6y05mykdhL/X8nNNYOPhncabODLvut3T3AgsO6lj8tc5m+faMValLKVRLD0+ovF+Xo9v l5/605/B06NJrPInF9ukm8pFPRtcN2dWiT4d7kAtP+0DxXnRYkXV2+opT779ihoLk9Ej fiyWt6PrVgzGjbv4brghUTAGEfdNDKqK/HS8dmBvnDL5f3Da67iND8YJz/U2sC/r7kPn olxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=GIRg8u/CQs8pHF7oNp/S2oS01P+PnK8CbWWnzHzlD1Q=; b=borw7wzg8mCBGK8NGnsbWbv9Kgfa2zGmiXvGW3Dm6LLcaWwY5RSnD+gLh3GWZXdEKN rXp78Bv1qldheA/6CPdCHbM0yTqljWTPtYPTfQyPeWPpWqy1HBkD+V6c7UkR9juySIYu Ml6NgEKFLP3tgiiT0pcT30WXgSkI7IouagUq+RBbG/DGy6cuQ/J1EcpDNbLrqzOol9xv nAzhN1NtF9HfD2/Gs/nPnXyaLsKLefHy9T5bgxOkQEfNr51XeY7iGPD3hF1FXO4ENKc2 gzY4Zuc8JjalslxptTyQiOz4RQ2qoOgg9D/qkFAquHp5AShQ6XQVaOC9qGp8HulSM4Bz vU2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TndR4eVO; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id cb15-20020a056a00430f00b0050a5da0cd2csi15384426pfb.30.2022.06.07.20.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:03:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=TndR4eVO; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C517C3B51DB; Tue, 7 Jun 2022 19:10:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242116AbiFGKwA (ORCPT + 99 others); Tue, 7 Jun 2022 06:52:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242302AbiFGKuK (ORCPT ); Tue, 7 Jun 2022 06:50:10 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6079CF5D07; Tue, 7 Jun 2022 03:49:52 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0FE471F920; Tue, 7 Jun 2022 10:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1654598991; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GIRg8u/CQs8pHF7oNp/S2oS01P+PnK8CbWWnzHzlD1Q=; b=TndR4eVOagDCdgGuQdHnEu5qFh/L+7MtYAG2FRyNA6T2QY8enB+H4p81jHr8tLM4qg7XY/ jgSe90fjtOlrCAZPVHOuGve5InrxHZB+y9cWKexeZln4igWyFcZeH2uuiZhgBqrN8ju1ry MpvS9i/eX7N04ulAUae9W1Tn/RvThaI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1654598991; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GIRg8u/CQs8pHF7oNp/S2oS01P+PnK8CbWWnzHzlD1Q=; b=HQaBZ2HDYcia1aRkO4v/8vyAprJOXKSqMSFSTFioKbn16SP5IIlOqchoQEge3ZVpyVn3km a45Qem1WkF3sJcCQ== Received: from localhost.localdomain (unknown [10.100.201.122]) (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 DCF902C142; Tue, 7 Jun 2022 10:49:50 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 07/36] tty/vt: consolemap: make parameters of inverse_translate() saner Date: Tue, 7 Jun 2022 12:49:17 +0200 Message-Id: <20220607104946.18710-7-jslaby@suse.cz> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607104946.18710-1-jslaby@suse.cz> References: <20220607104946.18710-1-jslaby@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 - int use_unicode -> bool: it's used as bool at some places already, so make it explicit. - int glyph -> u16: every caller passes a u16 in. So make it explicit too. And remove a negative check from inverse_translate() as it never could be negative. Signed-off-by: Jiri Slaby --- drivers/accessibility/braille/braille_console.c | 2 +- drivers/accessibility/speakup/main.c | 2 +- drivers/tty/vt/consolemap.c | 4 ++-- drivers/tty/vt/selection.c | 3 ++- drivers/tty/vt/vt.c | 2 +- include/linux/consolemap.h | 6 +++--- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/accessibility/braille/braille_console.c b/drivers/accessibility/braille/braille_console.c index fdc6b593f500..c4d54a5326b1 100644 --- a/drivers/accessibility/braille/braille_console.c +++ b/drivers/accessibility/braille/braille_console.c @@ -131,7 +131,7 @@ static void vc_refresh(struct vc_data *vc) for (i = 0; i < WIDTH; i++) { u16 glyph = screen_glyph(vc, 2 * (vc_x + i) + vc_y * vc->vc_size_row); - buf[i] = inverse_translate(vc, glyph, 1); + buf[i] = inverse_translate(vc, glyph, true); } braille_write(buf); } diff --git a/drivers/accessibility/speakup/main.c b/drivers/accessibility/speakup/main.c index d726537fa16c..f52265293482 100644 --- a/drivers/accessibility/speakup/main.c +++ b/drivers/accessibility/speakup/main.c @@ -470,7 +470,7 @@ static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs) c |= 0x100; } - ch = inverse_translate(vc, c, 1); + ch = inverse_translate(vc, c, true); *attribs = (w & 0xff00) >> 8; } return ch; diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index fb61158f4dc6..157c7f936294 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -281,12 +281,12 @@ unsigned short *set_translate(int m, struct vc_data *vc) * was active. * Still, it is now possible to a certain extent to cut and paste non-ASCII. */ -u16 inverse_translate(const struct vc_data *conp, int glyph, int use_unicode) +u16 inverse_translate(const struct vc_data *conp, u16 glyph, bool use_unicode) { struct uni_pagedict *p; int m; - if (glyph < 0 || glyph >= MAX_GLYPH) + if (glyph >= MAX_GLYPH) return 0; p = *conp->vc_uni_pagedir_loc; diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index f7755e73696e..6ef22f01cc51 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c @@ -68,7 +68,8 @@ sel_pos(int n, bool unicode) { if (unicode) return screen_glyph_unicode(vc_sel.cons, n / 2); - return inverse_translate(vc_sel.cons, screen_glyph(vc_sel.cons, n), 0); + return inverse_translate(vc_sel.cons, screen_glyph(vc_sel.cons, n), + false); } /** diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index f8c87c4d7399..1ea1c11c42fd 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4741,7 +4741,7 @@ u32 screen_glyph_unicode(const struct vc_data *vc, int n) if (uniscr) return uniscr->lines[n / vc->vc_cols][n % vc->vc_cols]; - return inverse_translate(vc, screen_glyph(vc, n * 2), 1); + return inverse_translate(vc, screen_glyph(vc, n * 2), true); } EXPORT_SYMBOL_GPL(screen_glyph_unicode); diff --git a/include/linux/consolemap.h b/include/linux/consolemap.h index 98171dbed51f..1ff2bf55eb85 100644 --- a/include/linux/consolemap.h +++ b/include/linux/consolemap.h @@ -17,15 +17,15 @@ struct vc_data; #ifdef CONFIG_CONSOLE_TRANSLATIONS -u16 inverse_translate(const struct vc_data *conp, int glyph, int use_unicode); +u16 inverse_translate(const struct vc_data *conp, u16 glyph, bool use_unicode); unsigned short *set_translate(int m, struct vc_data *vc); int conv_uni_to_pc(struct vc_data *conp, long ucs); u32 conv_8bit_to_uni(unsigned char c); int conv_uni_to_8bit(u32 uni); void console_map_init(void); #else -static inline u16 inverse_translate(const struct vc_data *conp, int glyph, - int use_unicode) +static inline u16 inverse_translate(const struct vc_data *conp, u16 glyph, + bool use_unicode) { return glyph; } -- 2.36.1