Skip to contentSkip to conversation

bpftool: replace sizeof(arr)/sizeof(arr[0]) with ARRAY_SIZE macro

PATCH Applied Rongguang Wei 3 participants 3 messages Jul 26, 2022 – Jul 29, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpftool: replace sizeof(arr)/sizeof(arr[0]) with ARRAY_SIZE macro

From: Rongguang Wei <[email protected]>

Use the ARRAY_SIZE macro and make the code more compact.

---
 tools/bpf/bpftool/prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/bpftool/prog.c +1 -1
index 5c2c63df92e8..1e7768aa7a0e 100644
@@ -1974,7 +1974,7 @@ static int profile_parse_metrics(int argc, char **argv)
 	int selected_cnt = 0;
 	unsigned int i;
 
-	metric_cnt = sizeof(metrics) / sizeof(struct profile_metric);
+	metric_cnt = ARRAY_SIZE(metrics);
 
 	while (argc > 0) {
 		for (i = 0; i < metric_cnt; i++) {
Signature · 1 line
2.25.1
#2 lore raw
In reply to Rongguang Wei
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 8 lines · On Tue, 26 Jul 2022 17:30:45 +0800 you wrote:

From: Rongguang Wei <[email protected]>

Use the ARRAY_SIZE macro and make the code more compact.

---
 tools/bpf/bpftool/prog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
- bpftool: replace sizeof(arr)/sizeof(arr[0]) with ARRAY_SIZE macro

    https://git.kernel.org/bpf/bpf-next/c/5eff8c18f124

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html