Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2183469iof; Tue, 7 Jun 2022 22:28:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDtYc6MSQAyLTzJj3XebGTgax904c6KQSD+zKjyBXw8E75A3WxcBo3yVbBMzxprlvojCkf X-Received: by 2002:a63:81c6:0:b0:3fc:9480:5e3c with SMTP id t189-20020a6381c6000000b003fc94805e3cmr28341730pgd.529.1654666097389; Tue, 07 Jun 2022 22:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666097; cv=none; d=google.com; s=arc-20160816; b=U1YHybqkG4y8+I4jGm5Rj93GsSiKXBr2AbxzLg4rkGbVYLv4N5M3eeBPE3ZiE2BnMR 2NE36kuhta6E+VBu3uKo0dlbxKDU3k5TjujuDaO5TIIx7R2JyAPE/AMxO5lADalh9QOo LrlqcdISK8p/kgU7HONLH7MZi4OLVgXth1oYMRb7tn63XwuSUCQFdXprVykfD77yyjiJ tCB+1G369Y8PFmCH04XDP+ZG0Yz+Fa+yAOdsgmcycTXAZJIKN1pfPg8s1T09HQGnIRhi v/U9quDrMhuxW1G5s9sDBRc9g5EvWiC5PEFkLidyTSsuojqnmpkGTV8AkzBRUp5S5iKA rFcw== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=ikkBKC1KqNjVSYGH4msAtxXZ42KrWWeGQjeVqqAJZ3w=; b=AbjF/zrFJrio4Bfc2+d4YCqRhG7cI0hi56GDYZAX9GUN6SS7We1pEZo12YNtYApF/v AONtXmleQLunmxvoobO1V7BP8Ej+wsV7BrXlJKEX5dD0p1LGud/PnqFRdjbVfFR1gAnI gNt+a+8OoxQzy0JXhSZgJPSs9wJlEK2c1dI+hm8s7OLxwRT70HWovnB3PtxWyZP6DIpg 1zy4f81hJ8iNehREAeZ6C7kWWsMRKO1e3Cy+RGPfZxVxQ9ko4pTy5Cw88UCoTkqX8enR 2xk8kTYbv2k4e7RfGlLThCDoWeH4Blq/s6AsUWa3i5uu7l5/PwbksJa3R8qtAJUp9zoz RPvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ny7dsd0G; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t14-20020a63444e000000b003f5ef397b2esi5447433pgk.32.2022.06.07.22.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ny7dsd0G; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D938147B49C; Tue, 7 Jun 2022 21:54:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242073AbiFGKxA (ORCPT + 99 others); Tue, 7 Jun 2022 06:53:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242288AbiFGKuK (ORCPT ); Tue, 7 Jun 2022 06:50:10 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2142D92733; Tue, 7 Jun 2022 03:49:51 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C956221AE4; Tue, 7 Jun 2022 10:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1654598989; 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; bh=ikkBKC1KqNjVSYGH4msAtxXZ42KrWWeGQjeVqqAJZ3w=; b=ny7dsd0GhKQHInyo7aIJPf85+8bsmwgrBA0y0F6lnveKOGHVgG80AZbpPMVZ3RI+FTOQpg UYMcbItPTEv1+9C1Y2ObAWHQYq6u5xEmk27KBDz+CjGytfrodzEZLozyknwtNq4LN4YEwe 1guFnOEgXfgV53AeoUApZPiklfjfF9E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1654598989; 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; bh=ikkBKC1KqNjVSYGH4msAtxXZ42KrWWeGQjeVqqAJZ3w=; b=oJ8bWNBPeLhBNXo0PP4ehaysRdZzgb7JU5AfvUlaIcwaL7I8ayeFSavKgrLpEG0OG8jFbg LCh0MwUqYKb9ZPDg== 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 A0DC12C141; Tue, 7 Jun 2022 10:49:49 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 01/36] tty/vt: consolemap: use ARRAY_SIZE() Date: Tue, 7 Jun 2022 12:49:11 +0200 Message-Id: <20220607104946.18710-1-jslaby@suse.cz> X-Mailer: git-send-email 2.36.1 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 The code uses constants as bounds in loops. Use ARRAY_SIZE() with appropriate parameters instead. This makes the loop bounds obvious. Signed-off-by: Jiri Slaby --- drivers/tty/vt/consolemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index d815ac98b39e..839d75d1a6c0 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -408,7 +408,7 @@ static void con_release_unimap(struct uni_pagedir *p) } p->uni_pgdir[i] = NULL; } - for (i = 0; i < 4; i++) { + for (i = 0; i < ARRAY_SIZE(p->inverse_translations); i++) { kfree(p->inverse_translations[i]); p->inverse_translations[i] = NULL; } @@ -798,7 +798,7 @@ u32 conv_8bit_to_uni(unsigned char c) int conv_uni_to_8bit(u32 uni) { int c; - for (c = 0; c < 0x100; c++) + for (c = 0; c < ARRAY_SIZE(translations[USER_MAP]); c++) if (translations[USER_MAP][c] == uni || (translations[USER_MAP][c] == (c | 0xf000) && uni == c)) return c; -- 2.36.1