Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1803100iof; Tue, 7 Jun 2022 11:35:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9BJBs00HYcVX2JWJanqzBO/IUtiVXh9lb3/xoEahP8oHw/aFr8Yw/xMouZeG5h0k6sDZG X-Received: by 2002:a17:906:9750:b0:6ff:11ed:7137 with SMTP id o16-20020a170906975000b006ff11ed7137mr27509724ejy.331.1654626532813; Tue, 07 Jun 2022 11:28:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654626532; cv=none; d=google.com; s=arc-20160816; b=ZDrjpj5wjGerOi64pNzqFBfcUKdnb4tpCI14Inx7+Eb9Y8lKnNHYOr5Kai+oQn0ect 3wFQCRpAJkTDkSzvEKapnUk6duJK9AtlOwB2vFRQ6d+xQUG6JHs4Tet9LW05eEJ2dFFv n0T6rdx+DA8YRQuZhErXBITUIpNZUdPhVHcEvYxqwgtknXz9LBOwO/bJMb+ve6gwdcn8 w+nFZ95ECfdpMsssPTx1GPepdKNB8AWd7rZpVoHtx/1w0g1aExdqsJ0PFTZkw93EZ2Kd Qi+1yiKQY8mmI+9GihLycQT5OhQ6liISX/iBTuYnM9XmpSC68e7EFdCDkItyLV5eUfnx 0hKA== 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=xMyZQRrXKtJochWB7+xsGtil/6dW4kBEoZgfCPMyREI=; b=OrcFETZayVlyofXVVWpAD5CuAo2mUqJcCdModGJHlQgBEN/IAuS7mkQ5U3FkUBkBQw VKyF80n83WxXbqjWOYLvyT8c0nlUygaOjXugmSqt6ncRc7wP9eg3jyGoBJfMSVny5dvs LQjdtz67F66q7YaBsrovCSrAj8tcpyQJH8Oh+t3uoQvZR32ohxF2Biw7+WVj4DpwnUW0 8jmlVd61PKX3rehPU3eczWoh1XZbdveWpZ+J/c5Z52ltQMiwVufplyLIV0KDtfRnfANJ 7qKCZFppEhHHZy1v4F8ThLFY0mkiUA9NvCo0vaf3GCKjxtehKVVj93664AkapRHfU72T YRBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=c6POMQ1Z; 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji1-20020a170907980100b0070bbebe6ce6si3880034ejc.103.2022.06.07.11.28.25; Tue, 07 Jun 2022 11:28:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=c6POMQ1Z; 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242299AbiFGKyW (ORCPT + 99 others); Tue, 7 Jun 2022 06:54:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242343AbiFGKuN (ORCPT ); Tue, 7 Jun 2022 06:50:13 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76CF4F688F; Tue, 7 Jun 2022 03:49:56 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5088F21B8B; Tue, 7 Jun 2022 10:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1654598994; 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=xMyZQRrXKtJochWB7+xsGtil/6dW4kBEoZgfCPMyREI=; b=c6POMQ1ZHRZ7N+amluupGEghN5rWqQ8Kc+FXi0uvbaTothz4CAuqd3dzj5NkqJkY07SJSR ET2cxU4ItRyEVeX4+wjRFNaNImRPHWp8mGuSLiocj0WV/aZD6SilCK45ix7dLjhYz9CuYK 6KhUR3c7DGPgMcmXZYwsZzrCBnFYdC0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1654598994; 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=xMyZQRrXKtJochWB7+xsGtil/6dW4kBEoZgfCPMyREI=; b=gPUycg+0rWUOl8es/5KCJA4BDQj4QeYwfgkFWPuHIs0HbE4XOYbzT44LxGGmHxZcZZ1mQF P1S4Ab2+kkK5kABg== 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 28A352C143; Tue, 7 Jun 2022 10:49:54 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 23/36] tty/vt: consolemap: saner variable names in con_unify_unimap() Date: Tue, 7 Jun 2022 12:49:33 +0200 Message-Id: <20220607104946.18710-23-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=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 function uses too vague variable names like i, j, k for iterators, p, q, p1, p2 for pointers etc. Rename all these, so that it is clear what is going on: - dict: for dictionaries. - d, r, g: for dir, row, glyph iterators -- these are unsigned now. - dir, row: for directory and row pointers. - glyph: for the glyph. - and so on... This is a lot of shuffling, but the result pays off, IMO. Signed-off-by: Jiri Slaby --- drivers/tty/vt/consolemap.c | 49 ++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index 2454a4395722..cbdc73605148 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -454,42 +454,41 @@ void con_free_unimap(struct vc_data *vc) kfree(p); } -static int con_unify_unimap(struct vc_data *conp, struct uni_pagedict *p) +static int con_unify_unimap(struct vc_data *conp, struct uni_pagedict *dict1) { - int i, j, k; - struct uni_pagedict *q; - - for (i = 0; i < MAX_NR_CONSOLES; i++) { - if (!vc_cons_allocated(i)) + struct uni_pagedict *dict2; + unsigned int cons, d, r; + + for (cons = 0; cons < MAX_NR_CONSOLES; cons++) { + if (!vc_cons_allocated(cons)) continue; - q = *vc_cons[i].d->vc_uni_pagedir_loc; - if (!q || q == p || q->sum != p->sum) + dict2 = *vc_cons[cons].d->vc_uni_pagedir_loc; + if (!dict2 || dict2 == dict1 || dict2->sum != dict1->sum) continue; - for (j = 0; j < UNI_DIRS; j++) { - u16 **p1, **q1; - p1 = p->uni_pgdir[j]; - q1 = q->uni_pgdir[j]; - if (!p1 && !q1) + for (d = 0; d < UNI_DIRS; d++) { + u16 **dir1 = dict1->uni_pgdir[d]; + u16 **dir2 = dict2->uni_pgdir[d]; + if (!dir1 && !dir2) continue; - if (!p1 || !q1) + if (!dir1 || !dir2) break; - for (k = 0; k < UNI_DIR_ROWS; k++) { - if (!p1[k] && !q1[k]) + for (r = 0; r < UNI_DIR_ROWS; r++) { + if (!dir1[r] && !dir2[r]) continue; - if (!p1[k] || !q1[k]) + if (!dir1[r] || !dir2[r]) break; - if (memcmp(p1[k], q1[k], UNI_ROW_GLYPHS * - sizeof(*p1[k]))) + if (memcmp(dir1[r], dir2[r], UNI_ROW_GLYPHS * + sizeof(*dir1[r]))) break; } - if (k < UNI_DIR_ROWS) + if (r < UNI_DIR_ROWS) break; } - if (j == UNI_DIRS) { - q->refcount++; - *conp->vc_uni_pagedir_loc = q; - con_release_unimap(p); - kfree(p); + if (d == UNI_DIRS) { + dict2->refcount++; + *conp->vc_uni_pagedir_loc = dict2; + con_release_unimap(dict1); + kfree(dict1); return 1; } } -- 2.36.1