summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/net/ethtool-util.c3
-rw-r--r--src/udev/scsi_id/scsi_serial.c3
-rw-r--r--src/udev/udev-ctrl.c14
-rw-r--r--src/udev/udev-event.c26
-rw-r--r--src/udev/udev-rules.c12
-rw-r--r--src/udev/udevd.c3
6 files changed, 17 insertions, 44 deletions
diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c
index 927b8abc64..a4b05d1bec 100644
--- a/src/udev/net/ethtool-util.c
+++ b/src/udev/net/ethtool-util.c
@@ -54,9 +54,8 @@ int ethtool_connect(int *ret) {
assert_return(ret, -EINVAL);
fd = socket(PF_INET, SOCK_DGRAM, 0);
- if (fd < 0) {
+ if (fd < 0)
return -errno;
- }
*ret = fd;
diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c
index 3691a69d48..69260cb1a0 100644
--- a/src/udev/scsi_id/scsi_serial.c
+++ b/src/udev/scsi_id/scsi_serial.c
@@ -577,9 +577,8 @@ static int check_fill_0x83_id(struct udev *udev,
if (id_search->id_type == SCSI_ID_NAA && wwn != NULL) {
strncpy(wwn, &serial[s], 16);
- if (wwn_vendor_extension != NULL) {
+ if (wwn_vendor_extension != NULL)
strncpy(wwn_vendor_extension, &serial[s + 16], 16);
- }
}
return 0;
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index ead7c92b27..56277f551f 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -121,18 +121,12 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) {
err = bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen);
}
- if (err < 0) {
- err = -errno;
- log_error_errno(errno, "bind failed: %m");
- return err;
- }
+ if (err < 0)
+ return log_error_errno(errno, "bind failed: %m");
err = listen(uctrl->sock, 0);
- if (err < 0) {
- err = -errno;
- log_error_errno(errno, "listen failed: %m");
- return err;
- }
+ if (err < 0)
+ return log_error_errno(errno, "listen failed: %m");
uctrl->bound = true;
uctrl->cleanup_socket = true;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 4761222786..1e34cbc2f5 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -731,15 +731,13 @@ int udev_event_spawn(struct udev_event *event,
/* pipes from child to parent */
if (result != NULL || log_get_max_level() >= LOG_INFO) {
if (pipe2(outpipe, O_NONBLOCK) != 0) {
- err = -errno;
- log_error_errno(errno, "pipe failed: %m");
+ err = log_error_errno(errno, "pipe failed: %m");
goto out;
}
}
if (log_get_max_level() >= LOG_INFO) {
if (pipe2(errpipe, O_NONBLOCK) != 0) {
- err = -errno;
- log_error_errno(errno, "pipe failed: %m");
+ err = log_error_errno(errno, "pipe failed: %m");
goto out;
}
}
@@ -753,14 +751,8 @@ int udev_event_spawn(struct udev_event *event,
char program[UTIL_PATH_SIZE];
/* child closes parent's ends of pipes */
- if (outpipe[READ_END] >= 0) {
- close(outpipe[READ_END]);
- outpipe[READ_END] = -1;
- }
- if (errpipe[READ_END] >= 0) {
- close(errpipe[READ_END]);
- errpipe[READ_END] = -1;
- }
+ outpipe[READ_END] = safe_close(outpipe[READ_END]);
+ errpipe[READ_END] = safe_close(errpipe[READ_END]);
strscpy(arg, sizeof(arg), cmd);
udev_build_argv(event->udev, arg, NULL, argv);
@@ -784,14 +776,8 @@ int udev_event_spawn(struct udev_event *event,
goto out;
default:
/* parent closed child's ends of pipes */
- if (outpipe[WRITE_END] >= 0) {
- close(outpipe[WRITE_END]);
- outpipe[WRITE_END] = -1;
- }
- if (errpipe[WRITE_END] >= 0) {
- close(errpipe[WRITE_END]);
- errpipe[WRITE_END] = -1;
- }
+ outpipe[WRITE_END] = safe_close(outpipe[WRITE_END]);
+ errpipe[WRITE_END] = safe_close(errpipe[WRITE_END]);
spawn_read(event,
timeout_usec,
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 43255fb9d4..822f292217 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -672,9 +672,8 @@ static int import_parent_into_properties(struct udev_device *dev, const char *fi
const char *key = udev_list_entry_get_name(list_entry);
const char *val = udev_list_entry_get_value(list_entry);
- if (fnmatch(filter, key, 0) == 0) {
+ if (fnmatch(filter, key, 0) == 0)
udev_device_add_property(dev, key, val);
- }
}
return 0;
}
@@ -1686,12 +1685,10 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
strbuf_complete(rules->strbuf);
/* cleanup uid/gid cache */
- free(rules->uids);
- rules->uids = NULL;
+ rules->uids = mfree(rules->uids);
rules->uids_cur = 0;
rules->uids_max = 0;
- free(rules->gids);
- rules->gids = NULL;
+ rules->gids = mfree(rules->gids);
rules->gids_cur = 0;
rules->gids_max = 0;
@@ -2064,8 +2061,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules,
char program[UTIL_PATH_SIZE];
char result[UTIL_LINE_SIZE];
- free(event->program_result);
- event->program_result = NULL;
+ event->program_result = mfree(event->program_result);
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), program, sizeof(program));
log_debug("PROGRAM '%s' %s:%u",
program,
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index f354ced2e2..20497ae8be 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1670,9 +1670,8 @@ int main(int argc, char *argv[]) {
arg_children_max = 8;
- if (sched_getaffinity(0, sizeof (cpu_set), &cpu_set) == 0) {
+ if (sched_getaffinity(0, sizeof(cpu_set), &cpu_set) == 0)
arg_children_max += CPU_COUNT(&cpu_set) * 2;
- }
log_debug("set children_max to %u", arg_children_max);
}