mirror of
https://github.com/systemd/systemd
synced 2024-07-22 18:55:10 +00:00
![Zbigniew Jędrzejewski-Szmek](/assets/img/avatar_default.png)
This is partially a refactoring, but also makes many more places use unlocked operations implicitly, i.e. all users of fopen_temporary(). AFAICT, the uses are always for short-lived files which are not shared externally, and are just used within the same context. Locking is not necessary.
52 lines
1.1 KiB
Plaintext
52 lines
1.1 KiB
Plaintext
@@
|
|
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);
|