summaryrefslogtreecommitdiff
path: root/coccinelle
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-04-04 10:17:16 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-04-12 11:44:52 +0200
commitfdeea3f4f1c0f78f1014582135d047265098fb82 (patch)
treed0d0f329f5b7dedd3c781cf64f0f468105e3befb /coccinelle
parent03abeb0baf7fe97c98a98d745b75c7d33e2f632e (diff)
downloadsystemd-fdeea3f4f1c0f78f1014582135d047265098fb82.tar.gz
systemd-fdeea3f4f1c0f78f1014582135d047265098fb82.tar.bz2
systemd-fdeea3f4f1c0f78f1014582135d047265098fb82.zip
Add fopen_unlocked() wrapper
Diffstat (limited to 'coccinelle')
-rw-r--r--coccinelle/fopen-unlocked.cocci37
1 files changed, 37 insertions, 0 deletions
diff --git a/coccinelle/fopen-unlocked.cocci b/coccinelle/fopen-unlocked.cocci
new file mode 100644
index 0000000000..93b993dd55
--- /dev/null
+++ b/coccinelle/fopen-unlocked.cocci
@@ -0,0 +1,37 @@
+@@
+expression f, path, options;
+@@
+- f = fopen(path, options);
+- if (!f)
+- return -errno;
+- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
++ r = fopen_unlocked(path, options, &f);
++ if (r < 0)
++ return r;
+@@
+expression f, path, options;
+@@
+- f = fopen(path, options);
+- if (!f) {
+- if (errno == ENOENT)
+- return -ESRCH;
+- return -errno;
+- }
+- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
++ r = fopen_unlocked(path, options, &f);
++ if (r == -ENOENT)
++ return -ESRCH;
++ if (r < 0)
++ return r;
+@@
+expression f, path, options;
+@@
+- f = fopen(path, options);
+- if (!f)
+- return errno == ENOENT ? -ESRCH : -errno;
+- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
++ r = fopen_unlocked(path, options, &f);
++ if (r == -ENOENT)
++ return -ESRCH;
++ if (r < 0)
++ return r;