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 <nixiaom...@huawei.com>
---
 libbb/loop.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libbb/loop.c b/libbb/loop.c
index baa02dabb..147597ab9 100644
--- a/libbb/loop.c
+++ b/libbb/loop.c
@@ -197,13 +197,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);
@@ -233,7 +234,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

Reply via email to