[PATCH v4 3/9] loop:refactor: del close_and_try_next_loopN

Denys Vlasenko vda.linux at googlemail.com
Mon Dec 12 18:09:55 UTC 2022


On Mon, Nov 21, 2022 at 2:57 PM Xiaoming Ni <nixiaoming at huawei.com> wrote:
>
> 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 at 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;
>                         }

 if (ioctl(lfd, LOOP_SET_FD, ffd))
                               goto close_and_try_next_loopN;

will work as well: the code at that label checks for
"if (!*device)" case too.

Applied, thank you.


More information about the busybox mailing list