From nobody Fri Oct 18 08:54:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1717596354366606.4027877871581; Wed, 5 Jun 2024 07:05:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 309B92131; Wed, 5 Jun 2024 10:05:53 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C350B2157; Wed, 5 Jun 2024 10:04:32 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E4CF11F18; Wed, 5 Jun 2024 10:04:26 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0C64A1F7B for ; Wed, 5 Jun 2024 10:04:25 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-jcc7bYb-PMCtxyL3OpdoRg-1; Wed, 05 Jun 2024 10:04:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13986800074 for ; Wed, 5 Jun 2024 14:04:23 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF06D2166AF6 for ; Wed, 5 Jun 2024 14:04:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717596264; h=from:from: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; bh=5C2M/H0OBduuJljCP8wsMBjaCx4PDaAMwJlY7Gu0Pf8=; b=Xac+7TUl4TZGhL0gk3ppUBz9vWHNRPVpB4d5b0XpF3n64UqVrqSH6WV2eYKp5ExtJnxfm+ 1zImqmRP7c14gJt9+q32KMBABjunP00k32SF8AvtGUnWLi/YgBnKBlz0Q0c2VH3XlTsyig yKGUaKf/lW189OSF7rC3ixuSZwq0jI0= X-MC-Unique: jcc7bYb-PMCtxyL3OpdoRg-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 1/2] lib: Annotate more function as NULL terminated Date: Wed, 5 Jun 2024 16:04:19 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: T7OZKKNAEZROTFAWVG232IZOFAWZD735 X-Message-ID-Hash: T7OZKKNAEZROTFAWVG232IZOFAWZD735 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1717596355896100001 Content-Type: text/plain; charset="utf-8"; x-default="true" While __attribute((sentinel)) (exposed by glib under G_GNUC_NULL_TERMINATED macro) is a gcc extension, it's supported by clang too. It's already being used throughout our code but some functions that take variadic arguments and expect NULL at the end were lacking such annotation. Fill them in. After this, there are still some functions left untouched because they expect a different sentinel than NULL. Unfortunately, glib does not provide macro for different sentinels. We may come up with our own, but let's save that for future work. Signed-off-by: Michal Privoznik --- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 2 +- tests/qemumigrationcookiexmltest.c | 2 +- tests/testutils.h | 3 ++- tests/testutilsqemuschema.h | 3 ++- tools/vsh.c | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 6e81945201..b78f539c85 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -947,7 +947,8 @@ int qemuMonitorDelDevice(qemuMonitor *mon, int qemuMonitorCreateObjectProps(virJSONValue **propsret, const char *type, const char *alias, - ...); + ...) + G_GNUC_NULL_TERMINATED; =20 int qemuMonitorAddObject(qemuMonitor *mon, virJSONValue **props, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index eb84a3d938..c5e758e7f8 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -468,7 +468,7 @@ qemuMonitorJSONHasError(virJSONValue *reply, * * Returns 0 on success and -1 on error. */ -static int +static int G_GNUC_NULL_TERMINATED qemuMonitorJSONTransactionAdd(virJSONValue *actions, const char *cmdname, ...) diff --git a/tests/qemumigrationcookiexmltest.c b/tests/qemumigrationcookie= xmltest.c index 5270e3a7e7..bc0f68b8c5 100644 --- a/tests/qemumigrationcookiexmltest.c +++ b/tests/qemumigrationcookiexmltest.c @@ -39,7 +39,7 @@ static virQEMUDriver driver; =20 static virBuffer testnamebuf =3D VIR_BUFFER_INITIALIZER; =20 -static const char * +static const char * G_GNUC_NULL_TERMINATED tn(const char *str, ...) { va_list ap; diff --git a/tests/testutils.h b/tests/testutils.h index e5469c5aa0..e22324e06d 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -113,7 +113,8 @@ void virTestFakeRootDirCleanup(char *fakerootdir); int virTestMain(int argc, char **argv, int (*func)(void), - ...); + ...) + G_GNUC_NULL_TERMINATED; =20 /* Setup, then call func() */ #define VIR_TEST_MAIN(func) \ diff --git a/tests/testutilsqemuschema.h b/tests/testutilsqemuschema.h index cb1e6da69e..191e763936 100644 --- a/tests/testutilsqemuschema.h +++ b/tests/testutilsqemuschema.h @@ -40,7 +40,8 @@ testQEMUSchemaValidateCommand(const char *command, =20 int testQEMUSchemaEntryMatchTemplate(virJSONValue *schemaentry, - ...); + ...) + G_GNUC_NULL_TERMINATED; =20 =20 virJSONValue * diff --git a/tools/vsh.c b/tools/vsh.c index 6cc1f60d87..9fbb1f9349 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2418,7 +2418,7 @@ vshCloseLogFile(vshControl *ctl) } =20 #ifndef WIN32 -static void +static void G_GNUC_NULL_TERMINATED vshPrintRaw(vshControl *ctl, ...) { va_list ap; --=20 2.44.1