mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
tree-wide: drop redundant if checks before safe_close()
Replace this: if (fd >= 0) safe_close(fd); by this: safe_close(fd);
This commit is contained in:
parent
66e405837b
commit
7f6e12b033
7
coccinelle/safe_close-no-if.cocci
Normal file
7
coccinelle/safe_close-no-if.cocci
Normal file
@ -0,0 +1,7 @@
|
||||
@@
|
||||
expression fd;
|
||||
@@
|
||||
- if (fd >= 0) {
|
||||
- fd = safe_close(fd);
|
||||
- }
|
||||
+ fd = safe_close(fd);
|
@ -239,9 +239,7 @@ int button_open(Button *b) {
|
||||
|
||||
assert(b);
|
||||
|
||||
if (b->fd >= 0) {
|
||||
b->fd = safe_close(b->fd);
|
||||
}
|
||||
b->fd = safe_close(b->fd);
|
||||
|
||||
p = strjoina("/dev/input/", b->name);
|
||||
|
||||
|
@ -753,12 +753,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) {
|
||||
outpipe[READ_END] = safe_close(outpipe[READ_END]);
|
||||
}
|
||||
if (errpipe[READ_END] >= 0) {
|
||||
errpipe[READ_END] = safe_close(errpipe[READ_END]);
|
||||
}
|
||||
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);
|
||||
@ -782,12 +778,8 @@ int udev_event_spawn(struct udev_event *event,
|
||||
goto out;
|
||||
default:
|
||||
/* parent closed child's ends of pipes */
|
||||
if (outpipe[WRITE_END] >= 0) {
|
||||
outpipe[WRITE_END] = safe_close(outpipe[WRITE_END]);
|
||||
}
|
||||
if (errpipe[WRITE_END] >= 0) {
|
||||
errpipe[WRITE_END] = safe_close(errpipe[WRITE_END]);
|
||||
}
|
||||
outpipe[WRITE_END] = safe_close(outpipe[WRITE_END]);
|
||||
errpipe[WRITE_END] = safe_close(errpipe[WRITE_END]);
|
||||
|
||||
spawn_read(event,
|
||||
timeout_usec,
|
||||
|
Loading…
Reference in New Issue
Block a user