From nobody Sat Nov 15 16:05:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=sean.taipei); dmarc=pass(p=quarantine dis=none) header.from=sean.taipei ARC-Seal: i=2; a=rsa-sha256; t=1749866992; cv=pass; d=zohomail.com; s=zohoarc; b=ECky9idN0o35ItfGtgvg4CmKCg6q/mfYYc1TXWS03ejEAubqwvCTBJq2PjsafxawxmVaLqm+lh4p/Fp7oLAE8DF9DLd1FkPxp5YdF4S3FUugVwzsfW2fEAe9CLeoZf7LDR3QibwIr+bg6nVRe6FlbBl/O7ySmpnEp9iWYIgW0jI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749866992; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dZoYcuG26oXDcPxCJZEZktm6Cju6OXppwdKQvUUTPWY=; b=dMeVjoGx2fByjDE20jr6rNf3aGaiiUvIlIz7KCggFgC8PR6LvgulHRZLSUXq4HPgjG4E7KsPE967nfo3Q6Bsm/0yCKVsuABWt3z3Tm7nITq62j8B8Zt3lRjPUxkjEUINSNrckM2n3+FraA7lRwra+koEYsL3lJKhuQZoU6RZcZs= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=sean.taipei); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749866992526434.3905235506686; Fri, 13 Jun 2025 19:09:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQGKu-0002qv-Of; Fri, 13 Jun 2025 22:09:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQGKt-0002pf-6t for qemu-devel@nongnu.org; Fri, 13 Jun 2025 22:09:35 -0400 Received: from mail.sean.taipei ([128.199.207.102] helo=sean.taipei) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQGKr-0006aj-Me for qemu-devel@nongnu.org; Fri, 13 Jun 2025 22:09:34 -0400 Received: from Mac.home.lla.com (unknown [207.191.242.16]) (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 sean.taipei (Postfix) with ESMTPSA id 8A0C52806; Sat, 14 Jun 2025 10:08:57 +0800 (CST) Authentication-Results: sean.taipei; dmarc=fail (p=quarantine dis=none) header.from=sean.taipei ARC-Filter: OpenARC Filter v0.1.0 sean.taipei 8A0C52806 ARC-Seal: i=1; a=rsa-sha256; d=sean.taipei; s=arc-2024Q2; t=1749866940; cv=none; b=FoepIYZXbB90bZburMfKQZC0YhulBgDbM6A67wdwTJ2dhjyagK7IVLFalw0mFy5w8h6SJKX0JP/IT25aooc3DiGXBnNgfVj5zN1a0i5s6J2HFoPmC6gA5yPJI3f91kssRT5GhmiSq7qfsWAOFADMbh32NMgxi/cBYOjSJmHxEAP0BQFr8Wc5wFFVpNZQueiyqU6UNgznIuEEbh34rYCqQJBRHTf0Xq1Pm+hjiZ/5o3AlQA1rW9/JJ0Gx0bIkH2Bou77Ge7tGNv1eNJUFkp29AEluBFDj+7+5K+1duRRlJuw+m+1kX3LpOmrOU+itcSUkMHJseATp5RjbPWDmUMXhmw== ARC-Message-Signature: i=1; a=rsa-sha256; d=sean.taipei; s=arc-2024Q2; t=1749866940; c=relaxed/simple; bh=OFgiAYNFhF4Pa/5z/yEOAjYoeD4iuxqzyU+5fqONaLQ=; h=DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:References: MIME-Version; b=bDMJviHBmWGxj2vZ8EPePzDqu63SCeIeMI1wSyWOp6ss3wV0Lz3svQIKRiIPUHUqTOdUaieUbG0SuBBvivaFsrPVNnKor69TrhnL/qq+1XlO97Qxb79oAurGDXgIQMhnMZx8vJVSLxgt4S4XFG7a68tE6QSm7T8UajSYNsTZhAmbMrjfwgq/DNZGoWwrS3oXp0KdIqsTC3vZ6WaU5MQq3q13bijeVKnxcAD2v1w51IWXSxbQ4eSE5cjPJMvZ3B+xLq+W4AXC8wk8jUb/hFkuFex7B0M0MUxswGX/YNh1yppiRef76bgrzRVE41e5eUrdrl1JNsx5/UK0yOBx3rxvhw== ARC-Authentication-Results: i=1; sean.taipei; dmarc=fail (p=quarantine dis=none) header.from=sean.taipei DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sean.taipei; s=2021Q3; t=1749866939; bh=OFgiAYNFhF4Pa/5z/yEOAjYoeD4iuxqzyU+5fqONaLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Md08k+b47vGppahMK/Voly0TpeBN3dDi36fPqz+G9HNBhxNkZjNA7drcNsV8I7TC AzWz4WVgQLF5MDfDMKFDb1uNcZPeLKXsRg1w+47cVNU2o8HfoI6p09YWU5ck4FQG/z 44lXjD6CU20uOG4gRTBi86DAeb7rQ5igZmanJQK4tGMcNiGJcUZU9eaBiBK3GKvWD4 yd4RRzjh4gGt69bTY0YOxxZ0uvzje+gsQiireeULSM9GefZUFvJyHklKikGuKaoit5 8xgwoFKT1dNgQShoZ5uYXmFsp4nCTmwJJoCCrsLLCHSs0T2sdIPmiXvDTawj3dtehm kP7BqJzh7dqAA== From: Sean Wei To: qemu-devel@nongnu.org Cc: Sean Wei , Christian Schoenebeck , Greg Kurz Subject: [PATCH 1/2] fsdev/9p-marshal: move G_GNUC_PRINTF to header Date: Fri, 13 Jun 2025 22:08:40 -0400 Message-ID: <20250613.qemu.9p.01@sean.taipei> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613.qemu.9p@sean.taipei> References: <20250613.qemu.9p@sean.taipei> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1 ALL_TRUSTED X-Powered-By: Sean X-Scanned-By: MIMEDefang 3.3 on 104.21.5.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=128.199.207.102; envelope-from=me@sean.taipei; helo=sean.taipei X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @sean.taipei) X-ZM-MESSAGEID: 1749866993439116600 Content-Type: text/plain; charset="utf-8" v9fs_string_sprintf() is annotated with G_GNUC_PRINTF(2, 3) in 9p-marshal.c, but the prototype in fsdev/9p-marshal.h is missing the attribute, so callers that include only the header do not get format checking. Move the annotation to the header and delete the duplicate in the source file. No behavior change. Signed-off-by: Sean Wei Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- fsdev/9p-marshal.c | 3 +-- fsdev/9p-marshal.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fsdev/9p-marshal.c b/fsdev/9p-marshal.c index f9b0336cd5..3455580703 100644 --- a/fsdev/9p-marshal.c +++ b/fsdev/9p-marshal.c @@ -27,8 +27,7 @@ void v9fs_string_free(V9fsString *str) str->size =3D 0; } =20 -void G_GNUC_PRINTF(2, 3) -v9fs_string_sprintf(V9fsString *str, const char *fmt, ...) +void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...) { va_list ap; =20 diff --git a/fsdev/9p-marshal.h b/fsdev/9p-marshal.h index f1abbe151c..e8c0ef0e11 100644 --- a/fsdev/9p-marshal.h +++ b/fsdev/9p-marshal.h @@ -76,7 +76,7 @@ static inline void v9fs_string_init(V9fsString *str) str->size =3D 0; } void v9fs_string_free(V9fsString *str); -void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...); +void G_GNUC_PRINTF(2, 3) v9fs_string_sprintf(V9fsString *str, const char *= fmt, ...); void v9fs_string_copy(V9fsString *lhs, V9fsString *rhs); =20 #endif --=20 2.49.0 From nobody Sat Nov 15 16:05:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=sean.taipei); dmarc=pass(p=quarantine dis=none) header.from=sean.taipei ARC-Seal: i=2; a=rsa-sha256; t=1749867040; cv=pass; d=zohomail.com; s=zohoarc; b=JcuK9UkFzy7KFX2JyEJbWYv19MzaqJCi6DmSQn6ZgM0z/8AXv28L6xpSeisv5/06wjHOIjT5nj76Ldb0QehnE7SV4qMbQKCNGwgRDOyoCaE/lEwL9su2UZzKKVgNKM5imayJ+9udzEnKf+dARspZow/Lxq6HOTPwL683gYnrVAU= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749867040; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kjmoXPw9PukKQFLkyU1UgaZl1glFqR/nenwTBJkQ88w=; b=nXPYGx2lB6sJqEcOO5UmH+G863Oo9Qsk9iQuYbizViYz/zuu5fOFY8tT++EBvBZPSbYT4nVYP2aOMTwIDBHlp3X/Va2ud1Hs76Y80MyVJPiHrlkNmx03EgxoCg436XdJrf4d9E91XvBfdXKRkD/A7ms6N6NxxC6YEy4JJzrl/Jg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=sean.taipei); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1749867040179751.205015086875; Fri, 13 Jun 2025 19:10:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQGLU-0003bQ-2f; Fri, 13 Jun 2025 22:10:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQGLR-0003YO-Us for qemu-devel@nongnu.org; Fri, 13 Jun 2025 22:10:10 -0400 Received: from mail.sean.taipei ([128.199.207.102] helo=sean.taipei) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQGLQ-0006or-1d for qemu-devel@nongnu.org; Fri, 13 Jun 2025 22:10:09 -0400 Received: from Mac.home.lla.com (unknown [207.191.242.16]) (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 sean.taipei (Postfix) with ESMTPSA id 343775F9F; Sat, 14 Jun 2025 10:09:31 +0800 (CST) Authentication-Results: sean.taipei; dmarc=fail (p=quarantine dis=none) header.from=sean.taipei ARC-Filter: OpenARC Filter v0.1.0 sean.taipei 343775F9F ARC-Seal: i=1; a=rsa-sha256; d=sean.taipei; s=arc-2024Q2; t=1749866975; cv=none; b=SpjVyNmVzgk1/nkZxJhHGAScIKPN515uHFwITUlzuF9+CqGHKFnBdifDJzYQSQqrdNmJfbK3kb995yReQw1vgea7sU6hBAJYLXtCbLWtHtlFw1WDQzzswG9uoGmFbUQBNiBkVlEwvdyU/+E13ch4WbPnlKRuYL6UNE7ECod2KsMuuHKodqHZKNqFR1n3ZG9RPsic2PXy/ZoCow4w6m401HWjNpOwNNPN80ji3Slt2wdMd+E+nA+edIpAIg4X27v0TJlwPnCJMX7kcptjvyLJAcO+8Xxvi4yfKJJAPclOE6OUuhLUAauZb3s3lEJfm29+ZFaxnI3hk1Ubdq+aKEEzRQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=sean.taipei; s=arc-2024Q2; t=1749866975; c=relaxed/simple; bh=m0K56CSPcT09qRkK6ylaq0Uw2Aj41rsQzExHIcDXrOQ=; h=DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:References: MIME-Version; b=WlZnjCxAOvNF2WQYA9hzPvV/n1B1ZznD1WYYCPvZvnQPQDeiGYyqw0bGtlGFsYmT0k3gcPrmGNkXkIYpskoZ8i1vsVm1we5y2Ky/VcDh96gxxJMTWENRXSe8am0r28DC0rB960uiZSterkw9qN+Wg/j/OS1VvbY3+2le50CtM5Q2XpUBSaaPStetlIe67DJFYGw9dKTRci4Jnokq+/nsZpWaoxklwEPyQ6uEMKDR+LCm24R78knXgRTWl2JKu61AJVNXolcX4nklELPd0GmpRyaJV4TcEARXdc1LLnemPBtrVQ92ps1LEpZ7btG0+2UXnyYpd7dy++/AUcvp4hVkxQ== ARC-Authentication-Results: i=1; sean.taipei; dmarc=fail (p=quarantine dis=none) header.from=sean.taipei DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sean.taipei; s=2021Q3; t=1749866974; bh=m0K56CSPcT09qRkK6ylaq0Uw2Aj41rsQzExHIcDXrOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rMwYb4BqW3r1x7nV6kXHGMuwLxgsk/OLMdYBr0VNfZmDkYElqpx0ASSLtU3H4h0qt M9fKVDD3VXQlxZV6hRq2Hgc3WlIvLZczm/+Zzs6AmMjoZQ9y1DANWRLNMyhaQeWX+j W3twbWdavinbfCac6Wm6LaMBAt8KzIhHwjvir+r69Fw+hI4C4Gl1klf/5V3A+XhKvj EwL1E/IBfznpOIIfzmNSJh5uziGbNz26JHGrttceKtlzXoxThOiz/rY7V/eBPdzUjM sT3Q2ymI+McBzbuCXEp/r/f+iYpFX2FC4u/238wQ4X7o3ECQ/1BqryWsZVae+/1DoD pCWeku2iZbE0A== From: Sean Wei To: qemu-devel@nongnu.org Cc: Sean Wei , Christian Schoenebeck , Greg Kurz Subject: [PATCH 2/2] hw/9pfs: move G_GNUC_PRINTF to header Date: Fri, 13 Jun 2025 22:09:20 -0400 Message-ID: <20250613.qemu.9p.02@sean.taipei> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613.qemu.9p@sean.taipei> References: <20250613.qemu.9p@sean.taipei> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1 ALL_TRUSTED X-Powered-By: Sean X-Scanned-By: MIMEDefang 3.3 on 104.21.5.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=128.199.207.102; envelope-from=me@sean.taipei; helo=sean.taipei X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @sean.taipei) X-ZM-MESSAGEID: 1749867041895116600 Content-Type: text/plain; charset="utf-8" v9fs_path_sprintf() is annotated with G_GNUC_PRINTF(2, 3) in hw/9pfs/9p.c, but the prototype in hw/9pfs/9p.h is missing the attribute, so callers that include only the header do not get format checking. Move the annotation to the header and delete the duplicate in the source file. No behavior change. Signed-off-by: Sean Wei Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/9pfs/9p.c | 3 +-- hw/9pfs/9p.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 8b001b9112..acfa7db4e1 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -201,8 +201,7 @@ void v9fs_path_free(V9fsPath *path) } =20 =20 -void G_GNUC_PRINTF(2, 3) -v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...) +void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...) { va_list ap; =20 diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 259ad32ed1..f4f4086cf7 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -456,7 +456,7 @@ static inline uint8_t v9fs_request_cancelled(V9fsPDU *p= du) void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu); void v9fs_path_init(V9fsPath *path); void v9fs_path_free(V9fsPath *path); -void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...); +void G_GNUC_PRINTF(2, 3) v9fs_path_sprintf(V9fsPath *path, const char *fmt= , ...); void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src); size_t v9fs_readdir_response_size(V9fsString *name); int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath, --=20 2.49.0 From nobody Sat Nov 15 16:05:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=sean.taipei); dmarc=pass(p=quarantine dis=none) header.from=sean.taipei ARC-Seal: i=2; a=rsa-sha256; t=1749867036; cv=pass; d=zohomail.com; s=zohoarc; b=YNDhm6YeI5IKCgEkxukDiLdyuCNoxz9yk7vymS3Cg+gwnWTpZd7jgIU2CngbTGjZXWxb5yE2t4hfdSd66Rb1hTULToLG8Ns9YBGIRXVytwYVvJUvhqOR6xuc2krAE3G4Ke8wejhyJKOkCH4RFhQTtvqG9G/YbY7fMwHZxQY+sdk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749867036; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=q+mIVuiz4BmW7842pJg3NFzMOtlANKtLQs1tY2hqffw=; b=E5cpGDGwNEMrQlK5xdsVV+1JM00Zj0RGkfxucLZkyP7imHkuW27y+OqWrJI7FRh/J+JbO88N45+sxop7HFEQrRh+dChs5E9RRTxu1o9kkgB6kaoO/U1BpH3GV78rzXEZKHlb0ZSdzcWV71WoOjEpzOhp9EX2FMYf8KSHP9Ace08= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=sean.taipei); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174986703654848.102817177247175; Fri, 13 Jun 2025 19:10:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uQGLa-0003le-0L; Fri, 13 Jun 2025 22:10:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQGLU-0003gp-Ne for qemu-devel@nongnu.org; Fri, 13 Jun 2025 22:10:13 -0400 Received: from mail.sean.taipei ([128.199.207.102] helo=sean.taipei) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQGLS-0006pB-3Q for qemu-devel@nongnu.org; Fri, 13 Jun 2025 22:10:12 -0400 Received: from Mac.home.lla.com (unknown [207.191.242.16]) (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 sean.taipei (Postfix) with ESMTPSA id 4BD3F5FC7; Sat, 14 Jun 2025 10:10:04 +0800 (CST) Authentication-Results: sean.taipei; dmarc=fail (p=quarantine dis=none) header.from=sean.taipei ARC-Filter: OpenARC Filter v0.1.0 sean.taipei 4BD3F5FC7 ARC-Seal: i=1; a=rsa-sha256; d=sean.taipei; s=arc-2024Q2; t=1749867007; cv=none; b=bhvZ8mpx4k1SzEDKRPPUBS1UWvvZ9v3YUD5lk7/WWJbKyKoaCFk4KuQ36xe10mKzAUZtjJWhc3GNIfqB4r6f+xPrbrjJV+Qvf+7fFzjO1IwBE80rKa4tMdkXXIgAZthoAM43xLovvpwInoB3oMew+9i+cjL5Zkl1u/3VUg4pW2YZ2C2Li+iAXrlQn5vb2VvAt197dKKSzSWNbp1iFyNEjfOlIUe0JYH91KifUViNh6uQZ0pldHnYa9XOAm9tlwx2KMfmzqK2LHT3qJQbGUG7lvrR26p6dER+8dEg1nFJkm4IFT5N+9qXEh3RxkXSDdM1WH1RYo0r2K4XMI2P/0ahAQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=sean.taipei; s=arc-2024Q2; t=1749867007; c=relaxed/simple; bh=VZLRDdSa1IIQmngleoD4NcU4WOkdN9IiCFAoz1wV0Eg=; h=DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:References: MIME-Version; b=W9HX+4biOs6RBzsbnYPM1MImsLhq69z+NXq0OPauQ4BCS4ij7QlV4HEiBaarB9usldtXXuERQIQzxxzgpX4Dm0ptkDNjPsv4VrCTYIyl6IjNYSezl1hXm+p+S0NSE3K3Remb40I+o5Kl6nvk6UOKz113hb9DR1yhLEBu0AY8r0q6Nzrk+qB5zorniTjOBSLJJFbua1ROfKcX9dkw6zLFC3G/5YYG+1U04CsF7+88bbRcvk8aVEJSu331v7n/eowpmaJPbsd20vP0q4GDkltOEBmXg2tPN6c/YzPrp60h3+Yo1oRaIAN0/XKp9qTUvuGRm04RSQ20JmKY4/+7WVeQ/Q== ARC-Authentication-Results: i=1; sean.taipei; dmarc=fail (p=quarantine dis=none) header.from=sean.taipei DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sean.taipei; s=2021Q3; t=1749867006; bh=VZLRDdSa1IIQmngleoD4NcU4WOkdN9IiCFAoz1wV0Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SEaryxXbzaEJw3DiL2zxTn0voLj2aLdVkNNvaFnRDTScyKJUk9Og3M7grAYS/keU7 fd413v/jSYeexuKczZwrKz9dOKs35ZtIX0VrS8AaXi+5lF+nm8Qz/oSitOdJaQ1mLK ijzbRsh1CevXMnC/wQC2cNYQnrClkOUzOLT9KtgsxqtppxfVEYBDxe4oSivvWgBbaG DEW2wFSkPC1A2f4qRK0DQaXZ4U+vgCurXa87KGDyXdyvAJ/Fzuylf76kw+SvePkHYq KhMXanVLKJoegMhiIRphVPWQFsQnjI6kUmQVGNv9Qs1cZILb4Y0yglfsDAtXwP1yUi qBN5GCPAQKLRw== From: Sean Wei To: qemu-devel@nongnu.org Cc: Sean Wei Subject: [PoC] show header-vs-source G_GNUC_PRINTF behavior Date: Fri, 13 Jun 2025 22:09:50 -0400 Message-ID: <20250613.qemu.9p.poc@sean.taipei> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613.qemu.9p@sean.taipei> References: <20250613.qemu.9p@sean.taipei> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1 ALL_TRUSTED X-Powered-By: Sean X-Scanned-By: MIMEDefang 3.3 on 104.21.5.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=128.199.207.102; envelope-from=me@sean.taipei; helo=sean.taipei X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @sean.taipei) X-ZM-MESSAGEID: 1749867037876116600 Content-Type: text/plain; charset="utf-8" This patch is NOT meant for merge. Just a simple proof-of-concept so reviewers can quickly reproduce the difference between placing a G_GNUC_PRINTF attribute in *.c versus *.h file. What it tests ------------- * Two identical printf-style helpers (my_printf) are provided: - v1: attribute lives in foo-v1.c - v2: attribute lives in foo-v2.h * Two callers (bar-v1.c, bar-v2.c) intentionally pass too few arguments: `my_printf("%d %d %d\n", 1)`. * A trivial Makefile builds each variant and shows whether GCC emits the missing-argument warning. Expected result --------------- $ make -C poc run // Compiling version 1 (Place G_GNUC_PRINTF in 'foo-v1.c') No warning will appear, sliently cause security flaw // Compiling version 2 (Place G_GNUC_PRINTF in 'foo-v2.h') bar-v2.c:4:17: warning: more '%' conversions than data arguments [-Wformat-= insufficient-args] Signed-off-by: Sean Wei --- poc/foo-v1.h | 3 +++ poc/foo-v1.c | 10 ++++++++++ poc/bar-v1.c | 6 ++++++ poc/foo-v2.h | 3 +++ poc/foo-v2.c | 10 ++++++++++ poc/bar-v2.c | 6 ++++++ poc/Makefile | 39 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 77 insertions(+) create mode 100644 poc/foo-v1.h create mode 100644 poc/foo-v1.c create mode 100644 poc/bar-v1.c create mode 100644 poc/foo-v2.h create mode 100644 poc/foo-v2.c create mode 100644 poc/bar-v2.c create mode 100644 poc/Makefile diff --git a/poc/foo-v1.h b/poc/foo-v1.h new file mode 100644 index 0000000000..37b5403ba6 --- /dev/null +++ b/poc/foo-v1.h @@ -0,0 +1,3 @@ +#define G_GNUC_PRINTF(n, m) __attribute__((format(printf, n, m))) + +void my_printf(const char *fmt, ...); diff --git a/poc/foo-v1.c b/poc/foo-v1.c new file mode 100644 index 0000000000..ce89f95e3e --- /dev/null +++ b/poc/foo-v1.c @@ -0,0 +1,10 @@ +#include +#include +#include "foo-v2.h" + +void G_GNUC_PRINTF(1, 2) my_printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} diff --git a/poc/bar-v1.c b/poc/bar-v1.c new file mode 100644 index 0000000000..6e707e13b4 --- /dev/null +++ b/poc/bar-v1.c @@ -0,0 +1,6 @@ +#include "foo-v1.h" + +int main() { + my_printf("%d %d %d\n", 1); // missing arguments + return 0; +} diff --git a/poc/foo-v2.h b/poc/foo-v2.h new file mode 100644 index 0000000000..8bb56d3181 --- /dev/null +++ b/poc/foo-v2.h @@ -0,0 +1,3 @@ +#define G_GNUC_PRINTF(n, m) __attribute__((format(printf, n, m))) + +void G_GNUC_PRINTF(1, 2) my_printf(const char *fmt, ...); diff --git a/poc/foo-v2.c b/poc/foo-v2.c new file mode 100644 index 0000000000..3f18632ee6 --- /dev/null +++ b/poc/foo-v2.c @@ -0,0 +1,10 @@ +#include +#include +#include "foo-v1.h" + +void my_printf(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); +} diff --git a/poc/bar-v2.c b/poc/bar-v2.c new file mode 100644 index 0000000000..e06fd87056 --- /dev/null +++ b/poc/bar-v2.c @@ -0,0 +1,6 @@ +#include "foo-v2.h" + +int main() { + my_printf("%d %d %d\n", 1); // missing arguments + return 0; +} diff --git a/poc/Makefile b/poc/Makefile new file mode 100644 index 0000000000..5725c9ff63 --- /dev/null +++ b/poc/Makefile @@ -0,0 +1,39 @@ +CC ?=3D gcc +CFLAGS ?=3D -Wall + +TARGET =3D prog-v1 prog-v2 +SRCS =3D foo-v1.c foo-v2.c bar-v1.c bar-v2.c +OBJS =3D $(SRCS:.c=3D.o) + +.PHONY: run + +run: clean prog-v1 prog-v2 + + +prog-v1: + @echo + @echo + @echo "### Compiling version 1 ###" + @echo "Place G_GNUC_PRINTF in 'foo.c' only" + @echo "No warning will appear, sliently cause security flaw" + @echo + $(CC) $(CFLAGS) -c foo-v1.c -o foo-v1.o + $(CC) $(CFLAGS) -c bar-v1.c -o bar-v1.o + @echo + $(CC) foo-v1.o bar-v1.o -o $@ + +prog-v2: + @echo + @echo + @echo "### Compiling version 2###" + @echo "Place G_GNUC_PRINTF in 'foo.h' instead" + @echo "Show warning for missing arguments" + @echo + $(CC) $(CFLAGS) -c foo-v2.c -o foo-v2.o + $(CC) $(CFLAGS) -c bar-v2.c -o bar-v2.o + @echo + $(CC) foo-v2.o bar-v2.o -o $@ + +clean: + @echo "### Clean all artifacts ###" + rm -f $(TARGET) $(OBJS) --=20 2.49.0