previous_stat = st;
}
- safe_close(fd);
- fd = TAKE_FD(fd_parent);
+ close_and_replace(fd, fd_parent);
continue;
}
return -ENOMEM;
/* And iterate again, but go one directory further down. */
- safe_close(fd);
- fd = TAKE_FD(child);
+ close_and_replace(fd, child);
}
if (ret_path)
goto finish;
}
- CLOSE_AND_REPLACE(null_fd, copy);
+ close_and_replace(null_fd, copy);
}
}
})
/* Like free_and_replace(), but for file descriptors */
-#define CLOSE_AND_REPLACE(a, b) \
+#define close_and_replace(a, b) \
({ \
int *_fdp_ = &(a); \
safe_close(*_fdp_); \
if (r < 0)
return -errno;
- CLOSE_AND_REPLACE(fd, r);
+ close_and_replace(fd, r);
}
*ret_fd = fds[*n_fds] = fd;
if (taken_fd < 0)
return (void) log_debug("Got notify message with SYSTEMD_LUKS_LOCK_FD=1 but no fd passed, ignoring: %m");
- safe_close(h->luks_lock_fd);
- h->luks_lock_fd = TAKE_FD(taken_fd);
+ close_and_replace(h->luks_lock_fd, taken_fd);
log_debug("Successfully acquired LUKS lock fd from worker.");
unlink_and_free(i->temp_path);
i->temp_path = TAKE_PTR(t);
- CLOSE_AND_REPLACE(i->output_fd, converted_fd);
+ close_and_replace(i->output_fd, converted_fd);
return 1;
}
unlink_and_free(i->temp_path);
i->temp_path = TAKE_PTR(t);
- CLOSE_AND_REPLACE(i->raw_job->disk_fd, converted_fd);
+ close_and_replace(i->raw_job->disk_fd, converted_fd);
return 1;
}
if (r < 0)
return r;
- CLOSE_AND_REPLACE(acd->fd, r);
+ close_and_replace(acd->fd, r);
if (reset_conflicts)
acd->n_conflict = 0;
/* For evdev devices, the file descriptor might be left uninitialized. This might happen while resuming
* into a session and logind has been restarted right before. */
- CLOSE_AND_REPLACE(sd->fd, r);
+ close_and_replace(sd->fd, r);
break;
case DEVICE_TYPE_UNKNOWN:
if (f != 0)
return -errno;
- CLOSE_AND_REPLACE(copy_fd, tmp_fd);
+ close_and_replace(copy_fd, tmp_fd);
remains = mfree(remains);
remains_size = 0;
return log_error_errno(r, "Failed to stat \"%s\" at \"%s\": %m", t, strnull(parent_name));
}
- CLOSE_AND_REPLACE(parent_fd, next_fd);
+ close_and_replace(parent_fd, next_fd);
}
}