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.
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;
}