const char *name,
int fd) {
- union {
- struct cmsghdr cmsghdr;
- uint8_t buf[CMSG_SPACE(sizeof(int))];
- } control = {};
+ CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int))) control = {};
struct iovec iovec;
struct msghdr mh = {
.msg_control = &control,
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
memcpy(CMSG_DATA(cmsg), &data_fd, sizeof(int));
- mh.msg_controllen = CMSG_SPACE(sizeof(int));
iovec = IOVEC_MAKE_STRING(name);
if (sendmsg(socket_fd, &mh, MSG_NOSIGNAL) < 0)
char **ret_name,
int *ret_fd) {
- union {
- struct cmsghdr cmsghdr;
- uint8_t buf[CMSG_SPACE(sizeof(int))];
- } control = {};
+ CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(int))) control;
char buffer[PATH_MAX+2];
struct iovec iov = IOVEC_INIT(buffer, sizeof(buffer)-1);
struct msghdr mh = {
return log_debug_errno(errno, "Failed to open '%s' directory: %m", where);
}
- unit_files = set_new(&string_hash_ops);
- if (!unit_files)
- return -ENOMEM;
-
markers = set_new(&path_hash_ops);
if (!markers)
return -ENOMEM;
continue;
/* Filter out duplicates */
- if (set_get(unit_files, de->d_name))
+ if (set_contains(unit_files, de->d_name))
continue;
dirent_ensure_type(d, de);
if (r > 0)
return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, "Unit file '%s' is active, can't detach.", de->d_name);
- r = set_put_strdup(unit_files, de->d_name);
+ r = set_put_strdup(&unit_files, de->d_name);
if (r < 0)
return log_debug_errno(r, "Failed to add unit name '%s' to set: %m", de->d_name);
_cleanup_(lookup_paths_free) LookupPaths paths = {};
bool found_enabled = false, found_running = false;
- _cleanup_set_free_free_ Set *unit_files = NULL;
+ _cleanup_set_free_ Set *unit_files = NULL;
_cleanup_closedir_ DIR *d = NULL;
const char *where;
struct dirent *de;
return log_debug_errno(errno, "Failed to open '%s' directory: %m", where);
}
- unit_files = set_new(&string_hash_ops);
- if (!unit_files)
- return -ENOMEM;
-
FOREACH_DIRENT(de, d, return log_debug_errno(errno, "Failed to enumerate '%s' directory: %m", where)) {
UnitFileState state;
continue;
/* Filter out duplicates */
- if (set_get(unit_files, de->d_name))
+ if (set_contains(unit_files, de->d_name))
continue;
dirent_ensure_type(d, de);
if (r > 0)
found_running = true;
- r = set_put_strdup(unit_files, de->d_name);
+ r = set_put_strdup(&unit_files, de->d_name);
if (r < 0)
return log_debug_errno(r, "Failed to add unit name '%s' to set: %m", de->d_name);
}