summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libudev/libudev-monitor.c2
-rw-r--r--src/libudev/libudev-private.h1
-rw-r--r--src/udev/udev-builtin-firmware.c2
-rw-r--r--src/udev/udev-builtin.c10
-rw-r--r--src/udev/udev-event.c6
-rw-r--r--src/udev/udev-rules.c4
-rw-r--r--src/udev/udevadm-info.c2
-rw-r--r--src/udev/udevadm-monitor.c2
-rw-r--r--src/udev/udevadm.c4
-rw-r--r--src/udev/udevd.c6
10 files changed, 19 insertions, 20 deletions
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c
index a6efd9758c..73a9c48993 100644
--- a/src/libudev/libudev-monitor.c
+++ b/src/libudev/libudev-monitor.c
@@ -296,7 +296,7 @@ _public_ int udev_monitor_filter_update(struct udev_monitor *udev_monitor)
/* matched, pass packet */
bpf_stmt(ins, &i, BPF_RET|BPF_K, 0xffffffff);
- if (i+1 >= ARRAY_SIZE(ins))
+ if (i+1 >= ELEMENTSOF(ins))
return -1;
}
diff --git a/src/libudev/libudev-private.h b/src/libudev/libudev-private.h
index d914aa4599..91f92264dd 100644
--- a/src/libudev/libudev-private.h
+++ b/src/libudev/libudev-private.h
@@ -19,7 +19,6 @@
#include "macro.h"
#include "libudev.h"
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define READ_END 0
#define WRITE_END 1
diff --git a/src/udev/udev-builtin-firmware.c b/src/udev/udev-builtin-firmware.c
index 146a57706f..5ba712c89d 100644
--- a/src/udev/udev-builtin-firmware.c
+++ b/src/udev/udev-builtin-firmware.c
@@ -99,7 +99,7 @@ static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], boo
/* lookup firmware file */
uname(&kernel);
- for (i = 0; i < ARRAY_SIZE(searchpath); i++) {
+ for (i = 0; i < ELEMENTSOF(searchpath); i++) {
util_strscpyl(fwpath, sizeof(fwpath), searchpath[i], kernel.release, "/", firmware, NULL);
fwfile = fopen(fwpath, "re");
if (fwfile != NULL)
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index 508a22ecf8..b8cdc708bc 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -44,7 +44,7 @@ int udev_builtin_init(struct udev *udev)
unsigned int i;
int err;
- for (i = 0; i < ARRAY_SIZE(builtins); i++) {
+ for (i = 0; i < ELEMENTSOF(builtins); i++) {
if (builtins[i]->init) {
err = builtins[i]->init(udev);
if (err < 0)
@@ -58,7 +58,7 @@ void udev_builtin_exit(struct udev *udev)
{
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(builtins); i++)
+ for (i = 0; i < ELEMENTSOF(builtins); i++)
if (builtins[i]->exit)
builtins[i]->exit(udev);
}
@@ -68,7 +68,7 @@ bool udev_builtin_validate(struct udev *udev)
unsigned int i;
bool change = false;
- for (i = 0; i < ARRAY_SIZE(builtins); i++)
+ for (i = 0; i < ELEMENTSOF(builtins); i++)
if (builtins[i]->validate)
if (builtins[i]->validate(udev))
change = true;
@@ -79,7 +79,7 @@ void udev_builtin_list(struct udev *udev)
{
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(builtins); i++)
+ for (i = 0; i < ELEMENTSOF(builtins); i++)
fprintf(stderr, " %-12s %s\n", builtins[i]->name, builtins[i]->help);
}
@@ -103,7 +103,7 @@ enum udev_builtin_cmd udev_builtin_lookup(const char *command)
pos = strchr(name, ' ');
if (pos)
pos[0] = '\0';
- for (i = 0; i < ARRAY_SIZE(builtins); i++)
+ for (i = 0; i < ELEMENTSOF(builtins); i++)
if (strcmp(builtins[i]->name, name) == 0)
return i;
return UDEV_BUILTIN_MAX;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index bea316c18e..eab1bae27f 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -132,7 +132,7 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char *
goto copy;
}
- for (i = 0; i < ARRAY_SIZE(map); i++) {
+ for (i = 0; i < ELEMENTSOF(map); i++) {
if (strncmp(&from[1], map[i].name, strlen(map[i].name)) == 0) {
type = map[i].type;
from += strlen(map[i].name)+1;
@@ -148,7 +148,7 @@ size_t udev_event_apply_format(struct udev_event *event, const char *src, char *
goto copy;
}
- for (i = 0; i < ARRAY_SIZE(map); i++) {
+ for (i = 0; i < ELEMENTSOF(map); i++) {
if (from[1] == map[i].fmt) {
type = map[i].type;
from += 2;
@@ -486,7 +486,7 @@ static void spawn_read(struct udev_event *event,
timeout = -1;
}
- fdcount = epoll_wait(fd_ep, ev, ARRAY_SIZE(ev), timeout);
+ fdcount = epoll_wait(fd_ep, ev, ELEMENTSOF(ev), timeout);
if (fdcount < 0) {
if (errno == EINTR)
continue;
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 4e85760bd4..55d7e30c02 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1131,7 +1131,7 @@ static int rule_add_key(struct rule_tmp *rule_tmp, enum token_type type,
token->key.type = type;
token->key.op = op;
rule_tmp->token_cur++;
- if (rule_tmp->token_cur >= ARRAY_SIZE(rule_tmp->token)) {
+ if (rule_tmp->token_cur >= ELEMENTSOF(rule_tmp->token)) {
log_error("temporary rule array too small\n");
return -1;
}
@@ -1344,7 +1344,7 @@ static int add_rule(struct udev_rules *rules, char *line,
};
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(blacklist); i++)
+ for (i = 0; i < ELEMENTSOF(blacklist); i++)
if (strcmp(attr, blacklist[i]) == 0) {
log_error("invalid ENV attribute, '%s' can not be set %s:%u\n", attr, filename, lineno);
continue;
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index f392818c83..39221b7374 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -44,7 +44,7 @@ static bool skip_attribute(const char *name)
};
unsigned int i;
- for (i = 0; i < ARRAY_SIZE(skip); i++)
+ for (i = 0; i < ELEMENTSOF(skip); i++)
if (strcmp(name, skip[i]) == 0)
return true;
return false;
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index 6a202f04ca..1a6f71a465 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -253,7 +253,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
struct epoll_event ev[4];
int i;
- fdcount = epoll_wait(fd_ep, ev, ARRAY_SIZE(ev), -1);
+ fdcount = epoll_wait(fd_ep, ev, ELEMENTSOF(ev), -1);
if (fdcount < 0) {
if (errno != EINTR)
fprintf(stderr, "error receiving uevent message: %m\n");
diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c
index 55b5948aae..0858c37be8 100644
--- a/src/udev/udevadm.c
+++ b/src/udev/udevadm.c
@@ -67,7 +67,7 @@ static int adm_help(struct udev *udev, int argc, char *argv[])
unsigned int i;
fprintf(stderr, "Usage: udevadm [--help] [--version] [--debug] COMMAND [COMMAND OPTIONS]\n");
- for (i = 0; i < ARRAY_SIZE(udevadm_cmds); i++)
+ for (i = 0; i < ELEMENTSOF(udevadm_cmds); i++)
if (udevadm_cmds[i]->help != NULL)
printf(" %-12s %s\n", udevadm_cmds[i]->name, udevadm_cmds[i]->help);
fprintf(stderr, "\n");
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
log_debug("runtime dir '%s'\n", udev_get_run_path(udev));
if (command != NULL)
- for (i = 0; i < ARRAY_SIZE(udevadm_cmds); i++) {
+ for (i = 0; i < ELEMENTSOF(udevadm_cmds); i++) {
if (strcmp(udevadm_cmds[i]->name, command) == 0) {
argc -= optind;
argv += optind;
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 97b910cc2e..24f0bf6d1e 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -327,7 +327,7 @@ static void worker_new(struct event *event)
int fdcount;
int i;
- fdcount = epoll_wait(fd_ep, ev, ARRAY_SIZE(ev), -1);
+ fdcount = epoll_wait(fd_ep, ev, ELEMENTSOF(ev), -1);
if (fdcount < 0) {
if (errno == EINTR)
continue;
@@ -889,7 +889,7 @@ static void static_dev_create_links(struct udev *udev)
if (dir == NULL)
return;
- for (i = 0; i < ARRAY_SIZE(stdlinks); i++) {
+ for (i = 0; i < ELEMENTSOF(stdlinks); i++) {
struct stat sb;
if (stat(stdlinks[i].target, &sb) == 0) {
@@ -1496,7 +1496,7 @@ int main(int argc, char *argv[])
/* kill idle or hanging workers */
timeout = 3 * 1000;
}
- fdcount = epoll_wait(fd_ep, ev, ARRAY_SIZE(ev), timeout);
+ fdcount = epoll_wait(fd_ep, ev, ELEMENTSOF(ev), timeout);
if (fdcount < 0)
continue;