]> git.ipfire.org Git - thirdparty/systemd.git/blame - coccinelle/fopen-unlocked.cocci
Add fopen_unlocked() wrapper
[thirdparty/systemd.git] / coccinelle / fopen-unlocked.cocci
CommitLineData
fdeea3f4
ZJS
1@@
2expression f, path, options;
3@@
4- f = fopen(path, options);
5- if (!f)
6- return -errno;
7- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
8+ r = fopen_unlocked(path, options, &f);
9+ if (r < 0)
10+ return r;
11@@
12expression f, path, options;
13@@
14- f = fopen(path, options);
15- if (!f) {
16- if (errno == ENOENT)
17- return -ESRCH;
18- return -errno;
19- }
20- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
21+ r = fopen_unlocked(path, options, &f);
22+ if (r == -ENOENT)
23+ return -ESRCH;
24+ if (r < 0)
25+ return r;
26@@
27expression f, path, options;
28@@
29- f = fopen(path, options);
30- if (!f)
31- return errno == ENOENT ? -ESRCH : -errno;
32- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
33+ r = fopen_unlocked(path, options, &f);
34+ if (r == -ENOENT)
35+ return -ESRCH;
36+ if (r < 0)
37+ return r;