From nobody Fri May 3 23:54:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639749370; cv=none; d=zohomail.com; s=zohoarc; b=FORtt4E9bldOCvwG8uSU1TrBZQZVSSj3bZGzVAIlvXOGElDFffALWrB5LHz8Pr8BAc/7ocOcW4D0vnk1+XevZIp+/em6UYBh3mGx2C+B4/Ul8AiYhKDE+GwUZxOdTmPQe0l9c4KXAopST2N4lXJxzPbxsqETeioQrQ3NZxOeGXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639749370; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZE0FID1q5HgkK6NP1+kA3tplovPy2PAQtBayiKHVsJk=; b=iFLdCiiQwaQemHEPDqi77O2uA831ueZSFe/voPm74Xcae1b+YFWdVtcxsuqSUh0P+TE2IfYcrm8FGRq/dOqgaFSiYM5bUIz/3/WF6B4jWytu+Sp6Vc1rRkZMqJMXrodn26BiRyrTF8rgxtBcL9z7KrCo7aGUHrC9W3Gh2T3dVrk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639749370006247.42425740812928; Fri, 17 Dec 2021 05:56:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-360-w1b6U5jgOfOwztkiLFSwHA-1; Fri, 17 Dec 2021 08:56:05 -0500 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 D11DD192CC4B; Fri, 17 Dec 2021 13:56:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ACDA85E486; Fri, 17 Dec 2021 13:56: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 723A44A7C8; Fri, 17 Dec 2021 13:56:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BHDtZJe018995 for ; Fri, 17 Dec 2021 08:55:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5F1BC4E2D8; Fri, 17 Dec 2021 13:55:35 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id D01314E2D1 for ; Fri, 17 Dec 2021 13:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639749368; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZE0FID1q5HgkK6NP1+kA3tplovPy2PAQtBayiKHVsJk=; b=e5U5hDGGPECgNVC76MCEwdxoYXRDtJCRVx8XnZtKWlVxBKAwaCf+47CDRRZ4mWPbQMQsGB kEMO2nad0/0Q2gPffB9JsUgYYjf0uaHW4dl2+iBH6Smlc3JH1r1mX/orixf7gLpCRc9g8Q CuqHYmBWuf925E5Brn2eCnOQFqKAsQo= X-MC-Unique: w1b6U5jgOfOwztkiLFSwHA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] vshtabletest: Fix potential memleak Date: Fri, 17 Dec 2021 14:55:29 +0100 Message-Id: <45ce1cd53dae7ac7fd0f00c3f7b19300bf150f98.1639749304.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639749372007100001 Content-Type: text/plain; charset="utf-8" In testVshTableNew() we test whether vshTableNew(NULL) allocates a table. This is expected to fail (and return NULL), because passing nothing but NULL to vshTableNew() is viewed as error. Nevertheless, if vshTableNew() did not fail and returned an allocated table it would be leaked. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tests/vshtabletest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 41ceec0a51..2b997753ff 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -33,7 +33,9 @@ static int testVshTableNew(const void *opaque G_GNUC_UNUSED) { - if (vshTableNew(NULL)) { + g_autoptr(vshTable) table =3D vshTableNew(NULL); + + if (table) { fprintf(stderr, "expected failure when passing null to vshTableNew= \n"); return -1; } --=20 2.32.0 From nobody Fri May 3 23:54:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639749428; cv=none; d=zohomail.com; s=zohoarc; b=keJt4tEQz8BpCmu3WDX9Q+zEZYVivAZq5DowXVRMmalV7F9FvJ/jnPKOVXWzAltpF5WiF9gtVjlBtB1EL+K3OC334fyXgdnjK3rl32fvWvB5ht7zY8y4hSaaDV6QNN0ziO/ECbPZKL5WjHOH6iqpR7A2EB80XAf0mr6h41lZCyg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639749428; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dpRA5P1/jOQUzTVn+qglfW10hh2nsXZZX8JFmDre40M=; b=Fji70hBokkJB7CkvjrkhcglFP1Y+Ei7t3llxtkGuCryXbmOj9eedNdFKrWkkhmCH5ffTrzwqd1VB1nUK6ZoB2zQ9cNDT01yjVtiQ7FSBEVvT/hRC1gBLZGe1YUoQLGOMb4Mb/PbKAY7Se0UqBXlJ2mgCIfOAyb3sLo/1E4CJ2tA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1639749428726424.007290318634; Fri, 17 Dec 2021 05:57:08 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-Lv7m57fINwCUelL8hGFudQ-1; Fri, 17 Dec 2021 08:56:07 -0500 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 5650F92510; Fri, 17 Dec 2021 13:56:03 +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 31F8650E11; Fri, 17 Dec 2021 13:56:03 +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 02145180B617; Fri, 17 Dec 2021 13:56:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BHDtaUV019002 for ; Fri, 17 Dec 2021 08:55:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 308A14E2D9; Fri, 17 Dec 2021 13:55:36 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACC754E2D1 for ; Fri, 17 Dec 2021 13:55:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639749427; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dpRA5P1/jOQUzTVn+qglfW10hh2nsXZZX8JFmDre40M=; b=fCLhkcp4IOeOrN+kuTFpfpJ+YVKsucXStFtQwxW6FFn6tshwg3p5TI5dCiNu5bcKXHkzFI SFpygPhoLGg1jzGLk//hy8HTbKj9IbX7ANIAkxsKlpJU0qAqbTWk2FWfZ6K8FuywYAIK8f JGm+rLYQl7t8i0Ivd+1WmbH1nksU1Yk= X-MC-Unique: Lv7m57fINwCUelL8hGFudQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] vsh-table: Hide vshTableRow typedef Date: Fri, 17 Dec 2021 14:55:30 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639749430586100001 Content-Type: text/plain; charset="utf-8" There's no need for any caller to know vshTableRow typedef. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tools/vsh-table.c | 1 + tools/vsh-table.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/vsh-table.c b/tools/vsh-table.c index 7fb0f13ee6..aa2deb8c72 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -31,6 +31,7 @@ =20 #define HEX_ENCODE_LENGTH 4 /* represents length of '\xNN' */ =20 +typedef struct _vshTableRow vshTableRow; struct _vshTableRow { char **cells; size_t ncells; diff --git a/tools/vsh-table.h b/tools/vsh-table.h index 5ce416cfa1..ad2e8ed50f 100644 --- a/tools/vsh-table.h +++ b/tools/vsh-table.h @@ -23,7 +23,6 @@ #include "vsh.h" =20 typedef struct _vshTable vshTable; -typedef struct _vshTableRow vshTableRow; =20 void vshTableFree(vshTable *table); vshTable *vshTableNew(const char *format, ...); --=20 2.32.0 From nobody Fri May 3 23:54:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639749348; cv=none; d=zohomail.com; s=zohoarc; b=H6G2CZR/RYZYNCUNbkpu+X9c9np3G/WUXgcNFt8IeBJx9dnUhAhpozImFvNtAnI3dQSFTpWWrBkONdheFJ4J6y8XZoUMGyB0Rmh1dHAu8UuuUS57gcxPvi6Lw6c1hXz1X8vfinoizcwcS3tOhaJgcEXJhPGvb/ZmFRyOXCxnyXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639749348; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fbVcqgFT2FfXFmpq0EQQxePluJvDvvn+cEsZbNobZZA=; b=fTA37fEysohJBKPyKu1fLbRxjjx+XqJO28/ES75+A3r4T2ZotOKAp4AE4ERszCMSOss8UYbiNhyALIofgin4e4WyhMfR1BZ7Fky9tdzoVGaXxt6oyBm2NGNf9tr6QXvdXOSVwjRGOZY5zcpvfrAt8OKO8zyToCM7/vvEui/oRRo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639749348400942.1850042478442; Fri, 17 Dec 2021 05:55:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-568-nbx2qxf5N7ifV298mefE-A-1; Fri, 17 Dec 2021 08:55:46 -0500 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 8161D92500; Fri, 17 Dec 2021 13:55:41 +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 37EA74E2DB; Fri, 17 Dec 2021 13:55:41 +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 35B081809CBA; Fri, 17 Dec 2021 13:55:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BHDtb0O019010 for ; Fri, 17 Dec 2021 08:55:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 13EF74E2DE; Fri, 17 Dec 2021 13:55:37 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 880AA5E486 for ; Fri, 17 Dec 2021 13:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639749347; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fbVcqgFT2FfXFmpq0EQQxePluJvDvvn+cEsZbNobZZA=; b=PVim4GL0vDp6fFl1NS3OOosuosS9a84vvQPBpu3CkNXJlkIHLZ8pjOjKaiXSQVwruKWqe4 QF/IvLQDc/xlOoe/HZ70xX0bj/egA/JiQC/2g0vMEMVXSC6DGY6uvIA93YDF8O4+oVMSoU 5JCwPhxJPdSA3vwkoVh4LKYGHFr7/eg= X-MC-Unique: nbx2qxf5N7ifV298mefE-A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] vsh-table.h: Modernize declarations Date: Fri, 17 Dec 2021 14:55:31 +0100 Message-Id: <227b911cf6b5a641977566386f3863d2a3cf7f20.1639749304.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639749349510100001 Content-Type: text/plain; charset="utf-8" Use modern style of function declarations where the return type and function name are on two separate lines. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tools/vsh-table.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/vsh-table.h b/tools/vsh-table.h index ad2e8ed50f..df647e3ba9 100644 --- a/tools/vsh-table.h +++ b/tools/vsh-table.h @@ -24,9 +24,18 @@ =20 typedef struct _vshTable vshTable; =20 -void vshTableFree(vshTable *table); -vshTable *vshTableNew(const char *format, ...); -int vshTableRowAppend(vshTable *table, const char *arg, ...); -void vshTablePrintToStdout(vshTable *table, vshControl *ctl); -char *vshTablePrintToString(vshTable *table, bool header); +void +vshTableFree(vshTable *table); G_DEFINE_AUTOPTR_CLEANUP_FUNC(vshTable, vshTableFree); + +vshTable * +vshTableNew(const char *format, ...); + +int +vshTableRowAppend(vshTable *table, const char *arg, ...); + +void +vshTablePrintToStdout(vshTable *table, vshControl *ctl); + +char * +vshTablePrintToString(vshTable *table, bool header); --=20 2.32.0 From nobody Fri May 3 23:54:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639749348; cv=none; d=zohomail.com; s=zohoarc; b=jlN8/u673aB9CnZLKNUb3zbyVffdc9m4BZTVjK0CN9pEUVlT0KfXynliPg5ixMoe1DFHRVKjpewVAODLm/tGw14gLOXiAEEXCEC8/c+lOYymahpQYmV7RDySJrNVW8oG835vTAQq0SZmttafdVpd46hYk0+Lkq1khwKAOrc+cp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639749348; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dFqhs1zONUEuHtRvRaz3uaW+2KgsW6sd2s2cFlrndEI=; b=SioqSgpHRYxGN5hrgJyXOhB4AS8RlzOP/91W9cwji1l3umibYCCWvu/rhrWr4aoJ+tnyWnlxrknCFJXDUWFaPs0xRjtfcOgmyT/rAMOOyYx1BmAhM+cPSLLYc6Dol4tsVuFeAH49LzOMMwQgBZPFAdaJd82k97cXQd8KQAVP/Eg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639749348583140.74824353359952; Fri, 17 Dec 2021 05:55:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-536-hX4cgEYuN-q9DdEqjHEsQQ-1; Fri, 17 Dec 2021 08:55:46 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D4D1D100C611; Fri, 17 Dec 2021 13:55:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AE671948C; Fri, 17 Dec 2021 13:55:41 +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 994734CA93; Fri, 17 Dec 2021 13:55:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BHDtbpv019017 for ; Fri, 17 Dec 2021 08:55:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id E4E294E2BF; Fri, 17 Dec 2021 13:55:37 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 610F55E484 for ; Fri, 17 Dec 2021 13:55:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639749347; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dFqhs1zONUEuHtRvRaz3uaW+2KgsW6sd2s2cFlrndEI=; b=Qm4ZeKn9M1/lbJDnwQqVkNecOUwgS/jAdWTUDSUNM3yliFnwz9s2X6+joIeydSbQTGd6HL 8szIys85VhK1wIj7h7AbjHksDo82or87Q2VoJqhoG5WTMOm5b8R7qapPEmWlSqJClOXQ2v z8DbePLJwaWBst18hdtyPtv2hPrUYIg= X-MC-Unique: hX4cgEYuN-q9DdEqjHEsQQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] vsh-table: Ensure NULL terminated arguments to vshTable*() Date: Fri, 17 Dec 2021 14:55:32 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639749349603100003 Content-Type: text/plain; charset="utf-8" There are two functions that take variable arguments: vshTableNew() and vshTableRowAppend(). Both expect the list of arguments to be NULL terminated. Annotate them with G_GNUC_NULL_TERMINATED to enable compile time check for this. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tests/vshtabletest.c | 4 ++-- tools/vsh-table.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 2b997753ff..83d7f9b5ab 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -33,7 +33,7 @@ static int testVshTableNew(const void *opaque G_GNUC_UNUSED) { - g_autoptr(vshTable) table =3D vshTableNew(NULL); + g_autoptr(vshTable) table =3D vshTableNew(NULL, NULL); =20 if (table) { fprintf(stderr, "expected failure when passing null to vshTableNew= \n"); @@ -85,7 +85,7 @@ testVshTableRowAppend(const void *opaque G_GNUC_UNUSED) if (!table) return -1; =20 - if (vshTableRowAppend(table, NULL) >=3D 0) { + if (vshTableRowAppend(table, NULL, NULL) >=3D 0) { fprintf(stderr, "Appending NULL shouldn't work\n"); return -1; } diff --git a/tools/vsh-table.h b/tools/vsh-table.h index df647e3ba9..18d5139aa6 100644 --- a/tools/vsh-table.h +++ b/tools/vsh-table.h @@ -29,10 +29,12 @@ vshTableFree(vshTable *table); G_DEFINE_AUTOPTR_CLEANUP_FUNC(vshTable, vshTableFree); =20 vshTable * -vshTableNew(const char *format, ...); +vshTableNew(const char *format, ...) + G_GNUC_NULL_TERMINATED; =20 int -vshTableRowAppend(vshTable *table, const char *arg, ...); +vshTableRowAppend(vshTable *table, const char *arg, ...) + G_GNUC_NULL_TERMINATED; =20 void vshTablePrintToStdout(vshTable *table, vshControl *ctl); --=20 2.32.0