Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp268273rdb; Mon, 15 Jan 2024 22:19:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEp+f5jVvFHQy/hmzBbSjQic1+IL/ZflrDlixFGf+Ua+puSJrzDmBmD3EJdY3KPhL3vmHy X-Received: by 2002:a17:906:b241:b0:a2d:468c:3845 with SMTP id ce1-20020a170906b24100b00a2d468c3845mr4326954ejb.35.1705385979232; Mon, 15 Jan 2024 22:19:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705385979; cv=none; d=google.com; s=arc-20160816; b=nTshsag2NKZ2rKmTSwCW+E1Pd8v/euernbl6vfYEvF1L/WRlhupRTfhaU4uCAWylTb 9BNvxBJ1GM5VKZXXBuEQQOFdkEE+vUO4jSFOFFBy2MynVuBpHm7n8k6oSRe5UVwGEAmE bDSdbZ3iRNz0BwWL6qU7Lm3dEorV2F+IKqzMpA+YtZq/yFuKnjACZBaydLaP+/uWT9QF dhrbmwMJ4oj39sbNEJlKhJGfb7k8gZhEBA/18jUSlWZ7g7DcEYLhjDbC3+AsTopVYfzQ ch+rJRM7xZ33LBNqjlVcamQFKH8LVvay0jaJimtkMrRbnIwNob+0ZQ/huZk7812bW0Cs 3eNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=7DOfeLjtpCk4d/9pgsdV/oTKFMDo2bBdTT0TqGRKAaM=; fh=Pafr22NV4PuxoSMXxQV8c7w82xGNounbZvGMmt80iM0=; b=EZGI1u/slf5z5x5ZcOLjeKrSejtonBqOWuMnjMtN3wEaU5a+6QWsihVQamBOMDnrLf E/FWTfN0rM1jTYJT0NyOGLJS0kfQk2wzPJScojZo4N/fgPrOcI3zK2m5oQthczP9uP3H yGDDUtMUK2795qxuiczAdr7/4uH1DDjJBN9YS+2YfQ+qT/67uyk3vhV4orQauUkmZk2g +kdScr25sNcnitsziUam4x70ulXm4Ko7AkdkTgfN3ZD2T2o1dt6dSpjR3dWlc0xhia2S fTiNvlCfj/luICkIuxygJqfYdKjATHp+mnMNyF76Xzmo8vzLPT1FBQN/h6tdYN4UW8jY 6Flw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-27034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27034-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gg6-20020a170906e28600b00a2d9a37a0c4si1852613ejb.45.2024.01.15.22.19.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 22:19:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-27034-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27034-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F3ACB1F238E4 for ; Tue, 16 Jan 2024 06:19:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A1BE107B4; Tue, 16 Jan 2024 06:19:29 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A33C10971; Tue, 16 Jan 2024 06:19:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxnuvqH6ZlZJcAAA--.2712S3; Tue, 16 Jan 2024 14:19:22 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxLs_oH6ZlFG8DAA--.18029S2; Tue, 16 Jan 2024 14:19:21 +0800 (CST) From: Tiezhu Yang To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Quentin Monnet Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v1] bpftool: Silence build warning about calloc() Date: Tue, 16 Jan 2024 14:19:20 +0800 Message-ID: <20240116061920.31172-1-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID:AQAAf8BxLs_oH6ZlFG8DAA--.18029S2 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7Cry3Xw13Xr15urWxXF4DZFc_yoW8WF1kpa yfJryUtw18XFn8Z3W8GF43GrW3G3s3Ja92vaykt345XrWrWF95JF4UGFWFqFyY9r4DJa4f ZasFy3yUXrZ5XabCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk2b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv 67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUcVc_UUUUU There exists the following warning when building bpftool: CC prog.o prog.c: In function ‘profile_open_perf_events’: prog.c:2301:24: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 2301 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); | ^~~ prog.c:2301:24: note: earlier argument should specify number of elements, later size of each element Tested with the latest upstream GCC which contains a new warning option -Wcalloc-transposed-args. The first argument to calloc is documented to be number of elements in array, while the second argument is size of each element, just switch the first and second arguments of calloc() to silence the build warning, compile tested only. Fixes: 47c09d6a9f67 ("bpftool: Introduce "prog profile" command") Signed-off-by: Tiezhu Yang --- tools/bpf/bpftool/prog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index feb8e305804f..9cb42a3366c0 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -2298,7 +2298,7 @@ static int profile_open_perf_events(struct profiler_bpf *obj) int map_fd; profile_perf_events = calloc( - sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); + obj->rodata->num_cpu * obj->rodata->num_metric, sizeof(int)); if (!profile_perf_events) { p_err("failed to allocate memory for perf_event array: %s", strerror(errno)); -- 2.42.0