diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-26 15:41:38 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-02-28 10:00:50 +0100 |
commit | e7685a77b41bbd1b8289aeaf75fccaf4bb68a361 (patch) | |
tree | 2a2942015d0168dced4458652d0bd2d79d0f1c99 /coccinelle | |
parent | c7f9a8d2705ad4d18d1ca43f3a8625575f1186e5 (diff) | |
download | systemd-e7685a77b41bbd1b8289aeaf75fccaf4bb68a361.tar.gz |
util: add new safe_close_above_stdio() wrapper
At various places we only want to close fds if they are not
stdin/stdout/stderr, i.e. fds 0, 1, 2. Let's add a unified helper call
for that, and port everything over.
Diffstat (limited to 'coccinelle')
-rw-r--r-- | coccinelle/close-above-stdio.cocci | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/coccinelle/close-above-stdio.cocci b/coccinelle/close-above-stdio.cocci new file mode 100644 index 0000000000..44b3b1c9f1 --- /dev/null +++ b/coccinelle/close-above-stdio.cocci @@ -0,0 +1,36 @@ +@@ +expression fd; +@@ +- if (fd > 2) +- safe_close(fd); ++ safe_close_above_stdio(fd); +@@ +expression fd; +@@ +- if (fd > 2) +- fd = safe_close(fd); ++ fd = safe_close_above_stdio(fd); +@@ +expression fd; +@@ +- if (fd >= 3) +- safe_close(fd); ++ safe_close_above_stdio(fd); +@@ +expression fd; +@@ +- if (fd >= 3) +- fd = safe_close(fd); ++ fd = safe_close_above_stdio(fd); +@@ +expression fd; +@@ +- if (fd > STDERR_FILENO) +- safe_close(fd); ++ safe_close_above_stdio(fd); +@@ +expression fd; +@@ +- if (fd > STDERR_FILENO) +- fd = safe_close(fd); ++ fd = safe_close_above_stdio(fd); |