summaryrefslogtreecommitdiffstats
path: root/coccinelle/fopen-unlocked.cocci
blob: 7870f8ccea09bfdfc8f196aec6e00990f6a5c81d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@@
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;
@@
expression f, path, p;
@@
  r = fopen_temporary(path, &f, &p);
  if (r < 0)
    return ...;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
@@
expression f, g, path, p;
@@
  r = fopen_temporary_label(path, g, &f, &p);
  if (r < 0)
    return ...;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
@@
expression f, fd, options;
@@
- f = fdopen(fd, options);
+ r = fdopen_unlocked(fd, options, &f);
+ if (r < 0) {
- if (!f) {
        ...
-       return -errno;
+       return r;
  }
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);
@@
expression f, buf, sz;
@@
- f = open_memstream(&buf, &sz);
+ f = open_memstream_unlocked(&buf, &sz);
  if (!f)
        return ...;
- (void) __fsetlocking(f, FSETLOCKING_BYCALLER);