fs-util: make sure openat_report_new() initializes return param also on shortcut
Our coding style dictates that return parameters should be initialized always on success, hence do so here also in the shortcut codepath. Issue discovered by @fbuihuu: https://github.com/systemd/systemd/pull/22808/files/ca8503f168d0632c606110da909aba3057777395#r831911069
This commit is contained in:
committed by
Yu Watanabe
parent
b312236919
commit
4d5dacbef3
@@ -1018,6 +1018,24 @@ TEST(openat_report_new) {
|
||||
assert_se(fd >= 0);
|
||||
fd = safe_close(fd);
|
||||
assert_se(!b);
|
||||
|
||||
fd = openat_report_new(AT_FDCWD, j, O_RDWR, 0666, &b);
|
||||
assert_se(fd >= 0);
|
||||
fd = safe_close(fd);
|
||||
assert_se(!b);
|
||||
|
||||
fd = openat_report_new(AT_FDCWD, j, O_RDWR|O_CREAT|O_EXCL, 0666, &b);
|
||||
assert_se(fd == -EEXIST);
|
||||
|
||||
assert_se(unlink(j) >= 0);
|
||||
|
||||
fd = openat_report_new(AT_FDCWD, j, O_RDWR, 0666, &b);
|
||||
assert_se(fd == -ENOENT);
|
||||
|
||||
fd = openat_report_new(AT_FDCWD, j, O_RDWR|O_CREAT|O_EXCL, 0666, &b);
|
||||
assert_se(fd >= 0);
|
||||
fd = safe_close(fd);
|
||||
assert_se(b);
|
||||
}
|
||||
|
||||
static int intro(void) {
|
||||
|
||||
Reference in New Issue
Block a user