/* 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;
}
#include "macro.h"
#include "libudev.h"
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define READ_END 0
#define WRITE_END 1
/* 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)
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)
{
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);
}
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;
{
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);
}
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;
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;
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;
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;
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;
}
};
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;
};
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;
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");
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");
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;
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;
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) {
/* 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;