Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2125482iof; Tue, 7 Jun 2022 20:34:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxpXEl4LqT9p5chCNlecNXzJ2hHIZgWK/j0e0xl7bqmwJjLb2EIR0WGdP8c4Gh1zd/IaGP X-Received: by 2002:a17:90a:3182:b0:1e3:530d:6994 with SMTP id j2-20020a17090a318200b001e3530d6994mr41819747pjb.69.1654659296755; Tue, 07 Jun 2022 20:34:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654659296; cv=none; d=google.com; s=arc-20160816; b=dk4ymR4E7zClnaNmPqUZryZ1fMsZ08vuctl4qzIGjtlEgo6yyesUc9pBsrND4f5YNF PByDgAq1cIWpi8EHD8QqC83hYZq+CxnrJDRgLYnliaAToPIdl6sIADR6zds1QJgXY7VC M5kixzeIroSwT5lS0gnituJUFPgAy/zpsBQgzNdv4xZZ/HNaMgpIDDVhwZD+xmcnEQOx XXSADlrN7sUuIKdpNm2SlRQglQE6bnMGNoPatypZJfChd6EiVTQ5SH7YPn7L00ZcdDNh iv8z6f+skMIxuO3cklZ/Xevzk+ZKaLvn7rPZsBGsnlY6vxXu7cfuiGS9xZQlv7noJeBv TgwQ== 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=F3O8pK7reIxPoFRnMcI5fdMHJz2FqzvY3j9G6Q+mnLQ=; b=MTM0Wu5oPcXOdwjVsubFeJoyd3ulDAKDYVc5VGHK9gbuBayvsXVK4QENaGFx9pto4+ sthsgJe7WnaEKmvt4tX/ZQ+P3hF3Y3jEywVeWfzB+ZNJQTW7NApyLufy6SlLM2PlMckS yttrxVuFNHi7GvEcx/Yffmkugm9mJLBkqDy1wGM+xPzsMEh7Dq/U8OHCLxrwDbxDMczi tkjC0q6b2IT+r20AzK4QqoUWAQd7t5H8EwduXqHIh81EJyF6T9XqTYLosfkWxcxi5hvM hXctdbp3Lf5dVUyKFtY1LXtSFCdd2tmoXzwFtP9wSE4dFdUU9q20WLwPji3Q9FMVQjb8 4pyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=t2QPgyVv; 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 a24-20020a1709027d9800b001688d11a074si2727638plm.457.2022.06.07.20.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:34:56 -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=t2QPgyVv; 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E1D5169DDB; Tue, 7 Jun 2022 19:42:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241902AbiFGKv0 (ORCPT + 99 others); Tue, 7 Jun 2022 06:51:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242314AbiFGKuK (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 82802F5D33; Tue, 7 Jun 2022 03:49:54 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 13F0921B79; Tue, 7 Jun 2022 10:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1654598992; 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=F3O8pK7reIxPoFRnMcI5fdMHJz2FqzvY3j9G6Q+mnLQ=; b=t2QPgyVvjdgXeqXuDziaytbgnFFz5I8nZZInxLQBJXXUq1tjx1SQlY/rXXYAkWxJcOp9Cv 9/kRsBx2GYI+9pTTFBbYB6SyOPoCbW9SYLOzZ4zK4D5lkDkDz6zy8QZO8xEKfEchWY8OL2 OJLj8XkwUoYZCRUYH9DfsbnqY0e5FRg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1654598992; 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=F3O8pK7reIxPoFRnMcI5fdMHJz2FqzvY3j9G6Q+mnLQ=; b=gofPsuTjRg4Rolez1n0h25U+DGKsnt7PRWwcFSkLXoBZ5ms/gy5+M45qqcfAYRtHOktf99 M4m7/3IehZ3tudCQ== 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 DD8AD2C142; Tue, 7 Jun 2022 10:49:51 +0000 (UTC) From: Jiri Slaby To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 12/36] tty/vt: consolemap: use sizeof(*pointer) instead of sizeof(type) Date: Tue, 7 Jun 2022 12:49:22 +0200 Message-Id: <20220607104946.18710-12-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 It is preferred to use sizeof(*pointer) instead of sizeof(type). First, the type of the variable can change and one needs not change the former (unlike the latter). Second, the latter is error-prone due to (u16), (u16 *), and (u16 **) mixture here. Signed-off-by: Jiri Slaby --- drivers/tty/vt/consolemap.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index 097ab7d01f8b..79a62dcca046 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c @@ -251,12 +251,12 @@ static void set_inverse_trans_unicode(struct vc_data *conp, return; q = p->inverse_trans_unicode; if (!q) { - q = p->inverse_trans_unicode = - kmalloc_array(MAX_GLYPH, sizeof(u16), GFP_KERNEL); + q = p->inverse_trans_unicode = kmalloc_array(MAX_GLYPH, + sizeof(*q), GFP_KERNEL); if (!q) return; } - memset(q, 0, MAX_GLYPH * sizeof(u16)); + memset(q, 0, MAX_GLYPH * sizeof(*q)); for (i = 0; i < UNI_DIRS; i++) { p1 = p->uni_pgdir[i]; @@ -478,8 +478,8 @@ static int con_unify_unimap(struct vc_data *conp, struct uni_pagedict *p) continue; if (!p1[k] || !q1[k]) break; - if (memcmp(p1[k], q1[k], - UNI_ROW_GLYPHS * sizeof(u16))) + if (memcmp(p1[k], q1[k], UNI_ROW_GLYPHS * + sizeof(*p1[k]))) break; } if (k < UNI_DIR_ROWS) @@ -505,7 +505,7 @@ con_insert_unipair(struct uni_pagedict *p, u_short unicode, u_short fontpos) n = UNI_DIR(unicode); p1 = p->uni_pgdir[n]; if (!p1) { - p1 = p->uni_pgdir[n] = kcalloc(UNI_DIR_ROWS, sizeof(u16 *), + p1 = p->uni_pgdir[n] = kcalloc(UNI_DIR_ROWS, sizeof(*p1), GFP_KERNEL); if (!p1) return -ENOMEM; @@ -514,11 +514,12 @@ con_insert_unipair(struct uni_pagedict *p, u_short unicode, u_short fontpos) n = UNI_ROW(unicode); p2 = p1[n]; if (!p2) { - p2 = p1[n] = kmalloc_array(UNI_ROW_GLYPHS, sizeof(u16), GFP_KERNEL); + p2 = p1[n] = kmalloc_array(UNI_ROW_GLYPHS, sizeof(*p2), + GFP_KERNEL); if (!p2) return -ENOMEM; /* No glyphs for the characters (yet) */ - memset(p2, 0xff, UNI_ROW_GLYPHS * sizeof(u16)); + memset(p2, 0xff, UNI_ROW_GLYPHS * sizeof(*p2)); } p2[UNI_GLYPH(unicode)] = fontpos; @@ -571,7 +572,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list) if (!ct) return 0; - unilist = vmemdup_user(list, array_size(sizeof(struct unipair), ct)); + unilist = vmemdup_user(list, array_size(sizeof(*unilist), ct)); if (IS_ERR(unilist)) return PTR_ERR(unilist); @@ -771,7 +772,7 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni struct uni_pagedict *p; struct unipair *unilist; - unilist = kvmalloc_array(ct, sizeof(struct unipair), GFP_KERNEL); + unilist = kvmalloc_array(ct, sizeof(*unilist), GFP_KERNEL); if (!unilist) return -ENOMEM; @@ -800,7 +801,7 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni } } console_unlock(); - if (copy_to_user(list, unilist, min(ect, ct) * sizeof(struct unipair))) + if (copy_to_user(list, unilist, min(ect, ct) * sizeof(*unilist))) ret = -EFAULT; put_user(ect, uct); kvfree(unilist); -- 2.36.1