From: Lennart Poettering Date: Mon, 21 Oct 2024 20:40:52 +0000 (+0200) Subject: fs-util: don't second guess openat_report_new() return values X-Git-Tag: v257-rc1~161^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da3d81cccd1f915e91a756b3d783e8bc3ecd0a5c;p=thirdparty%2Fsystemd.git fs-util: don't second guess openat_report_new() return values If openat_report_new() fails, then 'made_file' will be false, as no file was created, hence there's no need to skip the unlinkat() explicitly early, given that we check for 'made_file' anyway in the error path. The extra error code checks are hence entirely redundant. --- diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 7ccd3f6750a..53206c3b374 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -1195,17 +1195,6 @@ int xopenat_full(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_ fd = openat_report_new(dir_fd, path, open_flags, mode, &made_file); if (fd < 0) { - if (IN_SET(fd, - /* We got ENOENT? then someone else immediately removed it after we - * created it. In that case let's return immediately without unlinking - * anything, because there simply isn't anything to unlink anymore. */ - -ENOENT, - /* is a symlink? exists already → created by someone else, don't unlink */ - -ELOOP, - /* not a directory? exists already → created by someone else, don't unlink */ - -ENOTDIR)) - return fd; - r = fd; goto error; }