ASSERT_OK(pidref_set_pid(&pid1, 1));
uid_t uid;
- r = audit_loginuid_from_pid(&self, &uid);
- if (r != -ENODATA)
- ASSERT_OK(r);
+ ASSERT_OK_OR(r = audit_loginuid_from_pid(&self, &uid), -ENODATA);
if (r >= 0)
log_info("self audit login uid: " UID_FMT, uid);
ASSERT_ERROR(audit_loginuid_from_pid(&pid1, &uid), ENODATA);
uint32_t sessionid;
- r = audit_session_from_pid(&self, &sessionid);
- if (r != -ENODATA)
- ASSERT_OK(r);
+ ASSERT_OK_OR(r = audit_session_from_pid(&self, &sessionid), -ENODATA);
if (r >= 0)
log_info("self audit session id: %" PRIu32, sessionid);
continue;
r = cg_pid_get_path_shifted(pid.pid, NULL, &path_shifted);
- if (r != -ESRCH)
- ASSERT_OK(r);
+ ASSERT_OK_OR(r, -ESRCH);
r = cg_pidref_get_unit(&pid, &unit);
- if (r != -ESRCH)
- ASSERT_OK(r);
+ ASSERT_OK_OR(r, -ESRCH);
r = cg_pid_get_slice(pid.pid, &slice);
- if (r != -ESRCH)
- ASSERT_OK(r);
+ ASSERT_OK_OR(r, -ESRCH);
/* Not all processes belong to a specific user or a machine */
r = cg_pidref_get_owner_uid(&pid, &uid);
- if (!IN_SET(r, -ESRCH, -ENXIO))
- ASSERT_OK(r);
+ ASSERT_OK_OR(r, -ESRCH, -ENXIO);
r = cg_pidref_get_session(&pid, &session);
- if (!IN_SET(r, -ESRCH, -ENXIO))
- ASSERT_OK(r);
+ ASSERT_OK_OR(r, -ESRCH, -ENXIO);
r = cg_pid_get_user_unit(pid.pid, &user_unit);
- if (!IN_SET(r, -ESRCH, -ENXIO))
- ASSERT_OK(r);
+ ASSERT_OK_OR(r, -ESRCH, -ENXIO);
r = cg_pid_get_machine_name(pid.pid, &machine);
- if (!IN_SET(r, -ESRCH, -ENOENT))
- ASSERT_OK(r);
+ ASSERT_OK_OR(r, -ESRCH, -ENOENT);
log_debug(PID_FMT": %s, %s, "UID_FMT", %s, %s, %s, %s, %s",
pid.pid,
slice = UNIT_GET_SLICE(unit);
if (slice) {
start_parent_slices(slice);
- int r = unit_start(slice, NULL);
- if (r != -EALREADY)
- ASSERT_OK(r);
+ ASSERT_OK_OR(unit_start(slice, NULL), -EALREADY);
}
}
ASSERT_OK(r);
if (r == 0) {
_cleanup_free_ char *unit_dir = NULL, *build_dir = NULL, *build_dir_mount = NULL;
- int ret;
const char *coverage = getenv("COVERAGE_BUILD_DIR");
if (!coverage)
ASSERT_OK(copy_directory_at(AT_FDCWD, unit_dir, AT_FDCWD, PRIVATE_UNIT_DIR, COPY_MERGE_EMPTY));
/* Mount tmpfs on the following directories to make not StateDirectory= or friends disturb the host. */
- ret = get_build_exec_dir(&build_dir);
- if (ret != -ENOEXEC)
- ASSERT_OK(ret);
+ ASSERT_OK_OR(get_build_exec_dir(&build_dir), -ENOEXEC);
if (build_dir) {
/* Account for a build directory being in one of the soon-to-be-tmpfs directories. If we
ASSERT_OK(mount_nofollow_verbose(LOG_DEBUG, "tmpfs", p, "tmpfs", MS_NOSUID|MS_NODEV, NULL));
if (build_dir_mount) {
- ret = RET_NERRNO(access(build_dir, F_OK));
- if (ret != -ENOENT)
- ASSERT_OK(ret);
+ int k;
- if (ret == -ENOENT) {
+ ASSERT_OK_OR(k = RET_NERRNO(access(build_dir, F_OK)), -ENOENT);
+
+ if (k == -ENOENT) {
/* The build directory got overmounted by tmpfs, so let's use the "backup" bind mount to
* bring it back. */
ASSERT_OK(mkdir_p(build_dir, 0755));
ASSERT_TRUE(pid_is_kernel_thread(pid) == 0 || pid != 1);
- r = get_process_exe(pid, &f);
- if (r != -EACCES)
- ASSERT_OK(r);
+ ASSERT_OK_OR(get_process_exe(pid, &f), -EACCES);
log_info("PID"PID_FMT" exe: '%s'", pid, strna(f));
ASSERT_OK_ZERO(pid_get_uid(pid, &u));
ASSERT_OK_ZERO(get_process_gid(pid, &g));
log_info("PID"PID_FMT" GID: "GID_FMT, pid, g);
- r = get_process_environ(pid, &env);
- if (r != -EACCES)
- ASSERT_OK(r);
+ ASSERT_OK_OR(get_process_environ(pid, &env), -EACCES);
log_info("PID"PID_FMT" strlen(environ): %zi", pid, env ? (ssize_t)strlen(env) : (ssize_t)-errno);
if (!detect_container() && pid == 1)
for (;;) {
pid_t pid;
-
- r = proc_dir_read(d, &pid);
- ASSERT_OK(r);
+ ASSERT_OK(r = proc_dir_read(d, &pid));
if (r == 0) /* EOF */
break;