1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

tree-wide: make use of new STRLEN() macro everywhere (#7639)

Let's employ coccinelle to do this for us.

Follow-up for #7625.
This commit is contained in:
Lennart Poettering 2017-12-14 19:02:29 +01:00 committed by GitHub
parent 1142cbd76a
commit fbd0b64f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 253 additions and 219 deletions

View File

@ -350,8 +350,7 @@
proper event, instead of doing time-based poll loops.
- To determine the length of a constant string "foo", don't bother
with sizeof("foo")-1, please use strlen("foo") directly. gcc knows
strlen() anyway and turns it into a constant expression if possible.
with sizeof("foo")-1, please use STRLEN() instead.
- If you want to concatenate two or more strings, consider using
strjoin() rather than asprintf(), as the latter is a lot

View File

@ -0,0 +1,10 @@
@@
constant s;
@@
- sizeof(s)-1
+ STRLEN(s)
@@
constant s;
@@
- strlen(s)
+ STRLEN(s)

View File

@ -1474,7 +1474,7 @@ static bool valid_slice_name(const char *p, size_t n) {
if (!p)
return false;
if (n < strlen("x.slice"))
if (n < STRLEN("x.slice"))
return false;
if (memcmp(p + n - 6, ".slice", 6) == 0) {
@ -1558,7 +1558,7 @@ static const char *skip_session(const char *p) {
p += strspn(p, "/");
n = strcspn(p, "/");
if (n < strlen("session-x.scope"))
if (n < STRLEN("session-x.scope"))
return NULL;
if (memcmp(p, "session-", 8) == 0 && memcmp(p + n - 6, ".scope", 6) == 0) {
@ -1595,7 +1595,7 @@ static const char *skip_user_manager(const char *p) {
p += strspn(p, "/");
n = strcspn(p, "/");
if (n < strlen("user@x.service"))
if (n < STRLEN("user@x.service"))
return NULL;
if (memcmp(p, "user@", 5) == 0 && memcmp(p + n - 8, ".service", 8) == 0) {

View File

@ -30,11 +30,11 @@ int encode_devnode_name(const char *str, char *str_enc, size_t len);
int whitelisted_char_for_devnode(char c, const char *additional);
#define SYS_BLOCK_PATH_MAX(suffix) \
(strlen("/sys/dev/block/") + DECIMAL_STR_MAX(dev_t) + 1 + DECIMAL_STR_MAX(dev_t) + strlen_ptr(suffix))
(STRLEN("/sys/dev/block/") + DECIMAL_STR_MAX(dev_t) + 1 + DECIMAL_STR_MAX(dev_t) + strlen_ptr(suffix))
#define xsprintf_sys_block_path(buf, suffix, devno) \
xsprintf(buf, "/sys/dev/block/%u:%u%s", major(devno), minor(devno), strempty(suffix))
#define DEV_NUM_PATH_MAX \
(strlen("/dev/block/") + DECIMAL_STR_MAX(dev_t) + 1 + DECIMAL_STR_MAX(dev_t))
(STRLEN("/dev/block/") + DECIMAL_STR_MAX(dev_t) + 1 + DECIMAL_STR_MAX(dev_t))
#define xsprintf_dev_num_path(buf, type, devno) \
xsprintf(buf, "/dev/%s/%u:%u", type, major(devno), minor(devno))

View File

@ -427,7 +427,7 @@ int move_fd(int from, int to, int cloexec) {
int acquire_data_fd(const void *data, size_t size, unsigned flags) {
char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)];
char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)];
_cleanup_close_pair_ int pipefds[2] = { -1, -1 };
char pattern[] = "/dev/shm/data-fd-XXXXXX";
_cleanup_close_ int fd = -1;

View File

@ -1472,7 +1472,7 @@ int link_tmpfile(int fd, const char *path, const char *target) {
if (rename_noreplace(AT_FDCWD, path, AT_FDCWD, target) < 0)
return -errno;
} else {
char proc_fd_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1];
char proc_fd_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1];
xsprintf(proc_fd_path, "/proc/self/fd/%i", fd);

View File

@ -580,7 +580,7 @@ int tmp_dir(const char **ret) {
}
int inotify_add_watch_fd(int fd, int what, uint32_t mask) {
char path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
char path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
int r;
/* This is like inotify_add_watch(), except that the file to watch is not referenced by a path, but by an fd */
@ -825,7 +825,7 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags,
}
int access_fd(int fd, int mode) {
char p[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1];
char p[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(fd) + 1];
int r;
/* Like access() but operates on an already open fd */

View File

@ -1047,18 +1047,18 @@ int log_struct_iovec_internal(
}
for (i = 0; i < n_input_iovec; i++) {
if (input_iovec[i].iov_len < strlen("MESSAGE="))
if (input_iovec[i].iov_len < STRLEN("MESSAGE="))
continue;
if (memcmp(input_iovec[i].iov_base, "MESSAGE=", strlen("MESSAGE=")) == 0)
if (memcmp(input_iovec[i].iov_base, "MESSAGE=", STRLEN("MESSAGE=")) == 0)
break;
}
if (_unlikely_(i >= n_input_iovec)) /* Couldn't find MESSAGE=? */
return -error;
m = strndupa(input_iovec[i].iov_base + strlen("MESSAGE="),
input_iovec[i].iov_len - strlen("MESSAGE="));
m = strndupa(input_iovec[i].iov_base + STRLEN("MESSAGE="),
input_iovec[i].iov_len - STRLEN("MESSAGE="));
return log_dispatch_internal(level, error, file, line, func, NULL, NULL, NULL, NULL, m);
}

View File

@ -116,7 +116,7 @@ int name_to_handle_at_loop(
}
static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *mnt_id) {
char path[strlen("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)];
char path[STRLEN("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)];
_cleanup_free_ char *fdinfo = NULL;
_cleanup_close_ int subfd = -1;
char *p;

View File

@ -41,7 +41,7 @@
if (_pid_ == 0) { \
_r_ = ("/proc/self/" field); \
} else { \
_r_ = alloca(strlen("/proc/") + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
_r_ = alloca(STRLEN("/proc/") + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \
sprintf((char*) _r_, "/proc/"PID_FMT"/" field, _pid_); \
} \
_r_; \

View File

@ -226,7 +226,7 @@ static const char *const __signal_table[] = {
DEFINE_PRIVATE_STRING_TABLE_LOOKUP(__signal, int);
const char *signal_to_string(int signo) {
static thread_local char buf[sizeof("RTMIN+")-1 + DECIMAL_STR_MAX(int) + 1];
static thread_local char buf[STRLEN("RTMIN+") + DECIMAL_STR_MAX(int) + 1];
const char *name;
name = __signal_to_string(signo);

View File

@ -122,7 +122,7 @@ int socket_address_parse(SocketAddress *a, const char *s) {
} else if (startswith(s, "vsock:")) {
/* AF_VSOCK socket in vsock:cid:port notation */
const char *cid_start = s + strlen("vsock:");
const char *cid_start = s + STRLEN("vsock:");
e = strchr(cid_start, ':');
if (!e)

View File

@ -992,7 +992,7 @@ int get_ctty_devnr(pid_t pid, dev_t *d) {
}
int get_ctty(pid_t pid, dev_t *_devnr, char **r) {
char fn[sizeof("/dev/char/")-1 + 2*DECIMAL_STR_MAX(unsigned) + 1 + 1], *b = NULL;
char fn[STRLEN("/dev/char/") + 2*DECIMAL_STR_MAX(unsigned) + 1 + 1], *b = NULL;
_cleanup_free_ char *s = NULL;
const char *p;
dev_t devnr;

View File

@ -105,7 +105,7 @@ int socket_from_display(const char *display, char **path) {
k = strspn(display+1, "0123456789");
f = new(char, strlen("/tmp/.X11-unix/X") + k + 1);
f = new(char, STRLEN("/tmp/.X11-unix/X") + k + 1);
if (!f)
return -ENOMEM;

View File

@ -105,7 +105,7 @@ int fgetxattr_malloc(int fd, const char *name, char **value) {
}
ssize_t fgetxattrat_fake(int dirfd, const char *filename, const char *attribute, void *value, size_t size, int flags) {
char fn[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
char fn[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
_cleanup_close_ int fd = -1;
ssize_t l;

View File

@ -497,7 +497,8 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
char *v;
/* Create the EFI default boot loader name (specified for removable devices) */
v = strjoina(esp_path, "/EFI/BOOT/BOOT", name + strlen("systemd-boot"));
v = strjoina(esp_path, "/EFI/BOOT/BOOT",
name + STRLEN("systemd-boot"));
ascii_strupper(strrchr(v, '/') + 1);
k = copy_file_with_version_check(p, v, force);

View File

@ -977,10 +977,10 @@ static int introspect(sd_bus *bus, char **argv) {
pager_open(arg_no_pager, false);
name_width = strlen("NAME");
type_width = strlen("TYPE");
signature_width = strlen("SIGNATURE");
result_width = strlen("RESULT/VALUE");
name_width = STRLEN("NAME");
type_width = STRLEN("TYPE");
signature_width = STRLEN("SIGNATURE");
result_width = STRLEN("RESULT/VALUE");
sorted = newa(Member*, set_size(members));

View File

@ -565,8 +565,8 @@ static void automount_trigger_notify(Unit *u, Unit *other) {
static void automount_enter_waiting(Automount *a) {
_cleanup_close_ int ioctl_fd = -1;
int p[2] = { -1, -1 };
char name[sizeof("systemd-")-1 + DECIMAL_STR_MAX(pid_t) + 1];
char options[sizeof("fd=,pgrp=,minproto=5,maxproto=5,direct")-1
char name[STRLEN("systemd-") + DECIMAL_STR_MAX(pid_t) + 1];
char options[STRLEN("fd=,pgrp=,minproto=5,maxproto=5,direct")
+ DECIMAL_STR_MAX(int) + DECIMAL_STR_MAX(gid_t) + 1];
bool mounted = false;
int r, dev_autofs_fd;

View File

@ -147,7 +147,7 @@ static int dynamic_user_acquire(Manager *m, const char *name, DynamicUser** ret)
static int make_uid_symlinks(uid_t uid, const char *name, bool b) {
char path1[strlen("/run/systemd/dynamic-uid/direct:") + DECIMAL_STR_MAX(uid_t) + 1];
char path1[STRLEN("/run/systemd/dynamic-uid/direct:") + DECIMAL_STR_MAX(uid_t) + 1];
const char *path2;
int r = 0, k;
@ -175,7 +175,7 @@ static int make_uid_symlinks(uid_t uid, const char *name, bool b) {
r = k;
}
if (b && symlink(path1 + strlen("/run/systemd/dynamic-uid/direct:"), path2) < 0) {
if (b && symlink(path1 + STRLEN("/run/systemd/dynamic-uid/direct:"), path2) < 0) {
k = log_warning_errno(errno, "Failed to symlink \"%s\": %m", path2);
if (r == 0)
r = k;
@ -218,7 +218,7 @@ static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
(void) mkdir("/run/systemd/dynamic-uid", 0755);
for (;;) {
char lock_path[strlen("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
char lock_path[STRLEN("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
_cleanup_close_ int lock_fd = -1;
uid_t candidate;
ssize_t l;
@ -411,7 +411,7 @@ static int dynamic_user_push(DynamicUser *d, uid_t uid, int lock_fd) {
}
static void unlink_uid_lock(int lock_fd, uid_t uid, const char *name) {
char lock_path[strlen("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
char lock_path[STRLEN("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
if (lock_fd < 0)
return;
@ -744,7 +744,7 @@ void dynamic_user_vacuum(Manager *m, bool close_user) {
}
int dynamic_user_lookup_uid(Manager *m, uid_t uid, char **ret) {
char lock_path[strlen("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
char lock_path[STRLEN("/run/systemd/dynamic-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
_cleanup_free_ char *user = NULL;
uid_t check_uid;
int r;

View File

@ -62,7 +62,7 @@ int ima_setup(void) {
}
/* attempt to write the name of the policy file into sysfs file */
if (write(imafd, IMA_POLICY_PATH, strlen(IMA_POLICY_PATH)) > 0)
if (write(imafd, IMA_POLICY_PATH, STRLEN(IMA_POLICY_PATH)) > 0)
goto done;
/* fall back to copying the policy line-by-line */

View File

@ -140,7 +140,7 @@ static void manager_watch_jobs_in_progress(Manager *m) {
(void) sd_event_source_set_description(m->jobs_in_progress_event_source, "manager-jobs-in-progress");
}
#define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED)-1) + sizeof(ANSI_HIGHLIGHT_RED)-1 + 2*(sizeof(ANSI_NORMAL)-1))
#define CYLON_BUFFER_EXTRA (2*STRLEN(ANSI_RED) + STRLEN(ANSI_HIGHLIGHT_RED) + 2*STRLEN(ANSI_NORMAL))
static void draw_cylon(char buffer[], size_t buflen, unsigned width, unsigned pos) {
char *p = buffer;
@ -2651,7 +2651,7 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root) {
t = manager_timestamp_to_string(q);
{
char field[strlen(t) + strlen("-timestamp") + 1];
char field[strlen(t) + STRLEN("-timestamp") + 1];
strcpy(stpcpy(field, t), "-timestamp");
dual_timestamp_serialize(f, field, m->timestamps + q);
}

View File

@ -903,9 +903,9 @@ static int run_gdb(sd_journal *j) {
if (r < 0)
return log_error_errno(r, "Failed to retrieve COREDUMP_EXE field: %m");
assert(len > strlen("COREDUMP_EXE="));
data += strlen("COREDUMP_EXE=");
len -= strlen("COREDUMP_EXE=");
assert(len > STRLEN("COREDUMP_EXE="));
data += STRLEN("COREDUMP_EXE=");
len -= STRLEN("COREDUMP_EXE=");
exe = strndup(data, len);
if (!exe)

View File

@ -398,7 +398,7 @@ int main(int argc, char *argv[]) {
goto finish;
}
if (pid == 0) {
char dash_c[sizeof("-C")-1 + DECIMAL_STR_MAX(int) + 1];
char dash_c[STRLEN("-C") + DECIMAL_STR_MAX(int) + 1];
int progress_socket = -1;
const char *cmdline[9];
int i = 0;

View File

@ -422,7 +422,7 @@ static int add_source(RemoteServer *s, int fd, char* name, bool own_name) {
static int add_raw_socket(RemoteServer *s, int fd) {
int r;
_cleanup_close_ int fd_ = fd;
char name[sizeof("raw-socket-")-1 + DECIMAL_STR_MAX(int) + 1];
char name[STRLEN("raw-socket-") + DECIMAL_STR_MAX(int) + 1];
assert(fd >= 0);

View File

@ -31,7 +31,7 @@ int audit_type_from_string(const char *s);
const char *_s_; \
_s_ = audit_type_to_string(type); \
if (!_s_) { \
_s_ = alloca(strlen("AUDIT") + DECIMAL_STR_MAX(int)); \
_s_ = alloca(STRLEN("AUDIT") + DECIMAL_STR_MAX(int)); \
sprintf((char*) _s_, "AUDIT%04i", type); \
} \
_s_; \

View File

@ -2572,7 +2572,7 @@ static int find_data_object_by_boot_id(
Object **o,
uint64_t *b) {
char t[sizeof("_BOOT_ID=")-1 + 32 + 1] = "_BOOT_ID=";
char t[STRLEN("_BOOT_ID=") + 32 + 1] = "_BOOT_ID=";
sd_id128_to_string(boot_id, t + 9);
return journal_file_find_data_object(f, t, sizeof(t) - 1, o, b);

View File

@ -96,7 +96,7 @@ _public_ int sd_journal_printv(int priority, const char *format, va_list ap) {
/* FIXME: Instead of limiting things to LINE_MAX we could do a
C99 variable-length array on the stack here in a loop. */
char buffer[8 + LINE_MAX], p[sizeof("PRIORITY=")-1 + DECIMAL_STR_MAX(int) + 1];
char buffer[8 + LINE_MAX], p[STRLEN("PRIORITY=") + DECIMAL_STR_MAX(int) + 1];
struct iovec iov[2];
assert_return(priority >= 0, -EINVAL);
@ -357,7 +357,7 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove
errno = 0;
j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k);
if (errno == 0) {
char error[sizeof("ERRNO=")-1 + DECIMAL_STR_MAX(int) + 1];
char error[STRLEN("ERRNO=") + DECIMAL_STR_MAX(int) + 1];
if (j != buffer + 8 + k)
memmove(buffer + 8 + k, j, strlen(j)+1);
@ -459,7 +459,7 @@ _public_ int sd_journal_print_with_location(int priority, const char *file, cons
}
_public_ int sd_journal_printv_with_location(int priority, const char *file, const char *line, const char *func, const char *format, va_list ap) {
char buffer[8 + LINE_MAX], p[sizeof("PRIORITY=")-1 + DECIMAL_STR_MAX(int) + 1];
char buffer[8 + LINE_MAX], p[STRLEN("PRIORITY=") + DECIMAL_STR_MAX(int) + 1];
struct iovec iov[5];
char *f;

View File

@ -1343,7 +1343,8 @@ static int add_dmesg(sd_journal *j) {
if (!arg_dmesg)
return 0;
r = sd_journal_add_match(j, "_TRANSPORT=kernel", strlen("_TRANSPORT=kernel"));
r = sd_journal_add_match(j, "_TRANSPORT=kernel",
STRLEN("_TRANSPORT=kernel"));
if (r < 0)
return log_error_errno(r, "Failed to add match: %m");

View File

@ -58,8 +58,8 @@ void server_forward_console(
struct iovec iovec[5];
struct timespec ts;
char tbuf[sizeof("[] ")-1 + DECIMAL_STR_MAX(ts.tv_sec) + DECIMAL_STR_MAX(ts.tv_nsec)-3 + 1];
char header_pid[sizeof("[]: ")-1 + DECIMAL_STR_MAX(pid_t)];
char tbuf[STRLEN("[] ") + DECIMAL_STR_MAX(ts.tv_sec) + DECIMAL_STR_MAX(ts.tv_nsec)-3 + 1];
char header_pid[STRLEN("[]: ") + DECIMAL_STR_MAX(pid_t)];
_cleanup_free_ char *ident_buf = NULL;
_cleanup_close_ int fd = -1;
const char *tty;

View File

@ -50,7 +50,7 @@ void server_forward_kmsg(
_cleanup_free_ char *ident_buf = NULL;
struct iovec iovec[5];
char header_priority[DECIMAL_STR_MAX(priority) + 3],
header_pid[sizeof("[]: ")-1 + DECIMAL_STR_MAX(pid_t) + 1];
header_pid[STRLEN("[]: ") + DECIMAL_STR_MAX(pid_t) + 1];
int n = 0;
assert(s);

View File

@ -95,13 +95,14 @@ static void server_process_entry_meta(
*message = t;
}
} else if (l > strlen("OBJECT_PID=") &&
l < strlen("OBJECT_PID=") + DECIMAL_STR_MAX(pid_t) &&
} else if (l > STRLEN("OBJECT_PID=") &&
l < STRLEN("OBJECT_PID=") + DECIMAL_STR_MAX(pid_t) &&
startswith(p, "OBJECT_PID=") &&
allow_object_pid(ucred)) {
char buf[DECIMAL_STR_MAX(pid_t)];
memcpy(buf, p + strlen("OBJECT_PID="), l - strlen("OBJECT_PID="));
buf[l-strlen("OBJECT_PID=")] = '\0';
memcpy(buf, p + STRLEN("OBJECT_PID="),
l - STRLEN("OBJECT_PID="));
buf[l-STRLEN("OBJECT_PID=")] = '\0';
(void) parse_pid(buf, object_pid);
}
@ -252,7 +253,7 @@ static int server_process_entry(
tn = n++;
iovec[tn] = IOVEC_MAKE_STRING("_TRANSPORT=journal");
entry_size += strlen("_TRANSPORT=journal");
entry_size += STRLEN("_TRANSPORT=journal");
if (entry_size + n + 1 > ENTRY_SIZE_MAX) { /* data + separators + trailer */
log_debug("Entry is too big with %zu properties and %zu bytes, ignoring.", n, entry_size);

View File

@ -724,7 +724,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
#define IOVEC_ADD_NUMERIC_FIELD(iovec, n, value, type, isset, format, field) \
if (isset(value)) { \
char *k; \
k = newa(char, strlen(field "=") + DECIMAL_STR_MAX(type) + 1); \
k = newa(char, STRLEN(field "=") + DECIMAL_STR_MAX(type) + 1); \
sprintf(k, field "=" format, value); \
iovec[n++] = IOVEC_MAKE_STRING(k); \
}
@ -739,7 +739,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
#define IOVEC_ADD_ID128_FIELD(iovec, n, value, field) \
if (!sd_id128_is_null(value)) { \
char *k; \
k = newa(char, strlen(field "=") + SD_ID128_STRING_MAX); \
k = newa(char, STRLEN(field "=") + SD_ID128_STRING_MAX); \
sd_id128_to_string(value, stpcpy(k, field "=")); \
iovec[n++] = IOVEC_MAKE_STRING(k); \
}
@ -747,7 +747,7 @@ static void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned
#define IOVEC_ADD_SIZED_FIELD(iovec, n, value, value_size, field) \
if (value_size > 0) { \
char *k; \
k = newa(char, strlen(field "=") + value_size + 1); \
k = newa(char, STRLEN(field "=") + value_size + 1); \
*((char*) mempcpy(stpcpy(k, field "="), value, value_size)) = 0; \
iovec[n++] = IOVEC_MAKE_STRING(k); \
} \

View File

@ -180,7 +180,7 @@ struct Server {
ClientContext *pid1_context; /* the context of PID 1 */
};
#define SERVER_MACHINE_ID(s) ((s)->machine_id_field + strlen("_MACHINE_ID="))
#define SERVER_MACHINE_ID(s) ((s)->machine_id_field + STRLEN("_MACHINE_ID="))
/* Extra fields for any log messages */
#define N_IOVEC_META_FIELDS 22

View File

@ -106,7 +106,7 @@ struct StdoutStream {
LIST_FIELDS(StdoutStream, stdout_stream);
LIST_FIELDS(StdoutStream, stdout_stream_notify_queue);
char id_field[sizeof("_STREAM_ID=")-1 + SD_ID128_STRING_MAX];
char id_field[STRLEN("_STREAM_ID=") + SD_ID128_STRING_MAX];
};
void stdout_stream_free(StdoutStream *s) {
@ -194,7 +194,7 @@ static int stdout_stream_save(StdoutStream *s) {
s->forward_to_syslog,
s->forward_to_kmsg,
s->forward_to_console,
s->id_field + strlen("_STREAM_ID="));
s->id_field + STRLEN("_STREAM_ID="));
if (!isempty(s->identifier)) {
_cleanup_free_ char *escaped;
@ -255,7 +255,7 @@ static int stdout_stream_log(StdoutStream *s, const char *p, LineBreak line_brea
struct iovec *iovec;
int priority;
char syslog_priority[] = "PRIORITY=\0";
char syslog_facility[sizeof("SYSLOG_FACILITY=")-1 + DECIMAL_STR_MAX(int) + 1];
char syslog_facility[STRLEN("SYSLOG_FACILITY=") + DECIMAL_STR_MAX(int) + 1];
_cleanup_free_ char *message = NULL, *syslog_identifier = NULL;
size_t n = 0, m;
int r;
@ -300,7 +300,7 @@ static int stdout_stream_log(StdoutStream *s, const char *p, LineBreak line_brea
iovec[n++] = IOVEC_MAKE_STRING("_TRANSPORT=stdout");
iovec[n++] = IOVEC_MAKE_STRING(s->id_field);
syslog_priority[strlen("PRIORITY=")] = '0' + LOG_PRI(priority);
syslog_priority[STRLEN("PRIORITY=")] = '0' + LOG_PRI(priority);
iovec[n++] = IOVEC_MAKE_STRING(syslog_priority);
if (priority & LOG_FACMASK) {
@ -836,7 +836,7 @@ int server_open_stdout_socket(Server *s) {
void stdout_stream_send_notify(StdoutStream *s) {
struct iovec iovec = {
.iov_base = (char*) "FDSTORE=1",
.iov_len = strlen("FDSTORE=1"),
.iov_len = STRLEN("FDSTORE=1"),
};
struct msghdr msghdr = {
.msg_iov = &iovec,

View File

@ -132,7 +132,7 @@ static void forward_syslog_raw(Server *s, int priority, const char *buffer, cons
void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred, const struct timeval *tv) {
struct iovec iovec[5];
char header_priority[DECIMAL_STR_MAX(priority) + 3], header_time[64],
header_pid[sizeof("[]: ")-1 + DECIMAL_STR_MAX(pid_t) + 1];
header_pid[STRLEN("[]: ") + DECIMAL_STR_MAX(pid_t) + 1];
int n = 0;
time_t t;
struct tm *tm;

View File

@ -31,16 +31,16 @@ int main(int argc, char *argv[]) {
/* utf-8 and non-utf-8, message-less and message-ful iovecs */
struct iovec graph1[] = {
{(char*) "GRAPH=graph", strlen("GRAPH=graph")}
{(char*) "GRAPH=graph", STRLEN("GRAPH=graph")}
};
struct iovec graph2[] = {
{(char*) "GRAPH=graph\n", strlen("GRAPH=graph\n")}
{(char*) "GRAPH=graph\n", STRLEN("GRAPH=graph\n")}
};
struct iovec message1[] = {
{(char*) "MESSAGE=graph", strlen("MESSAGE=graph")}
{(char*) "MESSAGE=graph", STRLEN("MESSAGE=graph")}
};
struct iovec message2[] = {
{(char*) "MESSAGE=graph\n", strlen("MESSAGE=graph\n")}
{(char*) "MESSAGE=graph\n", STRLEN("MESSAGE=graph\n")}
};
assert_se(sd_journal_print(LOG_INFO, "piepapo") == 0);

View File

@ -232,8 +232,9 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
if (f)
b->can_fds =
(f - e == strlen("\r\nAGREE_UNIX_FD")) &&
memcmp(e + 2, "AGREE_UNIX_FD", strlen("AGREE_UNIX_FD")) == 0;
(f - e == STRLEN("\r\nAGREE_UNIX_FD")) &&
memcmp(e + 2, "AGREE_UNIX_FD",
STRLEN("AGREE_UNIX_FD")) == 0;
b->rbuffer_size -= (start - (char*) b->rbuffer);
memmove(b->rbuffer, start, b->rbuffer_size);

View File

@ -63,7 +63,7 @@ struct sd_bus_track {
({ \
char *_x; \
size_t _l = strlen(name); \
_x = alloca(strlen(MATCH_PREFIX)+_l+strlen(MATCH_SUFFIX)+1); \
_x = alloca(STRLEN(MATCH_PREFIX)+_l+STRLEN(MATCH_SUFFIX)+1); \
strcpy(stpcpy(stpcpy(_x, MATCH_PREFIX), name), MATCH_SUFFIX); \
_x; \
})

View File

@ -293,7 +293,7 @@ static int device_compare(const void *_a, const void *_b) {
* entire sound card completed. The kernel makes this guarantee
* when creating those devices, and hence we should too when
* enumerating them. */
sound_a += strlen("/sound/card");
sound_a += STRLEN("/sound/card");
sound_a = strchr(sound_a, '/');
if (sound_a) {

View File

@ -1050,7 +1050,7 @@ int device_update_db(sd_device *device) {
const char *devlink;
FOREACH_DEVICE_DEVLINK(device, devlink)
fprintf(f, "S:%s\n", devlink + strlen("/dev/"));
fprintf(f, "S:%s\n", devlink + STRLEN("/dev/"));
if (device->devlink_priority != 0)
fprintf(f, "L:%i\n", device->devlink_priority);

View File

@ -209,7 +209,7 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
return -ENOMEM;
}
devpath = syspath + strlen("/sys");
devpath = syspath + STRLEN("/sys");
r = device_add_property_internal(device, "DEVPATH", devpath);
if (r < 0)
@ -700,7 +700,7 @@ static int device_new_from_child(sd_device **ret, sd_device *child) {
path = strdup(syspath);
if (!path)
return -ENOMEM;
subdir = path + strlen("/sys");
subdir = path + STRLEN("/sys");
for (;;) {
char *pos;

View File

@ -104,7 +104,7 @@ _public_ int sd_network_get_route_domains(char ***ret) {
}
static int network_link_get_string(int ifindex, const char *field, char **ret) {
char path[strlen("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
_cleanup_free_ char *s = NULL;
int r;
@ -128,7 +128,7 @@ static int network_link_get_string(int ifindex, const char *field, char **ret) {
}
static int network_link_get_strv(int ifindex, const char *key, char ***ret) {
char path[strlen("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
_cleanup_strv_free_ char **a = NULL;
_cleanup_free_ char *s = NULL;
int r;
@ -224,7 +224,7 @@ _public_ int sd_network_link_get_route_domains(int ifindex, char ***ret) {
}
static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) {
char path[strlen("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];
_cleanup_free_ int *ifis = NULL;
_cleanup_free_ char *s = NULL;
size_t allocated = 0, c = 0;

View File

@ -610,7 +610,7 @@ void machine_release_unit(Machine *m) {
}
int machine_get_uid_shift(Machine *m, uid_t *ret) {
char p[strlen("/proc//uid_map") + DECIMAL_STR_MAX(pid_t) + 1];
char p[STRLEN("/proc//uid_map") + DECIMAL_STR_MAX(pid_t) + 1];
uid_t uid_base, uid_shift, uid_range;
gid_t gid_base, gid_shift, gid_range;
_cleanup_fclose_ FILE *f = NULL;

View File

@ -194,8 +194,8 @@ static int call_get_os_release(sd_bus *bus, const char *method, const char *name
static int list_machines(int argc, char *argv[], void *userdata) {
size_t max_name = strlen("MACHINE"), max_class = strlen("CLASS"),
max_service = strlen("SERVICE"), max_os = strlen("OS"), max_version_id = strlen("VERSION");
size_t max_name = STRLEN("MACHINE"), max_class = STRLEN("CLASS"),
max_service = STRLEN("SERVICE"), max_os = STRLEN("OS"), max_version_id = STRLEN("VERSION");
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_free_ char *prefix = NULL;
@ -284,13 +284,13 @@ static int list_machines(int argc, char *argv[], void *userdata) {
qsort_safe(machines, n_machines, sizeof(MachineInfo), compare_machine_info);
/* Allocate for prefix max characters for all fields + spaces between them + strlen(",\n") */
/* Allocate for prefix max characters for all fields + spaces between them + STRLEN(",\n") */
r = asprintf(&prefix, "%-*s",
(int) (max_name +
max_class +
max_service +
max_os +
max_version_id + 5 + strlen(",\n")),
max_version_id + 5 + STRLEN(",\n")),
",\n");
if (r < 0) {
r = log_oom();
@ -352,7 +352,7 @@ static int compare_image_info(const void *a, const void *b) {
static int list_images(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
size_t max_name = strlen("NAME"), max_type = strlen("TYPE"), max_size = strlen("USAGE"), max_crtime = strlen("CREATED"), max_mtime = strlen("MODIFIED");
size_t max_name = STRLEN("NAME"), max_type = STRLEN("TYPE"), max_size = STRLEN("USAGE"), max_crtime = STRLEN("CREATED"), max_mtime = STRLEN("MODIFIED");
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_free_ ImageInfo *images = NULL;
size_t n_images = 0, n_allocated = 0, j;
@ -2527,7 +2527,7 @@ static int compare_transfer_info(const void *a, const void *b) {
}
static int list_transfers(int argc, char *argv[], void *userdata) {
size_t max_type = strlen("TYPE"), max_local = strlen("LOCAL"), max_remote = strlen("REMOTE");
size_t max_type = STRLEN("TYPE"), max_local = STRLEN("LOCAL"), max_remote = STRLEN("REMOTE");
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ TransferInfo *transfers = NULL;

View File

@ -1320,7 +1320,7 @@ static int method_map_to_machine_user(sd_bus_message *message, void *userdata, s
HASHMAP_FOREACH(machine, m->machines, i) {
_cleanup_fclose_ FILE *f = NULL;
char p[strlen("/proc//uid_map") + DECIMAL_STR_MAX(pid_t) + 1];
char p[STRLEN("/proc//uid_map") + DECIMAL_STR_MAX(pid_t) + 1];
if (machine->class != MACHINE_CONTAINER)
continue;
@ -1438,7 +1438,7 @@ static int method_map_to_machine_group(sd_bus_message *message, void *groupdata,
HASHMAP_FOREACH(machine, m->machines, i) {
_cleanup_fclose_ FILE *f = NULL;
char p[strlen("/proc//gid_map") + DECIMAL_STR_MAX(pid_t) + 1];
char p[STRLEN("/proc//gid_map") + DECIMAL_STR_MAX(pid_t) + 1];
if (machine->class != MACHINE_CONTAINER)
continue;

View File

@ -340,7 +340,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
/* IEEE Organizationally Unique Identifier vendor string */
static int ieee_oui(sd_hwdb *hwdb, const struct ether_addr *mac, char **ret) {
const char *description;
char modalias[strlen("OUI:XXYYXXYYXXYY") + 1], *desc;
char modalias[STRLEN("OUI:XXYYXXYYXXYY") + 1], *desc;
int r;
assert(ret);

View File

@ -44,7 +44,7 @@
#if HAVE_ACL
static int get_acl(int fd, const char *name, acl_type_t type, acl_t *ret) {
char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
acl_t acl;
assert(fd >= 0);
@ -73,7 +73,7 @@ static int get_acl(int fd, const char *name, acl_type_t type, acl_t *ret) {
}
static int set_acl(int fd, const char *name, acl_type_t type, acl_t acl) {
char procfs_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1];
int r;
assert(fd >= 0);

View File

@ -2856,7 +2856,7 @@ static int uid_shift_pick(uid_t *shift, LockFile *ret_lock_file) {
(void) mkdir("/run/systemd/nspawn-uid", 0755);
for (;;) {
char lock_path[strlen("/run/systemd/nspawn-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
char lock_path[STRLEN("/run/systemd/nspawn-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
_cleanup_release_lock_file_ LockFile lf = LOCK_FILE_INIT;
if (--n_tries <= 0)
@ -2910,7 +2910,7 @@ static int uid_shift_pick(uid_t *shift, LockFile *ret_lock_file) {
}
static int setup_uid_map(pid_t pid) {
char uid_map[strlen("/proc//uid_map") + DECIMAL_STR_MAX(uid_t) + 1], line[DECIMAL_STR_MAX(uid_t)*3+3+1];
char uid_map[STRLEN("/proc//uid_map") + DECIMAL_STR_MAX(uid_t) + 1], line[DECIMAL_STR_MAX(uid_t)*3+3+1];
int r;
assert(pid > 1);

View File

@ -92,7 +92,7 @@ static int direct_lookup_name(const char *name, uid_t *ret) {
}
static int direct_lookup_uid(uid_t uid, char **ret) {
char path[strlen("/run/systemd/dynamic-uid/direct:") + DECIMAL_STR_MAX(uid_t) + 1], *s;
char path[STRLEN("/run/systemd/dynamic-uid/direct:") + DECIMAL_STR_MAX(uid_t) + 1], *s;
int r;
xsprintf(path, "/run/systemd/dynamic-uid/direct:" UID_FMT, uid);

View File

@ -766,7 +766,7 @@ static int format_timestamp_dns(char *buf, size_t l, time_t sec) {
struct tm tm;
assert(buf);
assert(l > strlen("YYYYMMDDHHmmSS"));
assert(l > STRLEN("YYYYMMDDHHmmSS"));
if (!gmtime_r(&sec, &tm))
return -EINVAL;
@ -1035,7 +1035,7 @@ const char *dns_resource_record_to_string(DnsResourceRecord *rr) {
case DNS_TYPE_RRSIG: {
_cleanup_free_ char *alg = NULL;
char expiration[strlen("YYYYMMDDHHmmSS") + 1], inception[strlen("YYYYMMDDHHmmSS") + 1];
char expiration[STRLEN("YYYYMMDDHHmmSS") + 1], inception[STRLEN("YYYYMMDDHHmmSS") + 1];
const char *type;
int n;

View File

@ -252,11 +252,13 @@ int ask_password_tty(
}
if (colors_enabled())
loop_write(ttyfd, ANSI_HIGHLIGHT, strlen(ANSI_HIGHLIGHT), false);
loop_write(ttyfd, ANSI_HIGHLIGHT,
STRLEN(ANSI_HIGHLIGHT), false);
loop_write(ttyfd, message, strlen(message), false);
loop_write(ttyfd, " ", 1, false);
if (colors_enabled())
loop_write(ttyfd, ANSI_NORMAL, strlen(ANSI_NORMAL), false);
loop_write(ttyfd, ANSI_NORMAL, STRLEN(ANSI_NORMAL),
false);
new_termios = old_termios;
new_termios.c_lflag &= ~(ICANON|ECHO);

View File

@ -1186,7 +1186,7 @@ int root_hash_load(const char *image, void **ret, size_t *ret_size) {
if (!IN_SET(r, -ENODATA, -EOPNOTSUPP, -ENOENT))
return r;
fn = newa(char, strlen(image) + strlen(".roothash") + 1);
fn = newa(char, strlen(image) + STRLEN(".roothash") + 1);
n = stpcpy(fn, image);
e = endswith(fn, ".raw");
if (e)

View File

@ -506,7 +506,9 @@ static int output_verbose(
else {
_cleanup_free_ char *value = NULL;
r = parse_field(data, length, "_SOURCE_REALTIME_TIMESTAMP=", strlen("_SOURCE_REALTIME_TIMESTAMP="), &value, NULL);
r = parse_field(data, length, "_SOURCE_REALTIME_TIMESTAMP=",
STRLEN("_SOURCE_REALTIME_TIMESTAMP="), &value,
NULL);
if (r < 0)
return r;
assert(r > 0);

View File

@ -425,7 +425,7 @@ int utmp_wall(
if (u->ut_type != USER_PROCESS || u->ut_user[0] == 0)
continue;
/* this access is fine, because strlen("/dev/") << 32 (UT_LINESIZE) */
/* this access is fine, because STRLEN("/dev/") << 32 (UT_LINESIZE) */
if (path_startswith(u->ut_line, "/dev/"))
path = u->ut_line;
else {

View File

@ -428,12 +428,12 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
unsigned n_shown = 0;
int job_count = 0;
max_id_len = strlen("UNIT");
load_len = strlen("LOAD");
active_len = strlen("ACTIVE");
sub_len = strlen("SUB");
job_len = strlen("JOB");
max_desc_len = strlen("DESCRIPTION");
max_id_len = STRLEN("UNIT");
load_len = STRLEN("LOAD");
active_len = STRLEN("ACTIVE");
sub_len = STRLEN("SUB");
job_len = STRLEN("JOB");
max_desc_len = STRLEN("DESCRIPTION");
for (u = unit_infos; u < unit_infos + c; u++) {
max_id_len = MAX(max_id_len, strlen(u->id) + (u->machine ? strlen(u->machine)+1 : 0));
@ -914,10 +914,10 @@ static int socket_info_compare(const struct socket_info *a, const struct socket_
static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
struct socket_info *s;
unsigned pathlen = strlen("LISTEN"),
typelen = strlen("TYPE") * arg_show_types,
socklen = strlen("UNIT"),
servlen = strlen("ACTIVATES");
unsigned pathlen = STRLEN("LISTEN"),
typelen = STRLEN("TYPE") * arg_show_types,
socklen = STRLEN("UNIT"),
servlen = STRLEN("ACTIVATES");
const char *on, *off;
for (s = socket_infos; s < socket_infos + cs; s++) {
@ -1165,12 +1165,12 @@ static int timer_info_compare(const struct timer_info *a, const struct timer_inf
static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
struct timer_info *t;
unsigned
nextlen = strlen("NEXT"),
leftlen = strlen("LEFT"),
lastlen = strlen("LAST"),
passedlen = strlen("PASSED"),
unitlen = strlen("UNIT"),
activatelen = strlen("ACTIVATES");
nextlen = STRLEN("NEXT"),
leftlen = STRLEN("LEFT"),
lastlen = STRLEN("LAST"),
passedlen = STRLEN("PASSED"),
unitlen = STRLEN("UNIT"),
activatelen = STRLEN("ACTIVATES");
const char *on, *off;
@ -1410,8 +1410,8 @@ static void output_unit_file_list(const UnitFileList *units, unsigned c) {
unsigned max_id_len, id_cols, state_cols;
const UnitFileList *u;
max_id_len = strlen("UNIT FILE");
state_cols = strlen("STATE");
max_id_len = STRLEN("UNIT FILE");
state_cols = STRLEN("STATE");
for (u = units; u < units + c; u++) {
max_id_len = MAX(max_id_len, strlen(basename(u->path)));
@ -1999,15 +1999,16 @@ static void output_machines_list(struct machine_info *machine_infos, unsigned n)
struct machine_info *m;
unsigned
circle_len = 0,
namelen = sizeof("NAME") - 1,
statelen = sizeof("STATE") - 1,
failedlen = sizeof("FAILED") - 1,
jobslen = sizeof("JOBS") - 1;
namelen = STRLEN("NAME"),
statelen = STRLEN("STATE"),
failedlen = STRLEN("FAILED"),
jobslen = STRLEN("JOBS");
assert(machine_infos || n == 0);
for (m = machine_infos; m < machine_infos + n; m++) {
namelen = MAX(namelen, strlen(m->name) + (m->is_host ? sizeof(" (host)") - 1 : 0));
namelen = MAX(namelen,
strlen(m->name) + (m->is_host ? STRLEN(" (host)") : 0));
statelen = MAX(statelen, strlen_ptr(m->state));
failedlen = MAX(failedlen, DECIMAL_STR_WIDTH(m->n_failed_units));
jobslen = MAX(jobslen, DECIMAL_STR_WIDTH(m->n_jobs));
@ -2053,7 +2054,8 @@ static void output_machines_list(struct machine_info *machine_infos, unsigned n)
if (m->is_host)
printf("%-*s (host) %s%-*s%s %s%*" PRIu32 "%s %*" PRIu32 "\n",
(int) (namelen - (sizeof(" (host)")-1)), strna(m->name),
(int) (namelen - (STRLEN(" (host)"))),
strna(m->name),
on_state, statelen, strna(m->state), off_state,
on_failed, failedlen, m->n_failed_units, off_failed,
jobslen, m->n_jobs);
@ -2256,10 +2258,10 @@ static void output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned
pager_open(arg_no_pager, false);
id_len = strlen("JOB");
unit_len = strlen("UNIT");
type_len = strlen("TYPE");
state_len = strlen("STATE");
id_len = STRLEN("JOB");
unit_len = STRLEN("UNIT");
type_len = STRLEN("TYPE");
state_len = STRLEN("STATE");
for (j = jobs; j < jobs + n; j++) {
uint32_t id = j->id;
@ -6086,7 +6088,7 @@ static int enable_sysv_units(const char *verb, char **args) {
if (!p)
return log_oom();
p[strlen(p) - strlen(".service")] = 0;
p[strlen(p) - STRLEN(".service")] = 0;
found_sysv = access(p, F_OK) >= 0;
if (!found_sysv)
continue;

View File

@ -466,7 +466,7 @@ static void test_write_string_file_no_create(void) {
assert_se(write_string_file("/a/file/which/does/not/exists/i/guess", "boohoo", 0) < 0);
assert_se(write_string_file(fn, "boohoo", 0) == 0);
assert_se(read(fd, buf, sizeof(buf)) == strlen("boohoo\n"));
assert_se(read(fd, buf, sizeof(buf)) == STRLEN("boohoo\n"));
assert_se(streq(buf, "boohoo\n"));
unlink(fn);

View File

@ -107,72 +107,72 @@ static void test_unhexmem(void) {
static void test_base32hexmem(void) {
char *b32;
b32 = base32hexmem("", strlen(""), true);
b32 = base32hexmem("", STRLEN(""), true);
assert_se(b32);
assert_se(streq(b32, ""));
free(b32);
b32 = base32hexmem("f", strlen("f"), true);
b32 = base32hexmem("f", STRLEN("f"), true);
assert_se(b32);
assert_se(streq(b32, "CO======"));
free(b32);
b32 = base32hexmem("fo", strlen("fo"), true);
b32 = base32hexmem("fo", STRLEN("fo"), true);
assert_se(b32);
assert_se(streq(b32, "CPNG===="));
free(b32);
b32 = base32hexmem("foo", strlen("foo"), true);
b32 = base32hexmem("foo", STRLEN("foo"), true);
assert_se(b32);
assert_se(streq(b32, "CPNMU==="));
free(b32);
b32 = base32hexmem("foob", strlen("foob"), true);
b32 = base32hexmem("foob", STRLEN("foob"), true);
assert_se(b32);
assert_se(streq(b32, "CPNMUOG="));
free(b32);
b32 = base32hexmem("fooba", strlen("fooba"), true);
b32 = base32hexmem("fooba", STRLEN("fooba"), true);
assert_se(b32);
assert_se(streq(b32, "CPNMUOJ1"));
free(b32);
b32 = base32hexmem("foobar", strlen("foobar"), true);
b32 = base32hexmem("foobar", STRLEN("foobar"), true);
assert_se(b32);
assert_se(streq(b32, "CPNMUOJ1E8======"));
free(b32);
b32 = base32hexmem("", strlen(""), false);
b32 = base32hexmem("", STRLEN(""), false);
assert_se(b32);
assert_se(streq(b32, ""));
free(b32);
b32 = base32hexmem("f", strlen("f"), false);
b32 = base32hexmem("f", STRLEN("f"), false);
assert_se(b32);
assert_se(streq(b32, "CO"));
free(b32);
b32 = base32hexmem("fo", strlen("fo"), false);
b32 = base32hexmem("fo", STRLEN("fo"), false);
assert_se(b32);
assert_se(streq(b32, "CPNG"));
free(b32);
b32 = base32hexmem("foo", strlen("foo"), false);
b32 = base32hexmem("foo", STRLEN("foo"), false);
assert_se(b32);
assert_se(streq(b32, "CPNMU"));
free(b32);
b32 = base32hexmem("foob", strlen("foob"), false);
b32 = base32hexmem("foob", STRLEN("foob"), false);
assert_se(b32);
assert_se(streq(b32, "CPNMUOG"));
free(b32);
b32 = base32hexmem("fooba", strlen("fooba"), false);
b32 = base32hexmem("fooba", STRLEN("fooba"), false);
assert_se(b32);
assert_se(streq(b32, "CPNMUOJ1"));
free(b32);
b32 = base32hexmem("foobar", strlen("foobar"), false);
b32 = base32hexmem("foobar", STRLEN("foobar"), false);
assert_se(b32);
assert_se(streq(b32, "CPNMUOJ1E8"));
free(b32);
@ -182,121 +182,121 @@ static void test_unbase32hexmem(void) {
void *mem;
size_t len;
assert_se(unbase32hexmem("", strlen(""), true, &mem, &len) == 0);
assert_se(unbase32hexmem("", STRLEN(""), true, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), ""));
free(mem);
assert_se(unbase32hexmem("CO======", strlen("CO======"), true, &mem, &len) == 0);
assert_se(unbase32hexmem("CO======", STRLEN("CO======"), true, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "f"));
free(mem);
assert_se(unbase32hexmem("CPNG====", strlen("CPNG===="), true, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNG====", STRLEN("CPNG===="), true, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "fo"));
free(mem);
assert_se(unbase32hexmem("CPNMU===", strlen("CPNMU==="), true, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNMU===", STRLEN("CPNMU==="), true, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "foo"));
free(mem);
assert_se(unbase32hexmem("CPNMUOG=", strlen("CPNMUOG="), true, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNMUOG=", STRLEN("CPNMUOG="), true, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "foob"));
free(mem);
assert_se(unbase32hexmem("CPNMUOJ1", strlen("CPNMUOJ1"), true, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNMUOJ1", STRLEN("CPNMUOJ1"), true, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "fooba"));
free(mem);
assert_se(unbase32hexmem("CPNMUOJ1E8======", strlen("CPNMUOJ1E8======"), true, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNMUOJ1E8======", STRLEN("CPNMUOJ1E8======"), true, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "foobar"));
free(mem);
assert_se(unbase32hexmem("A", strlen("A"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("A=======", strlen("A======="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAA=====", strlen("AAA====="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAAA==", strlen("AAAAAA=="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AB======", strlen("AB======"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAB====", strlen("AAAB===="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAB===", strlen("AAAAB==="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAAAB=", strlen("AAAAAAB="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("A", STRLEN("A"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("A=======", STRLEN("A======="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAA=====", STRLEN("AAA====="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAAA==", STRLEN("AAAAAA=="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AB======", STRLEN("AB======"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAB====", STRLEN("AAAB===="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAB===", STRLEN("AAAAB==="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAAAB=", STRLEN("AAAAAAB="), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("XPNMUOJ1", strlen("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CXNMUOJ1", strlen("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPXMUOJ1", strlen("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNXUOJ1", strlen("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMXOJ1", strlen("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUXJ1", strlen("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUOX1", strlen("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUOJX", strlen("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("XPNMUOJ1", STRLEN("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CXNMUOJ1", STRLEN("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPXMUOJ1", STRLEN("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNXUOJ1", STRLEN("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMXOJ1", STRLEN("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUXJ1", STRLEN("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUOX1", STRLEN("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUOJX", STRLEN("CPNMUOJ1"), true, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("", strlen(""), false, &mem, &len) == 0);
assert_se(unbase32hexmem("", STRLEN(""), false, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), ""));
free(mem);
assert_se(unbase32hexmem("CO", strlen("CO"), false, &mem, &len) == 0);
assert_se(unbase32hexmem("CO", STRLEN("CO"), false, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "f"));
free(mem);
assert_se(unbase32hexmem("CPNG", strlen("CPNG"), false, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNG", STRLEN("CPNG"), false, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "fo"));
free(mem);
assert_se(unbase32hexmem("CPNMU", strlen("CPNMU"), false, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNMU", STRLEN("CPNMU"), false, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "foo"));
free(mem);
assert_se(unbase32hexmem("CPNMUOG", strlen("CPNMUOG"), false, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNMUOG", STRLEN("CPNMUOG"), false, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "foob"));
free(mem);
assert_se(unbase32hexmem("CPNMUOJ1", strlen("CPNMUOJ1"), false, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNMUOJ1", STRLEN("CPNMUOJ1"), false, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "fooba"));
free(mem);
assert_se(unbase32hexmem("CPNMUOJ1E8", strlen("CPNMUOJ1E8"), false, &mem, &len) == 0);
assert_se(unbase32hexmem("CPNMUOJ1E8", STRLEN("CPNMUOJ1E8"), false, &mem, &len) == 0);
assert_se(streq(strndupa(mem, len), "foobar"));
free(mem);
assert_se(unbase32hexmem("CPNMUOG=", strlen("CPNMUOG="), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUOJ1E8======", strlen("CPNMUOJ1E8======"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("A", strlen("A"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("A", strlen("A"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAA", strlen("AAA"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAAA", strlen("AAAAAA"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AB", strlen("AB"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAB", strlen("AAAB"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAB", strlen("AAAAB"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAAAB", strlen("AAAAAAB"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUOG=", STRLEN("CPNMUOG="), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("CPNMUOJ1E8======", STRLEN("CPNMUOJ1E8======"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("A", STRLEN("A"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("A", STRLEN("A"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAA", STRLEN("AAA"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAAA", STRLEN("AAAAAA"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AB", STRLEN("AB"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAB", STRLEN("AAAB"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAB", STRLEN("AAAAB"), false, &mem, &len) == -EINVAL);
assert_se(unbase32hexmem("AAAAAAB", STRLEN("AAAAAAB"), false, &mem, &len) == -EINVAL);
}
/* https://tools.ietf.org/html/rfc4648#section-10 */
static void test_base64mem(void) {
char *b64;
assert_se(base64mem("", strlen(""), &b64) == 0);
assert_se(base64mem("", STRLEN(""), &b64) == 0);
assert_se(streq(b64, ""));
free(b64);
assert_se(base64mem("f", strlen("f"), &b64) == 4);
assert_se(base64mem("f", STRLEN("f"), &b64) == 4);
assert_se(streq(b64, "Zg=="));
free(b64);
assert_se(base64mem("fo", strlen("fo"), &b64) == 4);
assert_se(base64mem("fo", STRLEN("fo"), &b64) == 4);
assert_se(streq(b64, "Zm8="));
free(b64);
assert_se(base64mem("foo", strlen("foo"), &b64) == 4);
assert_se(base64mem("foo", STRLEN("foo"), &b64) == 4);
assert_se(streq(b64, "Zm9v"));
free(b64);
assert_se(base64mem("foob", strlen("foob"), &b64) == 8);
assert_se(base64mem("foob", STRLEN("foob"), &b64) == 8);
assert_se(streq(b64, "Zm9vYg=="));
free(b64);
assert_se(base64mem("fooba", strlen("fooba"), &b64) == 8);
assert_se(base64mem("fooba", STRLEN("fooba"), &b64) == 8);
assert_se(streq(b64, "Zm9vYmE="));
free(b64);
assert_se(base64mem("foobar", strlen("foobar"), &b64) == 8);
assert_se(base64mem("foobar", STRLEN("foobar"), &b64) == 8);
assert_se(streq(b64, "Zm9vYmFy"));
free(b64);
}

View File

@ -49,7 +49,7 @@ static void test_get_process_comm(pid_t pid) {
struct stat st;
_cleanup_free_ char *a = NULL, *c = NULL, *d = NULL, *f = NULL, *i = NULL;
_cleanup_free_ char *env = NULL;
char path[strlen("/proc//comm") + DECIMAL_STR_MAX(pid_t)];
char path[STRLEN("/proc//comm") + DECIMAL_STR_MAX(pid_t)];
pid_t e;
uid_t u;
gid_t g;
@ -382,7 +382,7 @@ static void test_rename_process_now(const char *p, int ret) {
/* we cannot expect cmdline to be renamed properly without privileges */
if (geteuid() == 0) {
log_info("cmdline = <%s>", cmdline);
assert_se(strneq(p, cmdline, strlen("test-process-util")));
assert_se(strneq(p, cmdline, STRLEN("test-process-util")));
assert_se(startswith(p, cmdline));
} else
log_info("cmdline = <%s> (not verified)", cmdline);

View File

@ -777,7 +777,7 @@ static int path_set_perms(Item *i, const char *path) {
if (S_ISLNK(st.st_mode))
log_debug("Skipping mode and owner fix for symlink %s.", path);
else {
char fn[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)];
char fn[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)];
xsprintf(fn, "/proc/self/fd/%i", fd);
/* not using i->path directly because it may be a glob */
@ -946,7 +946,7 @@ static int path_set_acl(const char *path, const char *pretty, acl_type_t type, a
static int path_set_acls(Item *item, const char *path) {
int r = 0;
#if HAVE_ACL
char fn[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int)];
char fn[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)];
_cleanup_close_ int fd = -1;
struct stat st;

View File

@ -231,7 +231,7 @@ static size_t subst_format_var(struct udev_event *event, struct udev_device *dev
break;
devnode = udev_device_get_devnode(dev_parent);
if (devnode != NULL)
l = strpcpy(&s, l, devnode + strlen("/dev/"));
l = strpcpy(&s, l, devnode + STRLEN("/dev/"));
break;
}
case SUBST_DEVNODE:
@ -242,7 +242,8 @@ static size_t subst_format_var(struct udev_event *event, struct udev_device *dev
if (event->name != NULL)
l = strpcpy(&s, l, event->name);
else if (udev_device_get_devnode(dev) != NULL)
l = strpcpy(&s, l, udev_device_get_devnode(dev) + strlen("/dev/"));
l = strpcpy(&s, l,
udev_device_get_devnode(dev) + STRLEN("/dev/"));
else
l = strpcpy(&s, l, udev_device_get_sysname(dev));
break;
@ -252,9 +253,12 @@ static size_t subst_format_var(struct udev_event *event, struct udev_device *dev
list_entry = udev_device_get_devlinks_list_entry(dev);
if (list_entry == NULL)
break;
l = strpcpy(&s, l, udev_list_entry_get_name(list_entry) + strlen("/dev/"));
l = strpcpy(&s, l,
udev_list_entry_get_name(list_entry) + STRLEN("/dev/"));
udev_list_entry_foreach(list_entry, udev_list_entry_get_next(list_entry))
l = strpcpyl(&s, l, " ", udev_list_entry_get_name(list_entry) + strlen("/dev/"), NULL);
l = strpcpyl(&s, l, " ",
udev_list_entry_get_name(list_entry) + STRLEN("/dev/"),
NULL);
break;
}
case SUBST_ROOT:

View File

@ -187,7 +187,7 @@ static void link_update(struct udev_device *dev, const char *slink, bool add) {
const char *target;
char buf[UTIL_PATH_SIZE];
util_path_encode(slink + strlen("/dev"), name_enc, sizeof(name_enc));
util_path_encode(slink + STRLEN("/dev"), name_enc, sizeof(name_enc));
strscpyl(dirname, sizeof(dirname), "/run/udev/links/", name_enc, NULL);
strscpyl(filename, sizeof(filename), dirname, "/", udev_device_get_id_filename(dev), NULL);

View File

@ -1098,7 +1098,8 @@ static void add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_M_DRIVER, op, value, NULL);
} else if (startswith(key, "ATTR{")) {
attr = get_key_attribute(rules->udev, key + strlen("ATTR"));
attr = get_key_attribute(rules->udev,
key + STRLEN("ATTR"));
if (attr == NULL)
LOG_AND_RETURN("error parsing %s attribute", "ATTR");
@ -1111,7 +1112,8 @@ static void add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_A_ATTR, op, value, attr);
} else if (startswith(key, "SYSCTL{")) {
attr = get_key_attribute(rules->udev, key + strlen("SYSCTL"));
attr = get_key_attribute(rules->udev,
key + STRLEN("SYSCTL"));
if (attr == NULL)
LOG_AND_RETURN("error parsing %s attribute", "ATTR");
@ -1124,7 +1126,8 @@ static void add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_A_SYSCTL, op, value, attr);
} else if (startswith(key, "SECLABEL{")) {
attr = get_key_attribute(rules->udev, key + strlen("SECLABEL"));
attr = get_key_attribute(rules->udev,
key + STRLEN("SECLABEL"));
if (attr == NULL)
LOG_AND_RETURN("error parsing %s attribute", "SECLABEL");
@ -1155,7 +1158,8 @@ static void add_rule(struct udev_rules *rules, char *line,
if (op > OP_MATCH_MAX)
LOG_AND_RETURN("invalid %s operation", "ATTRS");
attr = get_key_attribute(rules->udev, key + strlen("ATTRS"));
attr = get_key_attribute(rules->udev,
key + STRLEN("ATTRS"));
if (attr == NULL)
LOG_AND_RETURN("error parsing %s attribute", "ATTRS");
@ -1172,7 +1176,8 @@ static void add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_M_TAGS, op, value, NULL);
} else if (startswith(key, "ENV{")) {
attr = get_key_attribute(rules->udev, key + strlen("ENV"));
attr = get_key_attribute(rules->udev,
key + STRLEN("ENV"));
if (attr == NULL)
LOG_AND_RETURN("error parsing %s attribute", "ENV");
@ -1218,7 +1223,8 @@ static void add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_M_RESULT, op, value, NULL);
} else if (startswith(key, "IMPORT")) {
attr = get_key_attribute(rules->udev, key + strlen("IMPORT"));
attr = get_key_attribute(rules->udev,
key + STRLEN("IMPORT"));
if (attr == NULL) {
LOG_RULE_WARNING("ignoring IMPORT{} with missing type");
continue;
@ -1262,7 +1268,8 @@ static void add_rule(struct udev_rules *rules, char *line,
if (op > OP_MATCH_MAX)
LOG_AND_RETURN("invalid %s operation", "TEST");
attr = get_key_attribute(rules->udev, key + strlen("TEST"));
attr = get_key_attribute(rules->udev,
key + STRLEN("TEST"));
if (attr != NULL) {
mode = strtol(attr, NULL, 8);
rule_add_key(&rule_tmp, TK_M_TEST, op, value, &mode);
@ -1270,7 +1277,8 @@ static void add_rule(struct udev_rules *rules, char *line,
rule_add_key(&rule_tmp, TK_M_TEST, op, value, NULL);
} else if (startswith(key, "RUN")) {
attr = get_key_attribute(rules->udev, key + strlen("RUN"));
attr = get_key_attribute(rules->udev,
key + STRLEN("RUN"));
if (attr == NULL)
attr = "program";
if (op == OP_REMOVE)
@ -1389,14 +1397,14 @@ static void add_rule(struct udev_rules *rules, char *line,
pos = strstr(value, "link_priority=");
if (pos != NULL) {
int prio = atoi(pos + strlen("link_priority="));
int prio = atoi(pos + STRLEN("link_priority="));
rule_add_key(&rule_tmp, TK_A_DEVLINK_PRIO, op, NULL, &prio);
}
pos = strstr(value, "string_escape=");
if (pos != NULL) {
pos += strlen("string_escape=");
pos += STRLEN("string_escape=");
if (startswith(pos, "none"))
rule_add_key(&rule_tmp, TK_A_STRING_ESCAPE_NONE, op, NULL, NULL);
else if (startswith(pos, "replace"))
@ -1423,7 +1431,7 @@ static void add_rule(struct udev_rules *rules, char *line,
pos = strstr(value, "static_node=");
if (pos != NULL) {
pos += strlen("static_node=");
pos += STRLEN("static_node=");
rule_add_key(&rule_tmp, TK_A_STATIC_NODE, op, pos, NULL);
rule_tmp.rule.rule.has_static_node = true;
}
@ -1784,7 +1792,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(event->dev)) {
const char *devlink;
devlink = udev_list_entry_get_name(list_entry) + strlen("/dev/");
devlink = udev_list_entry_get_name(list_entry) + STRLEN("/dev/");
if (match_key(rules, cur, devlink) == 0) {
match = true;
break;
@ -2295,7 +2303,7 @@ void udev_rules_apply_to_event(struct udev_rules *rules,
log_debug("%i character(s) replaced", count);
}
if (major(udev_device_get_devnum(event->dev)) &&
!streq(name_str, udev_device_get_devnode(event->dev) + strlen("/dev/"))) {
!streq(name_str, udev_device_get_devnode(event->dev) + STRLEN("/dev/"))) {
log_error("NAME=\"%s\" ignored, kernel device nodes cannot be renamed; please fix it in %s:%u\n",
name,
rules_str(rules, rule->rule.filename_off),

View File

@ -137,14 +137,15 @@ static void print_record(struct udev_device *device) {
str = udev_device_get_devnode(device);
if (str != NULL)
printf("N: %s\n", str + strlen("/dev/"));
printf("N: %s\n", str + STRLEN("/dev/"));
i = udev_device_get_devlink_priority(device);
if (i != 0)
printf("L: %i\n", i);
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device))
printf("S: %s\n", udev_list_entry_get_name(list_entry) + strlen("/dev/"));
printf("S: %s\n",
udev_list_entry_get_name(list_entry) + STRLEN("/dev/"));
udev_list_entry_foreach(list_entry, udev_device_get_properties_list_entry(device))
printf("E: %s=%s\n",
@ -412,7 +413,8 @@ static int uinfo(struct udev *udev, int argc, char *argv[]) {
if (root)
printf("%s\n", udev_device_get_devnode(device));
else
printf("%s\n", udev_device_get_devnode(device) + strlen("/dev/"));
printf("%s\n",
udev_device_get_devnode(device) + STRLEN("/dev/"));
break;
}
case QUERY_SYMLINK:
@ -421,7 +423,8 @@ static int uinfo(struct udev *udev, int argc, char *argv[]) {
if (root)
printf("%s", udev_list_entry_get_name(list_entry));
else
printf("%s", udev_list_entry_get_name(list_entry) + strlen("/dev/"));
printf("%s",
udev_list_entry_get_name(list_entry) + STRLEN("/dev/"));
list_entry = udev_list_entry_get_next(list_entry);
if (list_entry != NULL)
printf(" ");