From patchwork Fri May 14 12:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 438903 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp299577jam; Fri, 14 May 2021 05:35:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWcCpKSvf6zXfbt/1i9yM9YmiqJl0k/QDBD14TpWFTU7BcIIJg+JrLlARs/54ahVSgbATd X-Received: by 2002:a17:906:4d44:: with SMTP id b4mr3528486ejv.306.1620995706582; Fri, 14 May 2021 05:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620995706; cv=none; d=google.com; s=arc-20160816; b=czyP9hYpcFwwONuOWp11hSTGrmWCLiEHS+lMncskhG6Y5jXxE56CTRKy/ny0t5ALcQ 94+BnKV9j2PC/tv3IOPV33LV5KCewlKaosug5HoaZ5EQzbBifwREkQEEiW12J/eztr8y NpET7gPSuJDpfWh09gIMl1V9OxzsLIlMM2Vm4FxspLJpeUXc9VuCVVk0EItmxBtwzJeP WfWgT6QSkOQvpvAd3709BI09Txw6X0L+0ZiAbg66N96xO1hKxHHFGSvCqEqBHfol6T5h IQKCHI+jhMh68k/C2GSO9yqtGQsQO2Oyvi71WQU+jYj26OIzUxT58Z9tD2bx5k+3rmLH fSPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=CZLa2NAA5RnSm1ynLTuWU4Ic/fIz8t7Ut7/0Lk3iolE=; b=dEFEpeFuxl91O/hCJ3PBJYL+ptkdyo+SAv4Li0KxbVixhOsLv3ShmtVsuIxheDMVrT SyL0y3iVtf3asjp15c0ZAfjR6xaLrIUs9q3MfpBgcI1Ua7CaDrcmkXF8CiQmXTikPFgh sAvKGDiwf9nLkh0wfyEqEqSKfSpe1GGZLm6J5Jcu1xi2jaFv5HUfYa8+KQQYQ2clLGbJ aDyiU3W9VGGjXR/GI3V7DNYBNk5M4Gq5d0iLGz7H7Qv7Gea3SHrIapcuQi8xLazzSqcf MWAq9Hf5/ARRqLcLWpsF5UGNImERqyIEsU+qZxek/R3oPOgQvrtg/yH05ADbqEzvPAiy TqUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=B6GC+sjk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a14si5675979edv.4.2021.05.14.05.35.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 May 2021 05:35:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=B6GC+sjk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:52464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhX21-0004x5-Kf for patch@linaro.org; Fri, 14 May 2021 08:35:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWjw-0001C3-Gn for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35020) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWjm-0005EL-Jb for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620994572; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CZLa2NAA5RnSm1ynLTuWU4Ic/fIz8t7Ut7/0Lk3iolE=; b=B6GC+sjktROps8G8BIgcvPHRL2XBBUgibUpTstzFUtvn8NzZs1u2V6RMKQkfEnbYlA+x/I fN/vbsqpqFn/0Wu8kYSYgDCNc3DklkzpGNxi2WKtuPWjZrBlftP4leEWZyQs2nrGN+NEqP j1iQYn7MGlV2Ylxmf8i22oMu+EgE44o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-JmNZE3CoPweYaGawTPrWGQ-1; Fri, 14 May 2021 08:16:08 -0400 X-MC-Unique: JmNZE3CoPweYaGawTPrWGQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98D959F93C; Fri, 14 May 2021 12:16:07 +0000 (UTC) Received: from thuth.com (ovpn-112-191.ams2.redhat.com [10.36.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43DEF6060F; Fri, 14 May 2021 12:16:06 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 14/20] tests: Avoid side effects inside g_assert() arguments Date: Fri, 14 May 2021 14:15:12 +0200 Message-Id: <20210514121518.832729-15-thuth@redhat.com> In-Reply-To: <20210514121518.832729-1-thuth@redhat.com> References: <20210514121518.832729-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=thuth@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell For us, assertions are always enabled, but side-effect expressions inside the argument to g_assert() are bad style anyway. Fix three occurrences in IPMI related tests, which will silence some Coverity nits. Fixes: CID 1432322, CID 1432287, CID 1432291 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alex Bennée Message-Id: <20210503165525.26221-4-peter.maydell@linaro.org> Signed-off-by: Thomas Huth --- tests/qtest/ipmi-bt-test.c | 6 ++++-- tests/qtest/ipmi-kcs-test.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) -- 2.27.0 diff --git a/tests/qtest/ipmi-bt-test.c b/tests/qtest/ipmi-bt-test.c index a42207d416..8492f02a9c 100644 --- a/tests/qtest/ipmi-bt-test.c +++ b/tests/qtest/ipmi-bt-test.c @@ -98,7 +98,8 @@ static void bt_wait_b_busy(void) { unsigned int count = 1000; while (IPMI_BT_CTLREG_GET_B_BUSY() != 0) { - g_assert(--count != 0); + --count; + g_assert(count != 0); usleep(100); } } @@ -107,7 +108,8 @@ static void bt_wait_b2h_atn(void) { unsigned int count = 1000; while (IPMI_BT_CTLREG_GET_B2H_ATN() == 0) { - g_assert(--count != 0); + --count; + g_assert(count != 0); usleep(100); } } diff --git a/tests/qtest/ipmi-kcs-test.c b/tests/qtest/ipmi-kcs-test.c index fc0a918c8d..afc24dd3e4 100644 --- a/tests/qtest/ipmi-kcs-test.c +++ b/tests/qtest/ipmi-kcs-test.c @@ -73,7 +73,8 @@ static void kcs_wait_ibf(void) { unsigned int count = 1000; while (IPMI_KCS_CMDREG_GET_IBF() != 0) { - g_assert(--count != 0); + --count; + g_assert(count != 0); } }