eBPF-based security platform
util: count the elements of an array with ARRAY_SIZE()
Daniel Borkmann64b13c4f466c
diff --git a/testing/helper/test-bpf-cmd.c b/testing/helper/test-bpf-cmd.cindex 10b463a5..0f858d78 100644--- a/testing/helper/test-bpf-cmd.c+++ b/testing/helper/test-bpf-cmd.c@@ -17,7 +17,7 @@#include <linux/bpf.h>-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))+#include <shirudo/misc.h>static const struct {const char *name;diff --git a/util/help.h b/util/help.hindex aa48fbbc..2822408b 100644--- a/util/help.h+++ b/util/help.h@@ -31,12 +31,12 @@ struct help_section {/* A section named h listing the items of the array a. */#define HELP_ITEMS(h, a) \{ .header = (h), .items = (a), \- .n_items = sizeof(a) / sizeof((a)[0]) + __must_be_array(a) }+ .n_items = ARRAY_SIZE(a) }/* A section named h listing the options of the opt_spec array a. */#define HELP_OPTIONS(h, a) \{ .header = (h), .options = (a), \- .n_options = sizeof(a) / sizeof((a)[0]) + __must_be_array(a) }+ .n_options = ARRAY_SIZE(a) }struct help {const char *usage;diff --git a/util/options.h b/util/options.hindex b25e4a77..aaf51f21 100644--- a/util/options.h+++ b/util/options.h@@ -72,9 +72,7 @@ void opt_init(struct opt_parser *p, const char *command,int first);#define OPT_INIT(p, command, specs, help, argc, argv, first) \- opt_init(p, command, specs, \- sizeof(specs) / sizeof((specs)[0]) + __must_be_array(specs), \- help, argc, argv, first)+ opt_init(p, command, specs, ARRAY_SIZE(specs), help, argc, argv, first)/** The index of the next option, with value set where it takes one, NULL@@ -113,9 +111,7 @@ int opt_choice(const struct opt_parser *p, const struct opt_name *names,size_t n, int *out) __must_check;#define OPT_CHOICE(p, names, out) \- opt_choice(p, names, \- sizeof(names) / sizeof((names)[0]) + __must_be_array(names), \- out)+ opt_choice(p, names, ARRAY_SIZE(names), out)/** Reports a usage error the command finds, as "<command>: <message>";