[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH v4 3/9] loop:refactor: del close_and_try_next_loopN
From: Xiaoming Ni <nixiaoming () huawei ! com>
Date: 2022-11-21 13:58:13
Message-ID: 20221121135819.413-4-nixiaoming () huawei ! com
[Download RAW message or body]
Step 3 of micro-refactoring the set_loop() function:
Delete close_and_try_next_loopN.
(add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0) Total: 0 bytes
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
libbb/loop.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libbb/loop.c b/libbb/loop.c
index 6c28e683a..c7687052b 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -200,13 +200,14 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
if (rc && errno == ENXIO) {
/* Associate free loop device with file */
if (ioctl(lfd, LOOP_SET_FD, ffd)) {
+ close(lfd);
/* Ouch. Are we racing with other mount? */
if (!*device) {
- close(lfd);
//TODO: add "if (--failcount != 0) ..."?
continue;
+ } else {
+ break;
}
- goto close_and_try_next_loopN;
}
memset(&loopinfo, 0, sizeof(loopinfo));
safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE);
@@ -236,7 +237,6 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
/* failure, undo LOOP_SET_FD */
ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary
}
- close_and_try_next_loopN:
close(lfd);
try_next_loopN:
rc = -1;
--
2.27.0
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic