I think it's an antipattern to have to count the number of bytes in
the prefix by hand. We should do this automatically to avoid wasting
programmer time, and possible errors. I didn't any offsets that were
wrong, so this change is mostly to make future development easier.
}
LIST_FOREACH(device_allow, a, c->device_allow) {
}
LIST_FOREACH(device_allow, a, c->device_allow) {
unsigned k = 0;
if (a->r)
unsigned k = 0;
if (a->r)
if (startswith(a->path, "/dev/"))
whitelist_device(path, a->path, acc);
if (startswith(a->path, "/dev/"))
whitelist_device(path, a->path, acc);
- else if (startswith(a->path, "block-"))
- whitelist_major(path, a->path + 6, 'b', acc);
- else if (startswith(a->path, "char-"))
- whitelist_major(path, a->path + 5, 'c', acc);
+ else if ((val = startswith(a->path, "block-")))
+ whitelist_major(path, val, 'b', acc);
+ else if ((val = startswith(a->path, "char-")))
+ whitelist_major(path, val, 'c', acc);
else
log_unit_debug(u, "Ignoring device %s while writing cgroup attribute.", a->path);
}
else
log_unit_debug(u, "Ignoring device %s while writing cgroup attribute.", a->path);
}