Skip to content

Commit

Permalink
tree-wide: use new logging helpers
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 26, 2021
1 parent 7244eab commit 766df09
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/lxc/cgroups/cgfsng.c
Expand Up @@ -3028,7 +3028,7 @@ static int __list_cgroup_delegate(char ***delegate)
}

*delegate = move_ptr(list);
return syswarn(0, "Failed to read /sys/kernel/cgroup/delegate");
return syswarn_ret(0, "Failed to read /sys/kernel/cgroup/delegate");
}

lxc_iterate_parts(token, buf, " \t\n") {
Expand Down
6 changes: 3 additions & 3 deletions src/lxc/commands.c
Expand Up @@ -354,7 +354,7 @@ static int __lxc_cmd_rsp_send(int fd, struct lxc_cmd_rsp *rsp)

ret = lxc_send_nointr(fd, rsp->data, rsp->datalen, MSG_NOSIGNAL);
if (ret < 0 || ret != (ssize_t)rsp->datalen)
return syswarn(-errno, "Failed to send command response %zd", ret);
return syswarn("Failed to send command response %zd", ret);

return 0;
}
Expand Down Expand Up @@ -392,7 +392,7 @@ static inline int rsp_one_fd_reap(int fd, int fd_send, struct lxc_cmd_rsp *rsp)
if (rsp->data && rsp->datalen > 0) {
ret = lxc_send_nointr(fd, rsp->data, rsp->datalen, MSG_NOSIGNAL);
if (ret < 0 || ret != (ssize_t)rsp->datalen)
return syswarn(-errno, "Failed to send command response %zd", ret);
return syswarn("Failed to send command response %zd", ret);
}

return LXC_CMD_REAP_CLIENT_FD;
Expand Down Expand Up @@ -430,7 +430,7 @@ __access_r(3, 2) static int rsp_many_fds_reap(int fd, __u32 fds_len,
if (rsp->data && rsp->datalen > 0) {
ret = lxc_send_nointr(fd, rsp->data, rsp->datalen, MSG_NOSIGNAL);
if (ret < 0 || ret != (ssize_t)rsp->datalen)
return syswarn(-errno, "Failed to send command response %zd", ret);
return syswarn("Failed to send command response %zd", ret);
}

return LXC_CMD_REAP_CLIENT_FD;
Expand Down
36 changes: 21 additions & 15 deletions src/lxc/log.h
Expand Up @@ -494,13 +494,6 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
__internal_ret__; \
})

#define syswarn(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
SYSWARN(format, ##__VA_ARGS__); \
__internal_ret__; \
})

#define systrace(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
Expand All @@ -515,14 +508,6 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
__internal_ret__; \
})

#define syswarn_set(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
errno = labs(__ret__); \
SYSWARN(format, ##__VA_ARGS__); \
__internal_ret__; \
})

#define log_error(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
Expand Down Expand Up @@ -612,6 +597,27 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
__internal_ret__; \
})

#define syswarn(format, ...) \
({ \
SYSWARN(format, ##__VA_ARGS__); \
(-errno); \
})

#define syswarn_set(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
errno = labs(__ret__); \
SYSWARN(format, ##__VA_ARGS__); \
__internal_ret__; \
})

#define syswarn_ret(__ret__, format, ...) \
({ \
typeof(__ret__) __internal_ret__ = (__ret__); \
SYSWARN(format, ##__VA_ARGS__); \
__internal_ret__; \
})

#define sysdebug(format, ...) \
({ \
SYSDEBUG(format, ##__VA_ARGS__); \
Expand Down

0 comments on commit 766df09

Please sign in to comment.