loop: simplify code of LOOP_SET_FD failure

function                                             old     new   delta
set_loop                                             790     760     -30

Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Xiaoming Ni 2022-12-12 18:57:09 +01:00 committed by Denys Vlasenko
parent ddccf6cd2f
commit 7dc76c9f21

View File

@ -188,13 +188,9 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
/* If device is free, try to claim it */ /* If device is free, try to claim it */
if (rc && errno == ENXIO) { if (rc && errno == ENXIO) {
/* Associate free loop device with file */ /* Associate free loop device with file */
if (ioctl(lfd, LOOP_SET_FD, ffd)) { rc = ioctl(lfd, LOOP_SET_FD, ffd);
/* Ouch. Are we racing with other mount? */ if (rc != 0) {
if (!*device) { /* Ouch... race: the device already has a fd */
close(lfd);
//TODO: add "if (--failcount != 0) ..."?
continue;
}
goto close_and_try_next_loopN; goto close_and_try_next_loopN;
} }
memset(&loopinfo, 0, sizeof(loopinfo)); memset(&loopinfo, 0, sizeof(loopinfo));