BPF List
 help / color / mirror / Atom feed
* [PATCH] bpftool: replace sizeof(arr)/sizeof(arr[0]) with ARRAY_SIZE macro
@ 2022-07-26  9:30 Rongguang Wei
  2022-07-27 21:03 ` Quentin Monnet
  2022-07-29 17:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Rongguang Wei @ 2022-07-26  9:30 UTC (permalink / raw)
  To: quentin, ast; +Cc: bpf, Rongguang Wei

From: Rongguang Wei <weirongguang@kylinos.cn>

Use the ARRAY_SIZE macro and make the code more compact.

Signed-off-by: Rongguang Wei <weirongguang@kylinos.cn>
---
 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 5c2c63df92e8..1e7768aa7a0e 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -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++) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-29 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-26  9:30 [PATCH] bpftool: replace sizeof(arr)/sizeof(arr[0]) with ARRAY_SIZE macro Rongguang Wei
2022-07-27 21:03 ` Quentin Monnet
2022-07-29 17:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox