From nobody Sat Feb 7 08:55:13 2026 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 --- 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