summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2007-06-25 10:55:35 +0000
committerDenis Vlasenko2007-06-25 10:55:35 +0000
commit80b8b39899a09c7516920cda5fd343b3086d4824 (patch)
treeaa9903fd6b64d19c5f640fa302272d85c92b204e
parent1399282b47bb218132a554cbe5b2b0ce4dcc055f (diff)
downloadbusybox-80b8b39899a09c7516920cda5fd343b3086d4824.zip
busybox-80b8b39899a09c7516920cda5fd343b3086d4824.tar.gz
Consolidate ARRAY_SIZE macro; remove one unneeded global var (walter harms <wharms@bfs.de>)
-rw-r--r--applets/applets.c3
-rw-r--r--coreutils/od_bloaty.c2
-rw-r--r--coreutils/stty.c4
-rw-r--r--coreutils/test.c3
-rw-r--r--editors/awk.c4
-rw-r--r--editors/vi.c3
-rw-r--r--include/libbb.h3
-rw-r--r--libbb/speed_table.c2
-rw-r--r--libbb/u_signal_names.c4
-rw-r--r--miscutils/crond.c5
-rw-r--r--modutils/insmod.c4
-rw-r--r--networking/httpd.c5
-rw-r--r--networking/ifconfig.c2
-rw-r--r--networking/ifupdown.c12
-rw-r--r--networking/libiproute/ll_proto.c4
-rw-r--r--networking/libiproute/ll_types.c2
-rw-r--r--networking/tftp.c4
-rw-r--r--procps/ps.c4
-rw-r--r--shell/ash.c13
-rw-r--r--shell/hush.c4
-rw-r--r--shell/lash.c4
-rw-r--r--shell/msh.c6
-rw-r--r--util-linux/fdisk.c2
-rw-r--r--util-linux/fdisk_osf.c7
-rw-r--r--util-linux/fdisk_sun.c10
-rw-r--r--util-linux/mount.c5
26 files changed, 55 insertions, 66 deletions
diff --git a/applets/applets.c b/applets/applets.c
index cff792f..57c972f 100644
--- a/applets/applets.c
+++ b/applets/applets.c
@@ -47,7 +47,6 @@ static const char usage_messages[] = ""
/* Define struct bb_applet applets[] */
#include "applets.h"
/* The -1 arises because of the {0,NULL,0,-1} entry. */
-const unsigned short NUM_APPLETS = sizeof(applets) / sizeof(applets[0]) - 1;
const struct bb_applet *current_applet;
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
@@ -488,7 +487,7 @@ static int applet_name_compare(const void *name, const void *vapplet)
const struct bb_applet *find_applet_by_name(const char *name)
{
/* Do a binary search to find the applet entry given the name. */
- return bsearch(name, applets, NUM_APPLETS, sizeof(applets[0]),
+ return bsearch(name, applets, ARRAY_SIZE(applets)-1, sizeof(applets[0]),
applet_name_compare);
}
diff --git a/coreutils/od_bloaty.c b/coreutils/od_bloaty.c
index 3250856..af5eba9 100644
--- a/coreutils/od_bloaty.c
+++ b/coreutils/od_bloaty.c
@@ -158,7 +158,7 @@ static const signed char width_bytes[] = {
initializer in the width_bytes array. */
struct dummy {
int assert_width_bytes_matches_size_spec_decl
- [sizeof width_bytes / sizeof width_bytes[0] == N_SIZE_SPECS ? 1 : -1];
+ [ARRAY_SIZE(width_bytes) == N_SIZE_SPECS ? 1 : -1];
};
static size_t string_min;
diff --git a/coreutils/stty.c b/coreutils/stty.c
index e6d054f..0983532 100644
--- a/coreutils/stty.c
+++ b/coreutils/stty.c
@@ -319,7 +319,7 @@ static const struct mode_info mode_info[] = {
};
enum {
- NUM_mode_info = (sizeof(mode_info) / sizeof(mode_info[0]))
+ NUM_mode_info = ARRAY_SIZE(mode_info)
};
/* Control character settings */
@@ -371,7 +371,7 @@ static const struct control_info control_info[] = {
};
enum {
- NUM_control_info = (sizeof(control_info) / sizeof(control_info[0]))
+ NUM_control_info = ARRAY_SIZE(control_info)
};
/* The width of the screen, for output wrapping */
diff --git a/coreutils/test.c b/coreutils/test.c
index 36fb38a..7b87a42 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -146,7 +146,6 @@ static const struct t_op {
{ ")" , RPAREN , PAREN },
};
-enum { NUM_OPS = sizeof(ops) / sizeof(ops[0]) };
#if ENABLE_FEATURE_TEST_64
typedef int64_t arith_t;
@@ -471,7 +470,7 @@ static enum token t_lex(char *s)
return op->op_num;
}
op++;
- } while (op < ops + NUM_OPS);
+ } while (op < ops + ARRAY_SIZE(ops));
return OPERAND;
}
diff --git a/editors/awk.c b/editors/awk.c
index 90ba643..940a794 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -390,7 +390,7 @@ static const char vValues[] =
/* hash size may grow to these values */
#define FIRST_PRIME 61;
static const unsigned PRIMES[] = { 251, 1021, 4093, 16381, 65521 };
-enum { NPRIMES = sizeof(PRIMES) / sizeof(PRIMES[0]) };
+
/* Globals. Split in two parts so that first one is addressed
@@ -570,7 +570,7 @@ static void hash_rebuild(xhash *hash)
unsigned newsize, i, idx;
hash_item **newitems, *hi, *thi;
- if (hash->nprime == NPRIMES)
+ if (hash->nprime == ARRAY_SIZE(PRIMES))
return;
newsize = PRIMES[hash->nprime++];
diff --git a/editors/vi.c b/editors/vi.c
index b961ca5..01d45e5 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2230,8 +2230,7 @@ static char readit(void) // read (maybe cursor) key from stdin
{"[13~", VI_K_FUN3}, // Function Key F3
{"[14~", VI_K_FUN4}, // Function Key F4
};
-
-#define ESCCMDS_COUNT (sizeof(esccmds)/sizeof(struct esc_cmds))
+ enum { ESCCMDS_COUNT = ARRAY_SIZE(esccmds) };
alarm(0); // turn alarm OFF while we wait for input
fflush(stdout);
diff --git a/include/libbb.h b/include/libbb.h
index b7b0657..3cdf28f 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1071,4 +1071,7 @@ extern const char bb_default_login_shell[];
#include <dmalloc.h>
#endif
+
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+
#endif /* __LIBBUSYBOX_H__ */
diff --git a/libbb/speed_table.c b/libbb/speed_table.c
index 6137b77..0f0b33d 100644
--- a/libbb/speed_table.c
+++ b/libbb/speed_table.c
@@ -54,7 +54,7 @@ static const struct speed_map speeds[] = {
#endif
};
-enum { NUM_SPEEDS = (sizeof(speeds) / sizeof(struct speed_map)) };
+enum { NUM_SPEEDS = ARRAY_SIZE(speeds) };
unsigned int tty_baud_to_value(speed_t speed)
{
diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c
index dc4c0b2..f8eaea7 100644
--- a/libbb/u_signal_names.c
+++ b/libbb/u_signal_names.c
@@ -127,7 +127,7 @@ int get_signum(const char *name)
return i;
if (strncasecmp(name, "SIG", 3) == 0)
name += 3;
- for (i = 0; i < sizeof(signals) / sizeof(signals[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(signals); i++)
if (strcasecmp(name, signals[i]) == 0)
return i;
@@ -152,7 +152,7 @@ int get_signum(const char *name)
const char *get_signame(int number)
{
- if ((unsigned)number < sizeof(signals) / sizeof(signals[0])) {
+ if ((unsigned)number < ARRAY_SIZE(signals)) {
if (signals[number][0]) /* if it's not an empty str */
return signals[number];
}
diff --git a/miscutils/crond.c b/miscutils/crond.c
index a490d41..5653f68 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -15,7 +15,6 @@
#include "libbb.h"
#include <sys/syslog.h>
-#define arysize(ary) (sizeof(ary)/sizeof((ary)[0]))
#ifndef CRONTABS
#define CRONTABS "/var/spool/cron/crontabs"
@@ -468,13 +467,13 @@ static void FixDayDow(CronLine * line)
int weekUsed = 0;
int daysUsed = 0;
- for (i = 0; i < (int)(arysize(line->cl_Dow)); ++i) {
+ for (i = 0; i < (int)(ARRAY_SIZE(line->cl_Dow)); ++i) {
if (line->cl_Dow[i] == 0) {
weekUsed = 1;
break;
}
}
- for (i = 0; i < (int)(arysize(line->cl_Days)); ++i) {
+ for (i = 0; i < (int)(ARRAY_SIZE(line->cl_Days)); ++i) {
if (line->cl_Days[i] == 0) {
daysUsed = 1;
break;
diff --git a/modutils/insmod.c b/modutils/insmod.c
index cba8dc4..8a6cc05 100644
--- a/modutils/insmod.c
+++ b/modutils/insmod.c
@@ -3632,7 +3632,7 @@ static int obj_gpl_license(struct obj_file *f, const char **license)
int i;
if (license)
*license = value+1;
- for (i = 0; i < sizeof(gpl_licenses)/sizeof(gpl_licenses[0]); ++i) {
+ for (i = 0; i < ARRAY_SIZE(gpl_licenses); ++i) {
if (strcmp(value+1, gpl_licenses[i]) == 0)
return 0;
}
@@ -3833,7 +3833,7 @@ add_ksymoops_symbols(struct obj_file *f, const char *filename,
#endif /* _NOT_SUPPORTED_ */
/* tag the desired sections if size is non-zero */
- for (i = 0; i < sizeof(section_names)/sizeof(section_names[0]); ++i) {
+ for (i = 0; i < ARRAY_SIZE(section_names); ++i) {
sec = obj_find_section(f, section_names[i]);
if (sec && sec->header.sh_size) {
l = sizeof(symprefix)+ /* "__insmod_" */
diff --git a/networking/httpd.c b/networking/httpd.c
index 8c0a83e..383a006 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -878,11 +878,8 @@ static int sendHeaders(HttpResponseNum responseNum)
time_t timer = time(0);
char timeStr[80];
int len;
- enum {
- numNames = sizeof(httpResponseNames) / sizeof(httpResponseNames[0])
- };
- for (i = 0; i < numNames; i++) {
+ for (i = 0; i < ARRAY_SIZE(httpResponseNames); i++) {
if (httpResponseNames[i].type == responseNum) {
responseString = httpResponseNames[i].name;
infoString = httpResponseNames[i].info;
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index 5742399..5e11b2b 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -337,7 +337,7 @@ int ifconfig_main(int argc, char **argv)
}
/* We fell through, so treat as possible hostname. */
- a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1;
+ a1op = Arg1Opt + ARRAY_SIZE(Arg1Opt) - 1;
mask = op->arg_flags;
goto HOSTNAME;
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 2b748f1..8843184 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -375,7 +375,7 @@ static const struct method_t methods6[] = {
static const struct address_family_t addr_inet6 = {
"inet6",
- sizeof(methods6) / sizeof(struct method_t),
+ ARRAY_SIZE(methods6),
methods6
};
#endif /* FEATURE_IFUPDOWN_IPV6 */
@@ -471,8 +471,8 @@ static const struct dhcp_client_t ext_dhcp_clients[] = {
static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
{
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
- int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
- for (i = 0; i < nclients; i++) {
+ int i ;
+ for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
if (exists_execable(ext_dhcp_clients[i].name))
return execute(ext_dhcp_clients[i].startcmd, ifd, exec);
}
@@ -490,8 +490,8 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
{
#if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP
- int i, nclients = sizeof(ext_dhcp_clients) / sizeof(ext_dhcp_clients[0]);
- for (i = 0; i < nclients; i++) {
+ int i ;
+ for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
if (exists_execable(ext_dhcp_clients[i].name))
return execute(ext_dhcp_clients[i].stopcmd, ifd, exec);
}
@@ -551,7 +551,7 @@ static const struct method_t methods[] = {
static const struct address_family_t addr_inet = {
"inet",
- sizeof(methods) / sizeof(methods[0]),
+ ARRAY_SIZE(methods),
methods
};
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c
index 10d7498..4e62e87 100644
--- a/networking/libiproute/ll_proto.c
+++ b/networking/libiproute/ll_proto.c
@@ -96,7 +96,7 @@ const char * ll_proto_n2a(unsigned short id, char *buf, int len)
id = ntohs(id);
- for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) {
+ for (i=0; i < ARRAY_SIZE(llproto_names); i++) {
if (llproto_names[i].id == id)
return llproto_names[i].name;
}
@@ -107,7 +107,7 @@ const char * ll_proto_n2a(unsigned short id, char *buf, int len)
int ll_proto_a2n(unsigned short *id, char *buf)
{
int i;
- for (i=0; i<sizeof(llproto_names)/sizeof(llproto_names[0]); i++) {
+ for (i=0; i < ARRAY_SIZE(llproto_names); i++) {
if (strcasecmp(llproto_names[i].name, buf) == 0) {
*id = htons(llproto_names[i].id);
return 0;
diff --git a/networking/libiproute/ll_types.c b/networking/libiproute/ll_types.c
index 5d2843b..84fd628 100644
--- a/networking/libiproute/ll_types.c
+++ b/networking/libiproute/ll_types.c
@@ -108,7 +108,7 @@ __PF(VOID,void)
#undef __PF
int i;
- for (i = 0; i < sizeof(arphrd_names)/sizeof(arphrd_names[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(arphrd_names); i++) {
if (arphrd_names[i].type == type)
return arphrd_names[i].name;
}
diff --git a/networking/tftp.c b/networking/tftp.c
index 8517830..b20486c 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -280,13 +280,13 @@ static int tftp( USE_GETPUT(const int cmd,)
"no such user",
"bad option",
};
- enum { NUM_ERRCODE = sizeof(errcode_str) / sizeof(errcode_str[0]) };
+
const char *msg = "";
if (rbuf[4] != '\0') {
msg = &rbuf[4];
rbuf[tftp_bufsize - 1] = '\0';
- } else if (recv_blk < NUM_ERRCODE) {
+ } else if (recv_blk < ARRAY_SIZE(errcode_str)) {
msg = errcode_str[recv_blk];
}
bb_error_msg("server error: (%u) %s", recv_blk, msg);
diff --git a/procps/ps.c b/procps/ps.c
index fd53eca..003e8ea 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -134,8 +134,6 @@ static const ps_out_t out_spec[] = {
#endif
};
-#define VEC_SIZE(v) ( sizeof(v) / sizeof((v)[0]) )
-
#if ENABLE_SELINUX
#define SELINIX_O_PREFIX "label,"
#define DEFAULT_O_STR SELINIX_O_PREFIX "pid,user" /* TODO: ,vsz,stat */ ",args"
@@ -171,7 +169,7 @@ static ps_out_t* new_out_t(void)
static const ps_out_t* find_out_spec(const char *name)
{
int i;
- for (i = 0; i < VEC_SIZE(out_spec); i++) {
+ for (i = 0; i < ARRAY_SIZE(out_spec); i++) {
if (!strcmp(name, out_spec[i].name))
return &out_spec[i];
}
diff --git a/shell/ash.c b/shell/ash.c
index b54f666..d9fe641 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -101,7 +101,7 @@ static const char *const optletters_optnames[] = {
#define optletters(n) optletters_optnames[(n)][0]
#define optnames(n) (&optletters_optnames[(n)][1])
-#define NOPTS (sizeof(optletters_optnames)/sizeof(optletters_optnames[0]))
+enum { NOPTS = ARRAY_SIZE(optletters_optnames) };
static char optlist[NOPTS];
@@ -1837,7 +1837,7 @@ initvar(void)
vps1.text = "PS1=# ";
#endif
vp = varinit;
- end = vp + sizeof(varinit) / sizeof(varinit[0]);
+ end = vp + ARRAY_SIZE(varinit);
do {
vpp = hashvar(vp->text);
vp->next = *vpp;
@@ -6876,8 +6876,8 @@ static const char *const *
findkwd(const char *s)
{
return bsearch(s, tokname_array + KWDOFFSET,
- (sizeof(tokname_array) / sizeof(char *)) - KWDOFFSET,
- sizeof(char *), pstrcmp);
+ ARRAY_SIZE(tokname_array) - KWDOFFSET,
+ sizeof(tokname_array[0]), pstrcmp);
}
/*
@@ -8094,7 +8094,6 @@ static const struct builtincmd builtintab[] = {
{ BUILTIN_REGULAR "wait", waitcmd },
};
-#define NUMBUILTINS (sizeof(builtintab) / sizeof(builtintab[0]))
#define COMMANDCMD (builtintab + 5 + \
2 * ENABLE_ASH_BUILTIN_TEST + \
@@ -8116,7 +8115,7 @@ find_builtin(const char *name)
struct builtincmd *bp;
bp = bsearch(
- name, builtintab, NUMBUILTINS, sizeof(builtintab[0]),
+ name, builtintab, ARRAY_SIZE(builtintab), sizeof(builtintab[0]),
pstrcmp
);
return bp;
@@ -11255,7 +11254,7 @@ helpcmd(int argc, char **argv)
int col, i;
out1fmt("\nBuilt-in commands:\n-------------------\n");
- for (col = 0, i = 0; i < NUMBUILTINS; i++) {
+ for (col = 0, i = 0; i < ARRAY_SIZE(builtintab) ; i++) {
col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '),
builtintab[i].name + 1);
if (col > 60) {
diff --git a/shell/hush.c b/shell/hush.c
index a446bbe..275b69e 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -2889,10 +2889,10 @@ static int reserved_word(o_string *dest, struct p_context *ctx)
{ "done", RES_DONE, FLAG_END }
#endif
};
- enum { NRES = sizeof(reserved_list)/sizeof(reserved_list[0]) };
+
const struct reserved_combo *r;
- for (r = reserved_list; r < reserved_list + NRES; r++) {
+ for (r = reserved_list; r < reserved_list + ARRAY_SIZE(reserved_list); r++) {
if (strcmp(dest->data, r->literal) != 0)
continue;
debug_printf("found reserved word %s, code %d\n", r->literal, r->code);
diff --git a/shell/lash.c b/shell/lash.c
index 4e8b237..e5c7ef6 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -146,8 +146,8 @@ static const struct built_in_command bltins[] = {
/* to do: add ulimit */
};
-#define VEC_SIZE(v) (sizeof(v)/sizeof(v[0]))
-#define VEC_LAST(v) v[VEC_SIZE(v)-1]
+
+#define VEC_LAST(v) v[ARRAY_SIZE(v)-1]
static int shell_context; /* Type prompt trigger (PS1 or PS2) */
diff --git a/shell/msh.c b/shell/msh.c
index 2328e07..effdc01 100644
--- a/shell/msh.c
+++ b/shell/msh.c
@@ -596,7 +596,7 @@ static const char * const signame[] = {
"Terminated",
};
-#define NSIGNAL (sizeof(signame)/sizeof(signame[0]))
+
struct res {
const char *r_name;
@@ -2997,7 +2997,7 @@ static int waitfor(int lastpid, int canintr)
} else {
rv = WAITSIG(s);
if (rv != 0) {
- if (rv < NSIGNAL) {
+ if (rv < ARRAY_SIZE(signame)) {
if (signame[rv] != NULL) {
if (pid != lastpid) {
prn(pid);
@@ -3016,7 +3016,7 @@ static int waitfor(int lastpid, int canintr)
}
if (WAITCORE(s))
prs(" - core dumped");
- if (rv >= NSIGNAL || signame[rv])
+ if (rv >= ARRAY_SIZE(signame) || signame[rv])
prs("\n");
rv = -1;
} else
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 4ecbadf..8707891 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -20,8 +20,6 @@
# define USE_FEATURE_FDISK_BLKSIZE(a)
#endif
-#define SIZE(a) (sizeof(a)/sizeof((a)[0]))
-
#define DEFAULT_SECTOR_SIZE 512
#define MAX_SECTOR_SIZE 2048
#define SECTOR_SIZE 512 /* still used in osf/sgi/sun code */
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
index afb8459..9f0dc7f 100644
--- a/util-linux/fdisk_osf.c
+++ b/util-linux/fdisk_osf.c
@@ -163,7 +163,7 @@ static const char * const xbsd_dktypenames[] = {
"floppy",
0
};
-#define BSD_DKMAXTYPES (sizeof(xbsd_dktypenames) / sizeof(xbsd_dktypenames[0]) - 1)
+
/*
* Filesystem type and version.
@@ -219,7 +219,6 @@ static const char *const xbsd_fstypes[] = {
"\x10" "AdvFS", /* BSD_FS_ADVFS */
NULL
};
-#define BSD_FSMAXTYPES (SIZE(xbsd_fstypes)-1)
/*
@@ -509,7 +508,7 @@ xbsd_print_disklabel(int show_all)
#else
printf("# %s:\n", partname(disk_device, xbsd_part_index+1, 0));
#endif
- if ((unsigned) lp->d_type < BSD_DKMAXTYPES)
+ if ((unsigned) lp->d_type < ARRAY_SIZE(xbsd_dktypenames)-1)
printf("type: %s\n", xbsd_dktypenames[lp->d_type]);
else
printf("type: %d\n", lp->d_type);
@@ -571,7 +570,7 @@ xbsd_print_disklabel(int show_all)
);
}
- if ((unsigned) pp->p_fstype < BSD_FSMAXTYPES)
+ if ((unsigned) pp->p_fstype < ARRAY_SIZE(xbsd_fstypes)-1)
printf("%8.8s", xbsd_fstypes[pp->p_fstype]);
else
printf("%8x", pp->p_fstype);
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index 2fa7b2b..d4614fd 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -207,7 +207,7 @@ sun_autoconfigure_scsi(void)
if (!q)
break;
*q = '\0';
- for (i = 0; i < SIZE(sun_drives); i++) {
+ for (i = 0; i < ARRAY_SIZE(sun_drives); i++) {
if (*sun_drives[i].vendor && strcasecmp(sun_drives[i].vendor, vendor))
continue;
if (!strstr(model, sun_drives[i].model))
@@ -244,7 +244,7 @@ create_sunlabel(void)
puts("Drive type\n"
" ? auto configure\n"
" 0 custom (with hardware detected defaults)");
- for (i = 0; i < SIZE(sun_drives); i++) {
+ for (i = 0; i < ARRAY_SIZE(sun_drives); i++) {
printf(" %c %s%s%s\n",
i + 'a', sun_drives[i].vendor,
(*sun_drives[i].vendor) ? " " : "",
@@ -255,11 +255,11 @@ create_sunlabel(void)
if (c == '0') {
break;
}
- if (c >= 'a' && c < 'a' + SIZE(sun_drives)) {
+ if (c >= 'a' && c < 'a' + ARRAY_SIZE(sun_drives)) {
p = sun_drives + c - 'a';
break;
}
- if (c >= 'A' && c < 'A' + SIZE(sun_drives)) {
+ if (c >= 'A' && c < 'A' + ARRAY_SIZE(sun_drives)) {
p = sun_drives + c - 'A';
break;
}
@@ -446,7 +446,7 @@ verify_sun(void)
else
array[i] = -1;
}
- qsort(array,SIZE(array),sizeof(array[0]),
+ qsort(array, ARRAY_SIZE(array), sizeof(array[0]),
(int (*)(const void *,const void *)) verify_sun_cmp);
if (array[0] == -1) {
printf("No partitions defined\n");
diff --git a/util-linux/mount.c b/util-linux/mount.c
index fe2f1d9..4dd1a85 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -120,7 +120,6 @@ struct {
{"remount", MS_REMOUNT}, // action flag
};
-#define VECTOR_SIZE(v) (sizeof(v) / sizeof((v)[0]))
/* Append mount options to string */
static void append_mount_options(char **oldopts, const char *newopts)
@@ -168,7 +167,7 @@ static int parse_mount_options(char *options, char **unrecognized)
if (comma) *comma = 0;
// Find this option in mount_options
- for (i = 0; i < VECTOR_SIZE(mount_options); i++) {
+ for (i = 0; i < ARRAY_SIZE(mount_options); i++) {
if (!strcasecmp(mount_options[i].name, options)) {
long fl = mount_options[i].flags;
if (fl < 0) flags &= fl;
@@ -177,7 +176,7 @@ static int parse_mount_options(char *options, char **unrecognized)
}
}
// If unrecognized not NULL, append unrecognized mount options */
- if (unrecognized && i == VECTOR_SIZE(mount_options)) {
+ if (unrecognized && i == ARRAY_SIZE(mount_options)) {
// Add it to strflags, to pass on to kernel
i = *unrecognized ? strlen(*unrecognized) : 0;
*unrecognized = xrealloc(*unrecognized, i+strlen(options)+2);