Commit 35b6e94b authored by Peter Maydell's avatar Peter Maydell Committed by Michael Tokarev
Browse files

s390: avoid always-true comparison in s390_pci_generate_fid()



Coverity points out that the comparison "fid <= ZPCI_MAX_FID"
in s390_pci_generate_fid() is always true (because fid
is 32 bits and ZPCI_MAX_FID is 0xffffffff). This isn't a
bug because the real loop termination condition is
expressed later via an "if (...) break;" inside the loop,
but it is a bit odd. Rephrase the loop to avoid the
unnecessary duplicate-but-never-true conditional.

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Acked-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
parent 25174055
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -809,17 +809,11 @@ static uint32_t s390_pci_generate_fid(Error **errp)
{
    uint32_t fid = 0;

    while (fid <= ZPCI_MAX_FID) {
    do {
        if (!s390_pci_find_dev_by_fid(fid)) {
            return fid;
        }

        if (fid == ZPCI_MAX_FID) {
            break;
        }

        fid++;
    }
    } while (fid++ != ZPCI_MAX_FID);

    error_setg(errp, "no free fid could be found");
    return 0;