diff mbox series

[v6,1/2] block: Ignore close() failure in get_tmp_filename()

Message ID 20221010040432.3380478-1-bin.meng@windriver.com (mailing list archive)
State New, archived
Headers show
Series [v6,1/2] block: Ignore close() failure in get_tmp_filename() | expand

Commit Message

Bin Meng Oct. 10, 2022, 4:04 a.m. UTC
The temporary file has been created and is ready for use. Checking
return value of close() does not seem useful. The file descriptor
is almost certainly closed; see close(2) under "Dealing with error
returns from close()".

Let's simply ignore close() failure here.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---

(no changes since v5)

Changes in v5:
- new patch: "block: Ignore close() failure in get_tmp_filename()"

 block.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Kevin Wolf Oct. 21, 2022, 9:25 a.m. UTC | #1
Am 10.10.2022 um 06:04 hat Bin Meng geschrieben:
> The temporary file has been created and is ready for use. Checking
> return value of close() does not seem useful. The file descriptor
> is almost certainly closed; see close(2) under "Dealing with error
> returns from close()".
> 
> Let's simply ignore close() failure here.
> 
> Suggested-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>

Thanks, series applied to the block branch.

Kevin
diff mbox series

Patch

diff --git a/block.c b/block.c
index bc85f46eed..582c205307 100644
--- a/block.c
+++ b/block.c
@@ -886,10 +886,7 @@  int get_tmp_filename(char *filename, int size)
     if (fd < 0) {
         return -errno;
     }
-    if (close(fd) != 0) {
-        unlink(filename);
-        return -errno;
-    }
+    close(fd);
     return 0;
 #endif
 }