Skip to content

Commit ee73508

Browse files
committed
util-lib: use MODE_INVALID as invalid value for mode_t everywhere
1 parent c89f52a commit ee73508

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Diff for: src/basic/fs-util.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
311311
if (fd < 0)
312312
return -errno;
313313

314-
if (mode > 0) {
314+
if (mode != MODE_INVALID) {
315315
r = fchmod(fd, mode);
316316
if (r < 0)
317317
return -errno;
@@ -338,7 +338,7 @@ int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gi
338338
}
339339

340340
int touch(const char *path) {
341-
return touch_file(path, false, USEC_INFINITY, UID_INVALID, GID_INVALID, 0);
341+
return touch_file(path, false, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID);
342342
}
343343

344344
int symlink_idempotent(const char *from, const char *to) {

Diff for: src/core/timer.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static void timer_enter_running(Timer *t) {
519519
dual_timestamp_get(&t->last_trigger);
520520

521521
if (t->stamp_path)
522-
touch_file(t->stamp_path, true, t->last_trigger.realtime, UID_INVALID, GID_INVALID, 0);
522+
touch_file(t->stamp_path, true, t->last_trigger.realtime, UID_INVALID, GID_INVALID, MODE_INVALID);
523523

524524
timer_set_state(t, TIMER_RUNNING);
525525
return;
@@ -555,7 +555,7 @@ static int timer_start(Unit *u) {
555555
/* The timer has never run before,
556556
* make sure a stamp file exists.
557557
*/
558-
touch_file(t->stamp_path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, 0);
558+
touch_file(t->stamp_path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID);
559559
}
560560

561561
t->result = TIMER_SUCCESS;

Diff for: src/test/test-conf-files.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "conf-files.h"
2727
#include "fs-util.h"
2828
#include "macro.h"
29+
#include "parse-util.h"
2930
#include "rm-rf.h"
3031
#include "string-util.h"
3132
#include "strv.h"
@@ -40,7 +41,7 @@ static void setup_test_dir(char *tmp_dir, const char *files, ...) {
4041
va_start(ap, files);
4142
while (files != NULL) {
4243
_cleanup_free_ char *path = strappend(tmp_dir, files);
43-
assert_se(touch_file(path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, 0) == 0);
44+
assert_se(touch_file(path, true, USEC_INFINITY, UID_INVALID, GID_INVALID, MODE_INVALID) == 0);
4445
files = va_arg(ap, const char *);
4546
}
4647
va_end(ap);

0 commit comments

Comments
 (0)