mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
tree-wide: use -EBADF for fd initialization
-1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
This commit is contained in:
@@ -3,17 +3,17 @@
|
||||
expression fd;
|
||||
@@
|
||||
- close(fd);
|
||||
- fd = -1;
|
||||
- fd = -EBADF;
|
||||
+ fd = safe_close(fd);
|
||||
@@
|
||||
expression fd;
|
||||
@@
|
||||
- close_nointr(fd);
|
||||
- fd = -1;
|
||||
- fd = -EBADF;
|
||||
+ fd = safe_close(fd);
|
||||
@@
|
||||
expression fd;
|
||||
@@
|
||||
- safe_close(fd);
|
||||
- fd = -1;
|
||||
- fd = -EBADF;
|
||||
+ fd = safe_close(fd);
|
||||
|
||||
@@ -213,7 +213,7 @@ int lock_whole_disk_from_devname(const char *devname, int open_flags, int flock_
|
||||
|
||||
// take the fd to avoid automatic cleanup
|
||||
int ret_fd = fd;
|
||||
fd = -1;
|
||||
fd = -EBADF;
|
||||
return ret_fd;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ static int fork_and_exec_process(const char *child, char **argv, int fd) {
|
||||
|
||||
static int do_accept(const char *name, char **argv, int fd) {
|
||||
_cleanup_free_ char *local = NULL, *peer = NULL;
|
||||
_cleanup_close_ int fd_accepted = -1;
|
||||
_cleanup_close_ int fd_accepted = -EBADF;
|
||||
|
||||
fd_accepted = accept4(fd, NULL, NULL, 0);
|
||||
if (fd_accepted < 0) {
|
||||
@@ -434,7 +434,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int r, n;
|
||||
int epoll_fd = -1;
|
||||
int epoll_fd = -EBADF;
|
||||
|
||||
log_show_color(true);
|
||||
log_parse_environment();
|
||||
|
||||
@@ -18,7 +18,7 @@ static int analyze_elf(char **filenames, JsonFormatFlags json_flags) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *package_metadata = NULL;
|
||||
_cleanup_(table_unrefp) Table *t = NULL;
|
||||
_cleanup_free_ char *abspath = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
r = path_make_absolute_cwd(*filename, &abspath);
|
||||
if (r < 0)
|
||||
|
||||
@@ -80,7 +80,7 @@ int chase_symlinks_at(
|
||||
int *ret_fd) {
|
||||
|
||||
_cleanup_free_ char *buffer = NULL, *done = NULL;
|
||||
_cleanup_close_ int fd = -1, root_fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF, root_fd = -EBADF;
|
||||
unsigned max_follow = CHASE_SYMLINKS_MAX; /* how many symlinks to follow before giving up and returning ELOOP */
|
||||
bool exists = true, append_trail_slash = false;
|
||||
struct stat previous_stat;
|
||||
@@ -227,7 +227,7 @@ int chase_symlinks_at(
|
||||
/* Two dots? Then chop off the last bit of what we already found out. */
|
||||
if (path_equal(first, "..")) {
|
||||
_cleanup_free_ char *parent = NULL;
|
||||
_cleanup_close_ int fd_parent = -1;
|
||||
_cleanup_close_ int fd_parent = -EBADF;
|
||||
|
||||
/* If we already are at the top, then going up will not change anything. This is
|
||||
* in-line with how the kernel handles this. */
|
||||
@@ -415,7 +415,7 @@ int chase_symlinks(
|
||||
int *ret_fd) {
|
||||
|
||||
_cleanup_free_ char *root = NULL, *absolute = NULL, *p = NULL;
|
||||
_cleanup_close_ int fd = -1, pfd = -1;
|
||||
_cleanup_close_ int fd = -EBADF, pfd = -EBADF;
|
||||
int r;
|
||||
|
||||
assert(path);
|
||||
@@ -496,7 +496,7 @@ int chase_symlinks_and_open(
|
||||
int open_flags,
|
||||
char **ret_path) {
|
||||
|
||||
_cleanup_close_ int path_fd = -1;
|
||||
_cleanup_close_ int path_fd = -EBADF;
|
||||
_cleanup_free_ char *p = NULL;
|
||||
int r;
|
||||
|
||||
@@ -534,7 +534,7 @@ int chase_symlinks_and_opendir(
|
||||
char **ret_path,
|
||||
DIR **ret_dir) {
|
||||
|
||||
_cleanup_close_ int path_fd = -1;
|
||||
_cleanup_close_ int path_fd = -EBADF;
|
||||
_cleanup_free_ char *p = NULL;
|
||||
DIR *d;
|
||||
int r;
|
||||
@@ -578,7 +578,7 @@ int chase_symlinks_and_stat(
|
||||
struct stat *ret_stat,
|
||||
int *ret_fd) {
|
||||
|
||||
_cleanup_close_ int path_fd = -1;
|
||||
_cleanup_close_ int path_fd = -EBADF;
|
||||
_cleanup_free_ char *p = NULL;
|
||||
int r;
|
||||
|
||||
@@ -621,7 +621,7 @@ int chase_symlinks_and_access(
|
||||
char **ret_path,
|
||||
int *ret_fd) {
|
||||
|
||||
_cleanup_close_ int path_fd = -1;
|
||||
_cleanup_close_ int path_fd = -EBADF;
|
||||
_cleanup_free_ char *p = NULL;
|
||||
int r;
|
||||
|
||||
@@ -665,7 +665,7 @@ int chase_symlinks_and_fopen_unlocked(
|
||||
FILE **ret_file) {
|
||||
|
||||
_cleanup_free_ char *final_path = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
int mode_flags, r;
|
||||
|
||||
assert(path);
|
||||
|
||||
@@ -20,7 +20,7 @@ int chattr_full(const char *path,
|
||||
unsigned *ret_final,
|
||||
ChattrApplyFlags flags) {
|
||||
|
||||
_cleanup_close_ int fd_will_close = -1;
|
||||
_cleanup_close_ int fd_will_close = -EBADF;
|
||||
unsigned old_attr, new_attr;
|
||||
int set_flags_errno = 0;
|
||||
struct stat st;
|
||||
@@ -149,7 +149,7 @@ int read_attr_fd(int fd, unsigned *ret) {
|
||||
}
|
||||
|
||||
int read_attr_path(const char *p, unsigned *ret) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
assert(p);
|
||||
assert(ret);
|
||||
|
||||
@@ -37,7 +37,7 @@ int efi_get_variable(
|
||||
void **ret_value,
|
||||
size_t *ret_size) {
|
||||
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
_cleanup_free_ void *buf = NULL;
|
||||
struct stat st;
|
||||
usec_t begin = 0; /* Unnecessary initialization to appease gcc */
|
||||
@@ -181,7 +181,7 @@ int efi_set_variable(const char *variable, const void *value, size_t size) {
|
||||
uint32_t attr;
|
||||
char buf[];
|
||||
} _packed_ * _cleanup_free_ buf = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
uint32_t attr = EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS;
|
||||
bool saved_flags_valid = false;
|
||||
unsigned saved_flags;
|
||||
|
||||
@@ -56,11 +56,9 @@ int close_nointr(int fd) {
|
||||
}
|
||||
|
||||
int safe_close(int fd) {
|
||||
|
||||
/*
|
||||
* Like close_nointr() but cannot fail. Guarantees errno is
|
||||
* unchanged. Is a NOP with negative fds passed, and returns
|
||||
* -1, so that it can be used in this syntax:
|
||||
* Like close_nointr() but cannot fail. Guarantees errno is unchanged. Is a noop for negative fds,
|
||||
* and returns -EBADF, so that it can be used in this syntax:
|
||||
*
|
||||
* fd = safe_close(fd);
|
||||
*/
|
||||
@@ -76,7 +74,7 @@ int safe_close(int fd) {
|
||||
assert_se(close_nointr(fd) != -EBADF);
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
void safe_close_pair(int p[static 2]) {
|
||||
@@ -412,7 +410,7 @@ int close_all_fds(const int except[], size_t n_except) {
|
||||
return close_all_fds_frugal(except, n_except); /* ultimate fallback if /proc/ is not available */
|
||||
|
||||
FOREACH_DIRENT(de, d, return -errno) {
|
||||
int fd = -1, q;
|
||||
int fd = -EBADF, q;
|
||||
|
||||
if (!IN_SET(de->d_type, DT_LNK, DT_UNKNOWN))
|
||||
continue;
|
||||
@@ -639,17 +637,19 @@ int rearrange_stdio(int original_input_fd, int original_output_fd, int original_
|
||||
};
|
||||
|
||||
int r, i,
|
||||
null_fd = -1, /* if we open /dev/null, we store the fd to it here */
|
||||
copy_fd[3] = { -1, -1, -1 }; /* This contains all fds we duplicate here temporarily, and hence need to close at the end */
|
||||
null_fd = -EBADF, /* If we open /dev/null, we store the fd to it here */
|
||||
copy_fd[3] = { -EBADF, -EBADF, -EBADF }; /* This contains all fds we duplicate here
|
||||
* temporarily, and hence need to close at the end. */
|
||||
bool null_readable, null_writable;
|
||||
|
||||
/* Sets up stdin, stdout, stderr with the three file descriptors passed in. If any of the descriptors is
|
||||
* specified as -1 it will be connected with /dev/null instead. If any of the file descriptors is passed as
|
||||
* itself (e.g. stdin as STDIN_FILENO) it is left unmodified, but the O_CLOEXEC bit is turned off should it be
|
||||
* on.
|
||||
/* Sets up stdin, stdout, stderr with the three file descriptors passed in. If any of the descriptors
|
||||
* is specified as -EBADF it will be connected with /dev/null instead. If any of the file descriptors
|
||||
* is passed as itself (e.g. stdin as STDIN_FILENO) it is left unmodified, but the O_CLOEXEC bit is
|
||||
* turned off should it be on.
|
||||
*
|
||||
* Note that if any of the passed file descriptors are > 2 they will be closed — both on success and on
|
||||
* failure! Thus, callers should assume that when this function returns the input fds are invalidated.
|
||||
* Note that if any of the passed file descriptors are > 2 they will be closed — both on success and
|
||||
* on failure! Thus, callers should assume that when this function returns the input fds are
|
||||
* invalidated.
|
||||
*
|
||||
* Note that when this function fails stdin/stdout/stderr might remain half set up!
|
||||
*
|
||||
@@ -701,9 +701,9 @@ int rearrange_stdio(int original_input_fd, int original_output_fd, int original_
|
||||
}
|
||||
}
|
||||
|
||||
/* At this point we now have the fds to use in fd[], and they are all above the stdio range, so that we
|
||||
* have freedom to move them around. If the fds already were at the right places then the specific fds are
|
||||
* -1. Let's now move them to the right places. This is the point of no return. */
|
||||
/* At this point we now have the fds to use in fd[], and they are all above the stdio range, so that
|
||||
* we have freedom to move them around. If the fds already were at the right places then the specific
|
||||
* fds are -EBADF. Let's now move them to the right places. This is the point of no return. */
|
||||
for (i = 0; i < 3; i++) {
|
||||
|
||||
if (fd[i] == i) {
|
||||
@@ -800,7 +800,7 @@ int fd_reopen_condition(
|
||||
return -errno;
|
||||
|
||||
if ((r & mask) == (flags & mask)) {
|
||||
*ret_new_fd = -1;
|
||||
*ret_new_fd = -EBADF;
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ static inline int make_null_stdio(void) {
|
||||
({ \
|
||||
int *_fd_ = &(fd); \
|
||||
int _ret_ = *_fd_; \
|
||||
*_fd_ = -1; \
|
||||
*_fd_ = -EBADF; \
|
||||
_ret_; \
|
||||
})
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ int take_fdopen_unlocked(int *fd, const char *options, FILE **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*fd = -1;
|
||||
*fd = -EBADF;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ FILE* take_fdopen(int *fd, const char *options) {
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
*fd = -1;
|
||||
*fd = -EBADF;
|
||||
|
||||
return f;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ DIR* take_fdopendir(int *dfd) {
|
||||
if (!d)
|
||||
return NULL;
|
||||
|
||||
*dfd = -1;
|
||||
*dfd = -EBADF;
|
||||
|
||||
return d;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ int write_string_stream_ts(
|
||||
const struct timespec *ts) {
|
||||
|
||||
bool needs_nl;
|
||||
int r, fd = -1;
|
||||
int r, fd = -EBADF;
|
||||
|
||||
assert(f);
|
||||
assert(line);
|
||||
@@ -558,7 +558,7 @@ int read_virtual_file_at(
|
||||
char **ret_contents,
|
||||
size_t *ret_size) {
|
||||
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ int readlink_and_make_absolute(const char *p, char **r) {
|
||||
}
|
||||
|
||||
int chmod_and_chown_at(int dir_fd, const char *path, mode_t mode, uid_t uid, gid_t gid) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
|
||||
|
||||
@@ -360,7 +360,7 @@ int fd_warn_permissions(const char *path, int fd) {
|
||||
}
|
||||
|
||||
int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
int r, ret;
|
||||
|
||||
assert(path);
|
||||
@@ -684,7 +684,7 @@ void unlink_tempfilep(char (*p)[]) {
|
||||
}
|
||||
|
||||
int unlinkat_deallocate(int fd, const char *name, UnlinkDeallocateFlags flags) {
|
||||
_cleanup_close_ int truncate_fd = -1;
|
||||
_cleanup_close_ int truncate_fd = -EBADF;
|
||||
struct stat st;
|
||||
off_t l, bs;
|
||||
|
||||
@@ -815,7 +815,7 @@ int conservative_renameat(
|
||||
int olddirfd, const char *oldpath,
|
||||
int newdirfd, const char *newpath) {
|
||||
|
||||
_cleanup_close_ int old_fd = -1, new_fd = -1;
|
||||
_cleanup_close_ int old_fd = -EBADF, new_fd = -EBADF;
|
||||
struct stat old_stat, new_stat;
|
||||
|
||||
/* Renames the old path to thew new path, much like renameat() — except if both are regular files and
|
||||
@@ -997,7 +997,7 @@ int parse_cifs_service(
|
||||
}
|
||||
|
||||
int open_mkdir_at(int dirfd, const char *path, int flags, mode_t mode) {
|
||||
_cleanup_close_ int fd = -1, parent_fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF, parent_fd = -EBADF;
|
||||
_cleanup_free_ char *fname = NULL;
|
||||
bool made;
|
||||
int r;
|
||||
|
||||
@@ -95,7 +95,7 @@ static int add_locales_from_archive(Set *locales) {
|
||||
const struct locarhead *h;
|
||||
const struct namehashent *e;
|
||||
const void *p = MAP_FAILED;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
size_t sz = 0;
|
||||
struct stat st;
|
||||
int r;
|
||||
|
||||
@@ -48,9 +48,9 @@ static int log_max_level = LOG_INFO;
|
||||
static int log_facility = LOG_DAEMON;
|
||||
|
||||
static int console_fd = STDERR_FILENO;
|
||||
static int syslog_fd = -1;
|
||||
static int kmsg_fd = -1;
|
||||
static int journal_fd = -1;
|
||||
static int syslog_fd = -EBADF;
|
||||
static int kmsg_fd = -EBADF;
|
||||
static int journal_fd = -EBADF;
|
||||
|
||||
static bool syslog_is_stream = false;
|
||||
|
||||
@@ -345,7 +345,7 @@ void log_close(void) {
|
||||
void log_forget_fds(void) {
|
||||
/* Do not call from library code. */
|
||||
|
||||
console_fd = kmsg_fd = syslog_fd = journal_fd = -1;
|
||||
console_fd = kmsg_fd = syslog_fd = journal_fd = -EBADF;
|
||||
}
|
||||
|
||||
void log_set_max_level(int level) {
|
||||
|
||||
@@ -113,7 +113,7 @@ int memfd_set_size(int fd, uint64_t sz) {
|
||||
}
|
||||
|
||||
int memfd_new_and_map(const char *name, size_t sz, void **p) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
int r;
|
||||
|
||||
assert(sz > 0);
|
||||
|
||||
@@ -211,7 +211,7 @@ int mkdir_p_safe(const char *prefix, const char *path, mode_t mode, uid_t uid, g
|
||||
|
||||
int mkdir_p_root(const char *root, const char *p, uid_t uid, gid_t gid, mode_t m) {
|
||||
_cleanup_free_ char *pp = NULL, *bn = NULL;
|
||||
_cleanup_close_ int dfd = -1;
|
||||
_cleanup_close_ int dfd = -EBADF;
|
||||
int r;
|
||||
|
||||
r = path_extract_directory(p, &pp);
|
||||
@@ -250,7 +250,7 @@ int mkdir_p_root(const char *root, const char *p, uid_t uid, gid_t gid, mode_t m
|
||||
}
|
||||
|
||||
if (uid_is_valid(uid) || gid_is_valid(gid)) {
|
||||
_cleanup_close_ int nfd = -1;
|
||||
_cleanup_close_ int nfd = -EBADF;
|
||||
|
||||
nfd = openat(dfd, bn, O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
|
||||
if (nfd < 0)
|
||||
|
||||
@@ -97,7 +97,7 @@ int name_to_handle_at_loop(
|
||||
static int fd_fdinfo_mnt_id(int fd, const char *filename, int flags, int *ret_mnt_id) {
|
||||
char path[STRLEN("/proc/self/fdinfo/") + DECIMAL_STR_MAX(int)];
|
||||
_cleanup_free_ char *fdinfo = NULL;
|
||||
_cleanup_close_ int subfd = -1;
|
||||
_cleanup_close_ int subfd = -EBADF;
|
||||
char *p;
|
||||
int r;
|
||||
|
||||
@@ -322,7 +322,7 @@ fallback_fstat:
|
||||
/* flags can be AT_SYMLINK_FOLLOW or 0 */
|
||||
int path_is_mount_point(const char *t, const char *root, int flags) {
|
||||
_cleanup_free_ char *canonical = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
int r;
|
||||
|
||||
assert(t);
|
||||
@@ -550,7 +550,7 @@ int mount_nofollow(
|
||||
unsigned long mountflags,
|
||||
const void *data) {
|
||||
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
/* In almost all cases we want to manipulate the mount table without following symlinks, hence
|
||||
* mount_nofollow() is usually the way to go. The only exceptions are environments where /proc/ is
|
||||
|
||||
@@ -34,8 +34,8 @@ const struct namespace_info namespace_info[] = {
|
||||
#define pid_namespace_path(pid, type) procfs_file_alloca(pid, namespace_info[type].proc_path)
|
||||
|
||||
int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *netns_fd, int *userns_fd, int *root_fd) {
|
||||
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, netnsfd = -1, usernsfd = -1;
|
||||
int rfd = -1;
|
||||
_cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, netnsfd = -EBADF, usernsfd = -EBADF;
|
||||
int rfd = -EBADF;
|
||||
|
||||
assert(pid >= 0);
|
||||
|
||||
@@ -113,7 +113,7 @@ int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r)
|
||||
userns_fd = -1;
|
||||
userns_fd = -EBADF;
|
||||
}
|
||||
|
||||
if (pidns_fd >= 0)
|
||||
@@ -202,7 +202,7 @@ int detach_mount_namespace(void) {
|
||||
int userns_acquire(const char *uid_map, const char *gid_map) {
|
||||
char path[STRLEN("/proc//uid_map") + DECIMAL_STR_MAX(pid_t) + 1];
|
||||
_cleanup_(sigkill_waitp) pid_t pid = 0;
|
||||
_cleanup_close_ int userns_fd = -1;
|
||||
_cleanup_close_ int userns_fd = -EBADF;
|
||||
int r;
|
||||
|
||||
assert(uid_map);
|
||||
|
||||
@@ -227,7 +227,7 @@ int open_extension_release(const char *root, const char *extension, bool relax_e
|
||||
|
||||
int fopen_extension_release(const char *root, const char *extension, bool relax_extension_release_check, char **ret_path, FILE **ret_file) {
|
||||
_cleanup_free_ char *p = NULL;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
FILE *f;
|
||||
int r;
|
||||
|
||||
|
||||
@@ -587,7 +587,7 @@ char* path_extend_internal(char **x, ...) {
|
||||
}
|
||||
|
||||
static int check_x_access(const char *path, int *ret_fd) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
int r;
|
||||
|
||||
/* We need to use O_PATH because there may be executables for which we have only exec
|
||||
@@ -615,7 +615,7 @@ static int check_x_access(const char *path, int *ret_fd) {
|
||||
}
|
||||
|
||||
static int find_executable_impl(const char *name, const char *root, char **ret_filename, int *ret_fd) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
_cleanup_free_ char *path_name = NULL;
|
||||
int r;
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ static void fallback_random_bytes(void *p, size_t n) {
|
||||
|
||||
void random_bytes(void *p, size_t n) {
|
||||
static bool have_getrandom = true, have_grndinsecure = true;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
if (n == 0)
|
||||
return;
|
||||
@@ -117,7 +117,7 @@ void random_bytes(void *p, size_t n) {
|
||||
|
||||
int crypto_random_bytes(void *p, size_t n) {
|
||||
static bool have_getrandom = true, seen_initialized = false;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
|
||||
if (n == 0)
|
||||
return 0;
|
||||
@@ -145,7 +145,7 @@ int crypto_random_bytes(void *p, size_t n) {
|
||||
}
|
||||
|
||||
if (!seen_initialized) {
|
||||
_cleanup_close_ int ready_fd = -1;
|
||||
_cleanup_close_ int ready_fd = -EBADF;
|
||||
int r;
|
||||
|
||||
ready_fd = open("/dev/random", O_RDONLY|O_CLOEXEC|O_NOCTTY);
|
||||
@@ -187,7 +187,7 @@ size_t random_pool_size(void) {
|
||||
}
|
||||
|
||||
int random_write_entropy(int fd, const void *seed, size_t size, bool credit) {
|
||||
_cleanup_close_ int opened_fd = -1;
|
||||
_cleanup_close_ int opened_fd = -EBADF;
|
||||
int r;
|
||||
|
||||
assert(seed || size == 0);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user