From patchwork Fri May 14 12:15:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 438901 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp294068jam; Fri, 14 May 2021 05:27:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlFiUneLz30vhC2y6YE6p6tBzbTAwqDzQi9MPVPBjVndsZbffiRNNd2bSHyz9NUwcquCh9 X-Received: by 2002:a92:c5aa:: with SMTP id r10mr3854107ilt.89.1620995269112; Fri, 14 May 2021 05:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620995269; cv=none; d=google.com; s=arc-20160816; b=w41n7cYQgleXx8DpwYhLCUl1DezbcPxyGQFI94ui7/8WTCc+veEQhKlZHzI8UFGVOX rfHUJX+XqIBpksoNfg+hof0/owsL0jaaatBWqaJ65jT9ipRerzab88BdZeoVkVLfCX+C E7MXwaCVY2qneUKux7r2lzRFmi+lQ+w8YW1MusBcGfMTKHni/1t4RsWw7b6RxiDdGMoo Qxurm/Dx4rSBYb9wU1XJHg2MMak0GcX9bsHER5ZLe514DF/bmdo3H7rbq1jt9x55AICE H2G42KV4jYuAGypeUfRPIEyYPOePZMcGoyZYIxkD7ak7+hXSMpTecuj6dkTb7p4mPERk FbVg== 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=/cjNEe0Ie8oBRIjqHrPIm4Ve53eJLvdLKvseQ78mcfw=; b=aaofFolU6RvY4ktGLU8FAkycvXyE8DQuwBznN6jSj6F2i7oY1zeUr0zo7/fpkNKRE0 ICEODm6ddggnjDrSLGxJj53NXib76+2jfEshFzAj6W6U+4QLq7o/3ckShtkrUQ3hbAF6 Xnp3W3UG4LYRCOn5MvtDPVlDhbwAizP0wrDjLo7Qn9/nscheGQ2ul7chlpkVedUvFssi fmeAsnSQ4UTuByyCy2qho/HK5nKZMRpKcdQnnqJfDv6Btwv1NkgNHBZOZOpmZHOnqFEA kU9th/z9GBhuT8hhxXETFlw5DvQQrzmEYJeDNEGkOLxTBNTNpYLMZ9UtiDoMKnvpDTGN MuYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b="i/Wsod6y"; 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 h5si8624348iol.44.2021.05.14.05.27.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 May 2021 05:27:49 -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="i/Wsod6y"; 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]:34816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhWuy-0000zO-Gx for patch@linaro.org; Fri, 14 May 2021 08:27:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWjq-00015u-KR for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34359) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWjd-0005BG-1w for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620994563; 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=/cjNEe0Ie8oBRIjqHrPIm4Ve53eJLvdLKvseQ78mcfw=; b=i/Wsod6yJ+ZzqMUQXQc6iKlp23mBHxTL8N0wRS9FrvKX/HAWl0U9+PID853xHtLGiuwNnR BqDkb8j9shB8HbWIP4uQLumyWWg9T+dkzSnEsJMCve+tFFzl57BKXBLiuVcOQA2MPAs55u EwnMdXg+yLl+QyXf2S1rTlp38hFvFBg= 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-189-Q4eD961OOQG7LxxaShgIpw-1; Fri, 14 May 2021 08:16:01 -0400 X-MC-Unique: Q4eD961OOQG7LxxaShgIpw-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 9A4429F932; Fri, 14 May 2021 12:15:59 +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 2EBB16060F; Fri, 14 May 2021 12:15:57 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 09/20] tests/qtest/ahci-test.c: Calculate iso_size with 64-bit arithmetic Date: Fri, 14 May 2021 14:15:07 +0200 Message-Id: <20210514121518.832729-10-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=unavailable 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: John Snow , =?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 Coverity notes that when calculating the 64-bit iso_size value in ahci_test_cdrom() we actually only do it with 32-bit arithmetic. This doesn't matter for the current test code because nsectors is always small; but adding the cast avoids the coverity complaints. Fixes: Coverity CID 1432343 Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: John Snow Message-Id: <20210506194358.3925-1-peter.maydell@linaro.org> Signed-off-by: Thomas Huth --- tests/qtest/ahci-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c index 5e1954852e..8073ccc205 100644 --- a/tests/qtest/ahci-test.c +++ b/tests/qtest/ahci-test.c @@ -1491,14 +1491,14 @@ static void ahci_test_cdrom(int nsectors, bool dma, uint8_t cmd, char *iso; int fd; AHCIOpts opts = { - .size = (ATAPI_SECTOR_SIZE * nsectors), + .size = ((uint64_t)ATAPI_SECTOR_SIZE * nsectors), .atapi = true, .atapi_dma = dma, .post_cb = ahci_cb_cmp_buff, .set_bcl = override_bcl, .bcl = bcl, }; - uint64_t iso_size = ATAPI_SECTOR_SIZE * (nsectors + 1); + uint64_t iso_size = (uint64_t)ATAPI_SECTOR_SIZE * (nsectors + 1); /* Prepare ISO and fill 'tx' buffer */ fd = prepare_iso(iso_size, &tx, &iso); From patchwork Fri May 14 12:15:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 438900 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp291630jam; Fri, 14 May 2021 05:24:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD6v3kt5eb2I+N5cgBZrkG3sgcTTaVq/glgX9obuMKK2eRRNIGJKjIxFeNpJW/ry9AvrMJ X-Received: by 2002:ab0:6898:: with SMTP id t24mr35125291uar.120.1620995053614; Fri, 14 May 2021 05:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620995053; cv=none; d=google.com; s=arc-20160816; b=gXHQeEGYpnoyYNjIP5YdJBJuiSoYwRFCNrw/6IVg/XVzWQ7EKr3yMpiCfoDSvN/NWI UKRT8TEjhlDkIGEBwKX5RU39AFNi1Oy0X7BmPdvrIDXqgX7IdLRo5pG/WD9S8GGv+aZB 9VgxG1knIhGfaSg9AZFTZkJFOkHxBhe5d+lRlDHn3s6tlzMrMgtU1goclQCRe/BgdhXX UOhJIcu50y7VvGZKXNILdQZzEvFzOFhVOyQ4ZAnE3bgEFsfMj+n2EBzJJOw6tml3yTP9 jGfFwVWoxp1HsQRtxnJXe1a7CWU0Gla6vVsGeXhiv7g+cVb4TDchwvBg0rfoIUW/vW4Q SsRQ== 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=14tSB4tTUTQTk3xCoqSM5N90C8CnpaBHwi7JKiwNwTo=; b=HWDYOpr/YwpnYKpR0XTe4PYap0S0VAL5/vZpPtEgaIc7uFuR4f6XvCjGItoZiG00wa UoWr8CQV22gqs/0fUwV2fERHhkLI1LpvXgy45/inC7jvosbS9KVY/6xDusOnqGCBkFZQ JFZQ16sjZGzeMrJpYM1sCxg8KujiBMk1TJDP+wUMmYXtwrrTtZ5UxRQbaGfBxn13qCPb yLPafREITXMxqptoqUDmfX1EHXE8qs8wXkrq9XsSnIMhPlyOBP1NkENnvoIKxViRtUHD CE25PM6P44ZHrqgO5RDwEOreJqXj5Np95VAFLws7BMR9GG+Dyyct8Sgw1UionSR9JCBL z0EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b="RT/HhJRY"; 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 x7si4198476uar.173.2021.05.14.05.24.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 May 2021 05:24:13 -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="RT/HhJRY"; 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]:54860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhWrV-0003hw-0l for patch@linaro.org; Fri, 14 May 2021 08:24:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWjj-00015G-1p for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWje-0005BO-UA for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620994564; 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=14tSB4tTUTQTk3xCoqSM5N90C8CnpaBHwi7JKiwNwTo=; b=RT/HhJRY0hUT7Qy/XIsJwyL7NNYOsgAMBXB8YEs+SFHuaMZ1/Ou44CVAyRO/cQUNBAno85 +4cXJd72MJzp/h9SrZljKpxHK5XO+9Ou4obItUFBlbR073PpvlwiSfK/mGxSu7TfloxwfM /7CdKJGGiaiCIe+Jgy9Hcr2hM5xDIUY= 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-238-mJ0Uph67PiCFJpAJcAE9uw-1; Fri, 14 May 2021 08:16:02 -0400 X-MC-Unique: mJ0Uph67PiCFJpAJcAE9uw-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 599C4107ACC7; Fri, 14 May 2021 12:16:01 +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 176EF60CCF; Fri, 14 May 2021 12:15:59 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 10/20] tests/qtest/npcm7xx_pwm-test.c: Avoid g_assert_true() for non-test assertions Date: Fri, 14 May 2021 14:15:08 +0200 Message-Id: <20210514121518.832729-11-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=170.10.133.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: Hao Wu , =?utf-8?q?Alex_Benn=C3=A9e?= , Havard Skinnemoen Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In the glib API, the distinction between g_assert() and g_assert_true() is that the former is for "bug, terminate the application" and the latter is for "test check, on failure either terminate or just mark the testcase as failed". For QEMU, g_assert() is always fatal, so code can assume that if the assertion fails execution does not proceed, but this is not true of g_assert_true(). In npcm7xx_pwm-test, the pwm_index() and pwm_module_index() functions include some assertions that are just guarding against possible bugs in the test code that might lead us to out-of-bounds array accesses. These should use g_assert() because they aren't part of what the test is testing and the code does not correctly handle the case where the condition was false. This fixes some Coverity issues where Coverity knows that g_assert_true() can continue when the condition is false and complains about the possible array overrun at various callsites. Fixes: Coverity CID 1442340, 1442341, 1442343, 1442344, 1442345, 1442346 Signed-off-by: Peter Maydell Reviewed-by: Thomas Huth Reviewed-by: Hao Wu Reviewed-by: Havard Skinnemoen Message-Id: <20210505135516.21097-1-peter.maydell@linaro.org> Signed-off-by: Thomas Huth --- tests/qtest/npcm7xx_pwm-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c index bd15a1c294..a54fd70d27 100644 --- a/tests/qtest/npcm7xx_pwm-test.c +++ b/tests/qtest/npcm7xx_pwm-test.c @@ -201,7 +201,7 @@ static int pwm_module_index(const PWMModule *module) { ptrdiff_t diff = module - pwm_module_list; - g_assert_true(diff >= 0 && diff < ARRAY_SIZE(pwm_module_list)); + g_assert(diff >= 0 && diff < ARRAY_SIZE(pwm_module_list)); return diff; } @@ -211,7 +211,7 @@ static int pwm_index(const PWM *pwm) { ptrdiff_t diff = pwm - pwm_list; - g_assert_true(diff >= 0 && diff < ARRAY_SIZE(pwm_list)); + g_assert(diff >= 0 && diff < ARRAY_SIZE(pwm_list)); return diff; } From patchwork Fri May 14 12:15:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 438904 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp299967jam; Fri, 14 May 2021 05:35:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxNNT2icn1iL7I7q74pZWZ1imxsN9cgVbhsHMfmqjxSMJ7fOB1gnJJe3XsiLzzK5TLVIwi X-Received: by 2002:aa7:db94:: with SMTP id u20mr34334760edt.381.1620995735539; Fri, 14 May 2021 05:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620995735; cv=none; d=google.com; s=arc-20160816; b=h5MCn6JouwP6yLGCONIvUQYXRc9lkmYWTqR27NB7so+vwq5d3b3pdHGPa8B9UMKi/c C5dUXPqnLzGyrsJ/e53aCtStSENvMHOMnlhNofJC8y8ASyKaAo1q+e0rOCZruBGMFMPG JaNXa8L9cEAlrJkc/SWOGRjk00x9FiemAnjAH5D4VG4hxqkeKBVAYanTfmVf8as2znbL me4Qzlsj/eSsnNqOdjZuxZ3/tFx3qT48sc6J7eKK5yNlyTtaWnjJCU4Dad+VclV4xkB/ pC96iUWluBz3/6VjceJHlfhjhuFxUbdXGSbn0QxVd/drr19G51/HvuyHnozAZGAPQo2q GPpQ== 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=SUBqIr3WvhNROSfqC7gDwf0PYwulCayH7dwWB5D5wqw=; b=eu5js5cVAL6358JRyONohQQ5R4vrVPvgE2xEOcl/Y2d0s+tzOVEOSdS0bsgTUJkL6s m+NDts1M8+BRlRcHAdajAFXRFp9IXRo9V60AIiHsMzO8yULGvxmY8yT8T+yYnH8zATL+ r9IuRQndAac0HwVHz2yS3b+sLzpMB0G4yUgmQEtgIOcjkkdpLoNFZs8Ki7QfuzWZkzBG ipDV6Bj4H0i7q2uAv//YcGcNWEQdrV6KgZF9HzZkqNhztXQdIIxYPXmFLXaT9O3LtTM9 twIjiJ+WwLRcmQ0yt7sgkIfShvmCuMXf8TCypjOaYCtLb7wh8XCo68uIkJPYQ4M9XgY4 5QIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="K/D7HctS"; 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=pass (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 v11si5818573edt.160.2021.05.14.05.35.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 May 2021 05:35:35 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b="K/D7HctS"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:55324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhX2U-0006rh-Im for patch@linaro.org; Fri, 14 May 2021 08:35:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWjy-0001Cp-JQ for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWjs-0005Gu-9q for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620994579; 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=SUBqIr3WvhNROSfqC7gDwf0PYwulCayH7dwWB5D5wqw=; b=K/D7HctSPk97uQqc3vbvlNwW88bT6JpF0i+/WJuwy6EcUGjdtaDRdnpZkbf3MMIoOhXkBx UaDFZ9vyE7h+1yy/R/nuLEhL6s8KKK7RJSkGv4WdlkJj+VqKDmBs3a+CgIDzfXoIQ8fGfv KYp9vrZ2Rmu4K2KH4JMO8zg0ywXR+4w= 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-472-pUHFTsNeNYmDIg_vBsg23w-1; Fri, 14 May 2021 08:16:05 -0400 X-MC-Unique: pUHFTsNeNYmDIg_vBsg23w-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 B4479106BB40; Fri, 14 May 2021 12:16:04 +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 7619C6060F; Fri, 14 May 2021 12:16:03 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 12/20] tests/qtest/tpm-util.c: Free memory with correct free function Date: Fri, 14 May 2021 14:15:10 +0200 Message-Id: <20210514121518.832729-13-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=170.10.133.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?Alex_Benn=C3=A9e?= , Stefan Berger Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell tpm_util_migration_start_qemu() allocates memory with g_strdup_printf() but frees it with free() rather than g_free(), which provokes Coverity complaints (CID 1432379, 1432350). Use the correct free function. Fixes: Coverity CID 1432379, CID 1432350 Signed-off-by: Peter Maydell Reviewed-by: Stefan Berger Reviewed-by: Alex Bennée Message-Id: <20210503165525.26221-2-peter.maydell@linaro.org> Signed-off-by: Thomas Huth --- tests/qtest/tpm-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/tests/qtest/tpm-util.c b/tests/qtest/tpm-util.c index b70cc32d60..3a40ff3f96 100644 --- a/tests/qtest/tpm-util.c +++ b/tests/qtest/tpm-util.c @@ -289,6 +289,6 @@ void tpm_util_migration_start_qemu(QTestState **src_qemu, *dst_qemu = qtest_init(dst_qemu_args); - free(src_qemu_args); - free(dst_qemu_args); + g_free(src_qemu_args); + g_free(dst_qemu_args); } From patchwork Fri May 14 12:15:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 438902 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp297658jam; Fri, 14 May 2021 05:32:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN7LGTgUfDn0u1vaVtHCiKsfQDzvrS8ZlrhVBOxw5OjMgM4Zs+ceLuJ2sGC1tpdIaSVJa+ X-Received: by 2002:aa7:cf06:: with SMTP id a6mr55769655edy.340.1620995562217; Fri, 14 May 2021 05:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620995562; cv=none; d=google.com; s=arc-20160816; b=fvQthYPNnWGPk4hHicaI345OGL+ZadDKPgb5wPobdIZ5rRYszWUK9iVDHOz9hbGgWK w5/TML/aFPjZ+wWUvhPH3uMnGcCrBlxLqUTCTJeZHaj0ohPnVqAK/yeBh630dlx0nC/7 qxCOQM2y9FSTTY6t2dfqajlNlN4Z5yuh5AiNnE6qC6rgncP1B04KF86H0xIUVhDSdmQw nnHeIlEgBnpUUq9rk+Hy1P6579luN6TrMzGPmcWarpjvIwknFTTJa27KhyqbBzMNvtS7 0HBCW1MVOAKt5koiKVHWPPc4BtsyAC2+xzljYw7Vgp0eunFjkxYsfLhev2o0tpEved1z eFFQ== 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=j/wH9psoh9uMcU1oiJdjRiAj7sIw/rh8zckC3ACOccw=; b=JDhYjInLfzCqOvYD+pxNRAIgtFL7VzfyfWkgaBZ82nGZ/n4oViH1SQbcKO57insSSn Ve2rsCpz1mIgcXFHF6UyfAcevJUuVbx44jkP9xSk1S95E4Zmwmjcrk+50MPw4x0yGpzc 60qpjnBdU2vr/hTu2DM2gzWl+rrBgadNB5j67nd/YvgtMYH9PIryMDkDn2HmHCx8jYe3 ZPY+wptR5h4ktdNrKTqYd7fOTv5Rc/itsgQr0otdtBOjiRJXYjhOo+BHE2cBMxjGxv+G S0pOYGm9s2F8ci2hklf/JWE3H535mUgRLud2VT6QlLMRtmlkADOjctgmZli21YvFLN6o Tm0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DY3SYd97; 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=pass (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 s19si6008278edd.423.2021.05.14.05.32.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 May 2021 05:32:42 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DY3SYd97; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:46098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhWzh-0000VW-96 for patch@linaro.org; Fri, 14 May 2021 08:32:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWju-000180-H4 for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWji-0005CH-1k for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620994569; 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=j/wH9psoh9uMcU1oiJdjRiAj7sIw/rh8zckC3ACOccw=; b=DY3SYd97p3XNnnvVWVG7Rn5OrdKVg7MLomZ5XOeFFeFf1s1oAR4gvNy/lel9pU+jSYARfa U/Q3hXjWw0WxS1XQn1/TzhfhuwlCwozAN1hPsXc1xLh1iQSCUok+iL1LZOHZIh/jVw7HHz ONe+OdyblsmXAK/ciNV/YKtTBWXjLSA= 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-301-T4djApgdMyumESE89WRzGQ-1; Fri, 14 May 2021 08:16:07 -0400 X-MC-Unique: T4djApgdMyumESE89WRzGQ-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 EC543801817; Fri, 14 May 2021 12:16:05 +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 0B0EF6060F; Fri, 14 May 2021 12:16:04 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 13/20] tests/qtest/rtc-test: Remove pointless NULL check Date: Fri, 14 May 2021 14:15:11 +0200 Message-Id: <20210514121518.832729-14-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=unavailable 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?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In rtc-test.c we know that s is non-NULL because qtest_start() will return a non-NULL value, and we assume this when we pass s to qtest_irq_intercept_in(). So we can drop the initial assignment of NULL and the "if (s)" condition at the end of the function. Fixes: Coverity CID 1432353 Signed-off-by: Peter Maydell Reviewed-by: Thomas Huth Reviewed-by: Alex Bennée Message-Id: <20210503165525.26221-3-peter.maydell@linaro.org> Signed-off-by: Thomas Huth --- tests/qtest/rtc-test.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.27.0 diff --git a/tests/qtest/rtc-test.c b/tests/qtest/rtc-test.c index 402ce2c609..8126ab1bdb 100644 --- a/tests/qtest/rtc-test.c +++ b/tests/qtest/rtc-test.c @@ -686,7 +686,7 @@ static void periodic_timer(void) int main(int argc, char **argv) { - QTestState *s = NULL; + QTestState *s; int ret; g_test_init(&argc, &argv, NULL); @@ -712,9 +712,7 @@ int main(int argc, char **argv) ret = g_test_run(); - if (s) { - qtest_quit(s); - } + qtest_quit(s); return ret; } 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); } } From patchwork Fri May 14 12:15:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 438905 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp304910jam; Fri, 14 May 2021 05:41:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDWRs+k/fSa4JLSI74CBe59BsKmPJ2h6X3k0nM/sEc+p8UCs4HpZ+5qrC4k9hMr6aj7M47 X-Received: by 2002:a67:dc8a:: with SMTP id g10mr1531210vsk.3.1620996099088; Fri, 14 May 2021 05:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620996099; cv=none; d=google.com; s=arc-20160816; b=oBVBmYdqCwyD+rJ52jXN5oGgBzQtOMIhqud3Zi1ozxtR+8WtYacMv1CN7cOnluVWxK 9HOgGcaU9polXeCcEyD2dQkHrcWF8iC7pAxnDhhu99wSlDG1DrC4KUpSjR+s2dhTNahB 1jk54IQ7KZal7OQYmiHUMC8mdSp94SdCwRw9Qy3uhHWLYMW+1/y5scu+De167D43aSCE 4PWBD1w2eoiAzqs3mxxSJruSsuKxKUaG6JSfDFZjp0rasAeYop5EO5cW4/X3O9t7B3QB AdL7eGqOkuIAThAFE0urqGTSz32RubnQJBs0cktISnEEXgrC0NwK473DgJmpwVmtpBCH HwNQ== 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=jP1KnCaOQAK1rlZjVBFS+c5ftmWXFlXtg8ELoUTXETg=; b=yGcfS8sw/1HCArpaqpjIn8T2WnlviYcVczYXFBpcrVmb15Cwn5L8ZeYvFy5huplRgr R2fTsaEnarQeM4B8YMK9Y8JJcocisb2x8OoC1GLS4+wyKkjTTmw/m5p+FFHbrEfgS2Ls fHOoFlFKayaAhhI6viKXG+j1finWE3L8wGvVClIccUjnWexWRcQ9cMjl+XU/oO53Cqr0 l1CvDOJeX2dXStx19flxEY59RUVQ2c9AvlJXdNO/emC42om2HXiIix/7D9nUO8KI73jD 9EZSoWL1BoeRrgJxFKoDVgg9rdrDt5Z8KHINWvMpaIZxKGc1erQA7lN85ZK/GPjyQtW1 ikqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RV+GkDZk; 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=pass (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 d24si3914580vsj.96.2021.05.14.05.41.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 May 2021 05:41:39 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RV+GkDZk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:41348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhX8M-00085c-Eg for patch@linaro.org; Fri, 14 May 2021 08:41:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56700) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWk0-0001GM-Ra for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhWjq-0005Fz-Fv for qemu-devel@nongnu.org; Fri, 14 May 2021 08:16:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620994577; 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=jP1KnCaOQAK1rlZjVBFS+c5ftmWXFlXtg8ELoUTXETg=; b=RV+GkDZkSkqo41sI0u6O6YKF7rWQKLat2spxSeBuw2UcFkE7UC+A5VvStplIh+kRDxpwaD e9W9/y+Nyt4wkcY9BQA7wlvlmyT+G2Kjdt6uNo5qn9Gdr5ae77kZ2CCX8o6jiXLB43KP+U sFLqnIDllZnKMS54thzmQ1yrdbzkPV4= 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-236-pcm-_wp-NCqqVWv2MLVg6w-1; Fri, 14 May 2021 08:16:15 -0400 X-MC-Unique: pcm-_wp-NCqqVWv2MLVg6w-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 8E5C19F92E; Fri, 14 May 2021 12:16:14 +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 2D37C60C5D; Fri, 14 May 2021 12:16:12 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 18/20] tests/qtest/migration-test: Use g_autofree to avoid leaks on error paths Date: Fri, 14 May 2021 14:15:16 +0200 Message-Id: <20210514121518.832729-19-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=170.10.133.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?Alex_Benn=C3=A9e?= , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Coverity notices that several places in the migration-test code fail to free memory in error-exit paths. This is pretty unimportant in test case code, but we can avoid having to manually free the memory entirely by using g_autofree. The places where Coverity spotted a leak were relating to early exits not freeing 'uri' in test_precopy_unix(), do_test_validate_uuid(), migrate_postcopy_prepare() and test_migrate_auto_converge(). This patch converts all the string-allocation in the test code to g_autofree for consistency. Fixes: Coverity CID 1432313, 1432315, 1432352, 1432364 Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert Message-Id: <20210506185819.9010-1-peter.maydell@linaro.org> Signed-off-by: Thomas Huth --- tests/qtest/migration-test.c | 61 ++++++++++++------------------------ 1 file changed, 20 insertions(+), 41 deletions(-) -- 2.27.0 diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 4d989f191b..2b028df687 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -110,13 +110,12 @@ static void init_bootfile(const char *bootpath, void *content, size_t len) */ static void wait_for_serial(const char *side) { - char *serialpath = g_strdup_printf("%s/%s", tmpfs, side); + g_autofree char *serialpath = g_strdup_printf("%s/%s", tmpfs, side); FILE *serialfile = fopen(serialpath, "r"); const char *arch = qtest_get_arch(); int started = (strcmp(side, "src_serial") == 0 && strcmp(arch, "ppc64") == 0) ? 0 : 1; - g_free(serialpath); do { int readvalue = fgetc(serialfile); @@ -274,10 +273,9 @@ static void check_guests_ram(QTestState *who) static void cleanup(const char *filename) { - char *path = g_strdup_printf("%s/%s", tmpfs, filename); + g_autofree char *path = g_strdup_printf("%s/%s", tmpfs, filename); unlink(path); - g_free(path); } static char *SocketAddress_to_str(SocketAddress *addr) @@ -374,11 +372,8 @@ static char *migrate_get_parameter_str(QTestState *who, static void migrate_check_parameter_str(QTestState *who, const char *parameter, const char *value) { - char *result; - - result = migrate_get_parameter_str(who, parameter); + g_autofree char *result = migrate_get_parameter_str(who, parameter); g_assert_cmpstr(result, ==, value); - g_free(result); } static void migrate_set_parameter_str(QTestState *who, const char *parameter, @@ -495,12 +490,14 @@ static void migrate_start_destroy(MigrateStart *args) static int test_migrate_start(QTestState **from, QTestState **to, const char *uri, MigrateStart *args) { - gchar *arch_source, *arch_target; - gchar *cmd_source, *cmd_target; + g_autofree gchar *arch_source = NULL; + g_autofree gchar *arch_target = NULL; + g_autofree gchar *cmd_source = NULL; + g_autofree gchar *cmd_target = NULL; const gchar *ignore_stderr; - char *bootpath = NULL; - char *shmem_opts; - char *shmem_path; + g_autofree char *bootpath = NULL; + g_autofree char *shmem_opts = NULL; + g_autofree char *shmem_path = NULL; const char *arch = qtest_get_arch(); const char *machine_opts = NULL; const char *memory_size; @@ -559,8 +556,6 @@ static int test_migrate_start(QTestState **from, QTestState **to, g_assert_not_reached(); } - g_free(bootpath); - if (!getenv("QTEST_LOG") && args->hide_stderr) { ignore_stderr = "2>/dev/null"; } else { @@ -588,11 +583,9 @@ static int test_migrate_start(QTestState **from, QTestState **to, memory_size, tmpfs, arch_source, shmem_opts, args->opts_source, ignore_stderr); - g_free(arch_source); if (!args->only_target) { *from = qtest_init(cmd_source); } - g_free(cmd_source); cmd_target = g_strdup_printf("-accel kvm -accel tcg%s%s " "-name target,debug-threads=on " @@ -605,18 +598,14 @@ static int test_migrate_start(QTestState **from, QTestState **to, memory_size, tmpfs, uri, arch_target, shmem_opts, args->opts_target, ignore_stderr); - g_free(arch_target); *to = qtest_init(cmd_target); - g_free(cmd_target); - g_free(shmem_opts); /* * Remove shmem file immediately to avoid memory leak in test failed case. * It's valid becase QEMU has already opened this file */ if (args->use_shmem) { unlink(shmem_path); - g_free(shmem_path); } out: @@ -662,7 +651,7 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, QTestState **to_ptr, MigrateStart *args) { - char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); + g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; if (test_migrate_start(&from, &to, uri, args)) { @@ -684,7 +673,6 @@ static int migrate_postcopy_prepare(QTestState **from_ptr, wait_for_serial("src_serial"); migrate_qmp(from, uri, "{}"); - g_free(uri); wait_for_migration_pass(from); @@ -724,7 +712,7 @@ static void test_postcopy_recovery(void) { MigrateStart *args = migrate_start_new(); QTestState *from, *to; - char *uri; + g_autofree char *uri = NULL; args->hide_stderr = true; @@ -775,7 +763,6 @@ static void test_postcopy_recovery(void) (const char * []) { "failed", "active", "completed", NULL }); migrate_qmp(from, uri, "{'resume': true}"); - g_free(uri); /* Restore the postcopy bandwidth to unlimited */ migrate_set_parameter_int(from, "max-postcopy-bandwidth", 0); @@ -800,7 +787,7 @@ static void test_baddest(void) static void test_precopy_unix(void) { - char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); + g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); MigrateStart *args = migrate_start_new(); QTestState *from, *to; @@ -836,14 +823,13 @@ static void test_precopy_unix(void) wait_for_migration_complete(from); test_migrate_end(from, to, true); - g_free(uri); } #if 0 /* Currently upset on aarch64 TCG */ static void test_ignore_shared(void) { - char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); + g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; if (test_migrate_start(&from, &to, uri, false, true, NULL, NULL)) { @@ -873,7 +859,6 @@ static void test_ignore_shared(void) g_assert_cmpint(read_ram_property_int(from, "transferred"), <, 1024 * 1024); test_migrate_end(from, to, true); - g_free(uri); } #endif @@ -925,16 +910,15 @@ static void test_xbzrle(const char *uri) static void test_xbzrle_unix(void) { - char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); + g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); test_xbzrle(uri); - g_free(uri); } static void test_precopy_tcp(void) { MigrateStart *args = migrate_start_new(); - char *uri; + g_autofree char *uri = NULL; QTestState *from, *to; if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", args)) { @@ -971,7 +955,6 @@ static void test_precopy_tcp(void) wait_for_migration_complete(from); test_migrate_end(from, to, true); - g_free(uri); } static void test_migrate_fd_proto(void) @@ -1060,7 +1043,7 @@ static void test_migrate_fd_proto(void) static void do_test_validate_uuid(MigrateStart *args, bool should_fail) { - char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); + g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; if (test_migrate_start(&from, &to, uri, args)) { @@ -1088,7 +1071,6 @@ static void do_test_validate_uuid(MigrateStart *args, bool should_fail) } test_migrate_end(from, to, false); - g_free(uri); } static void test_validate_uuid(void) @@ -1136,7 +1118,7 @@ static void test_validate_uuid_dst_not_set(void) static void test_migrate_auto_converge(void) { - char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); + g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); MigrateStart *args = migrate_start_new(); QTestState *from, *to; int64_t remaining, percentage; @@ -1214,7 +1196,6 @@ static void test_migrate_auto_converge(void) wait_for_serial("dest_serial"); wait_for_migration_complete(from); - g_free(uri); test_migrate_end(from, to, true); } @@ -1224,7 +1205,7 @@ static void test_multifd_tcp(const char *method) MigrateStart *args = migrate_start_new(); QTestState *from, *to; QDict *rsp; - char *uri; + g_autofree char *uri = NULL; if (test_migrate_start(&from, &to, "defer", args)) { return; @@ -1273,7 +1254,6 @@ static void test_multifd_tcp(const char *method) wait_for_serial("dest_serial"); wait_for_migration_complete(from); test_migrate_end(from, to, true); - g_free(uri); } static void test_multifd_tcp_none(void) @@ -1309,7 +1289,7 @@ static void test_multifd_tcp_cancel(void) MigrateStart *args = migrate_start_new(); QTestState *from, *to, *to2; QDict *rsp; - char *uri; + g_autofree char *uri = NULL; args->hide_stderr = true; @@ -1387,7 +1367,6 @@ static void test_multifd_tcp_cancel(void) wait_for_serial("dest_serial"); wait_for_migration_complete(from); test_migrate_end(from, to2, true); - g_free(uri); } int main(int argc, char **argv)