From nobody Mon Apr 29 01:24:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1510609503803348.65872462433765; Mon, 13 Nov 2017 13:45:03 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC1DA61D0E; Mon, 13 Nov 2017 21:45:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A67F9351B; Mon, 13 Nov 2017 21:45:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E085E1800BD3; Mon, 13 Nov 2017 21:44:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vADLiuX4001487 for ; Mon, 13 Nov 2017 16:44:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 255D89351B; Mon, 13 Nov 2017 21:44:56 +0000 (UTC) Received: from mamuti.net (unknown [10.40.205.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E3B729351F for ; Mon, 13 Nov 2017 21:44:54 +0000 (UTC) Received: by mamuti.net (Postfix, from userid 500) id CD91610E2AD; Mon, 13 Nov 2017 22:44:52 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 13 Nov 2017 22:44:51 +0100 Message-Id: <031de26f6537f061bd226156237945e89d744185.1510609491.git.jdenemar@redhat.com> Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] vircapstest: Avoid (im)possible strcmp call with NULL argument X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 13 Nov 2017 21:45:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some compiler may get confused and decide we are calling strcmp with NULL argument from test_virCapsDomainDataLookupLXC. Although this does not really happen since the call is guarded with (data->machinetype !=3D expect_machinetype), using STRNEQ_NULLABLE is easier to understand, less fragile, and doing so makes sure strcmp is never called with NULL argument. Signed-off-by: Jiri Denemark --- tests/vircapstest.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/vircapstest.c b/tests/vircapstest.c index 95829133d0..05ec802f35 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -188,11 +188,10 @@ doCapsCompare(virCapsPtr caps, goto error; } =20 - if (data->machinetype !=3D expect_machinetype && - STRNEQ(data->machinetype, expect_machinetype)) { + if (STRNEQ_NULLABLE(data->machinetype, expect_machinetype)) { fprintf(stderr, "data->machinetype=3D%s doesn't match " "expect_machinetype=3D%s\n", - data->machinetype, expect_machinetype); + NULLSTR(data->machinetype), NULLSTR(expect_machinetype)); goto error; } =20 --=20 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list