From patchwork Sun Jan 21 21:01:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 189841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2240449dyb; Sun, 21 Jan 2024 13:07:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYWdYm80rrqtbjXYMs5By7VulOk3zaLsSP7JLJcOLaO0+fFWUJQV0Bsy22wAhkoc6pjTRr X-Received: by 2002:a05:620a:a1a:b0:783:76ba:2179 with SMTP id i26-20020a05620a0a1a00b0078376ba2179mr4060624qka.63.1705871231009; Sun, 21 Jan 2024 13:07:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705871230; cv=pass; d=google.com; s=arc-20160816; b=fBTUZHHGhqgbCHjuH7igZFVbWjJ2agG6FzVGYkk7ySu1vgraAI5n09P2FmTCHnajWK qo7lOpawzsKQdCQR9RYZdl/QP0lD0SQD5KO3I7eSqEBHPGWalMhIejod5L0brlveJutx tqXXs0qW3qNb3tkMOvJ6kBr5TPNZ4m9NdXAgV/xmmzyzMhu1Zi8vONanhkToy5E0VfXI NKun833QLYILp0M3jT8EH61p2lEc5GacZpLUak4KcomQFtNThdIysfrKsctQYObLX+1z qehmFCpcpPc2IdELlblZQrNY87r/fq3oVcUMcpELGhC9plMYme/vcaGRHLRI5u0R51RG EF3Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=95+g6eNrwAEXW4baO5WOG0bfCGud2wwXs3GQhS7LtNU=; fh=dJd+3NRnVFvBaW/IXi0G9kHIpwH/063mGZ1m5fE8wt8=; b=VY1duTr30lE0LTrMotkoMUzC6q+KcULiZf/S4xpOW0QWBQByCunnxkpsZ9NeNdM9nb 0Rt0xYiOXU01W/TU+AK/wxCMfBbYVmNedvw4QG57BlErCXsTEp3HMeP7djLtuPmmn8Pd q6H30Nn0kIRqjsi7svAMCcDAH6IhAKkoPFzHBOv4YIBI57LhKk+E5fY2G+Yuu1A28Z7i Tfe01Pb12fYKQM7gKdDHwIDKPi+cIxYZt2DptPo4Zl6cKlgYxqVRsoRVNR3HezdwKhT3 j+bKjH09gDe4/3DNvS24TgN0WHW5nvtcmUXvNh6DIMXOqKtRrGkSPc/q2+6cOcd+rxL5 GXNw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h14-20020a05620a13ee00b007839b79566fsi1609273qkl.767.2024.01.21.13.07.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 13:07:10 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B61CE385803E for ; Sun, 21 Jan 2024 21:07:10 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 7A0723858407 for ; Sun, 21 Jan 2024 21:07:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A0723858407 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A0723858407 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.83.234.184 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705871223; cv=none; b=uxrwWq3BbGwg/xtre7zWHQ0B5CLP9tgjmUHdLgvK4wVJZ4UeS4oTYk6QGlyfwmhpCDL0V6qWmWKOXjGbiG7a9VwuF2Q7BAQ6qVJ20Fn4XnaT/Gv+CW6DcXRhHuKbaL/1anTJdw5pHZx+alfYgbAGASU3XQtV/sHZ4YOz7bqVxjc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705871223; c=relaxed/simple; bh=ICcNfU9h+l6A55rr+xwcFz5gLu+5uBGgTZmfopUpkMY=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=w/sSARMAjnI2ppBjj/zcFY7iT8QA1SWRvYoqCYCIOPQilRFVrg8xunUw4zC+ham/BePDnCw3Y4gbVlLkSnAGLH4q/k9NGqd33dLdOLW3xMpWI2RYJ82YqkJtlmwYUF96/F1vsd2OKp8wJPjalxpCH32Q46e1Ku7voonFjCOBEMw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from csb.redhat.com (deer0x03.wildebeest.org [172.31.17.133]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 63D84302BBEA; Sun, 21 Jan 2024 22:06:59 +0100 (CET) Received: by csb.redhat.com (Postfix, from userid 10916) id D99C4CEF2C; Sun, 21 Jan 2024 22:06:58 +0100 (CET) From: Mark Wielaard To: binutils@sourceware.org Cc: Mark Wielaard Subject: [PATCH] opcodes: tic4x_disassemble swap xcalloc arguments Date: Sun, 21 Jan 2024 22:01:42 +0100 Message-Id: <20240121210142.568900-1-mark@klomp.org> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, 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 server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788735631958306160 X-GMAIL-MSGID: 1788735631958306160 GCC 14 will detect when the size and count arguments of calloc are swapped. binutils-gdb/opcodes/tic4x-dis.c: In function ‘tic4x_disassemble’: binutils-gdb/opcodes/tic4x-dis.c:710:32: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 710 | optab = xcalloc (sizeof (tic4x_inst_t *), (1 << TIC4X_HASH_SIZE)); | ^~~~~~~~~~~~ binutils-gdb/opcodes/tic4x-dis.c:710:32: note: earlier argument should specify number of elements, later size of each element binutils-gdb/opcodes/tic4x-dis.c:712:40: error: ‘xcalloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 712 | optab_special = xcalloc (sizeof (tic4x_inst_t *), TIC4X_SPESOP_SIZE); | ^~~~~~~~~~~~ binutils-gdb/opcodes/tic4x-dis.c:712:40: note: earlier argument should specify number of elements, later size of each element opcodes/ChangeLog: * /tic4x-dis.c (tic4x_disassemble): Swap size and count xcalloc arguments. --- opcodes/tic4x-dis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opcodes/tic4x-dis.c b/opcodes/tic4x-dis.c index 49de510981b..0c703ecf08a 100644 --- a/opcodes/tic4x-dis.c +++ b/opcodes/tic4x-dis.c @@ -707,9 +707,9 @@ tic4x_disassemble (unsigned long pc, if (optab == NULL) { - optab = xcalloc (sizeof (tic4x_inst_t *), (1 << TIC4X_HASH_SIZE)); + optab = xcalloc ((1 << TIC4X_HASH_SIZE), sizeof (tic4x_inst_t *)); - optab_special = xcalloc (sizeof (tic4x_inst_t *), TIC4X_SPESOP_SIZE); + optab_special = xcalloc (TIC4X_SPESOP_SIZE, sizeof (tic4x_inst_t *)); /* Install opcodes in reverse order so that preferred forms overwrite synonyms. */