[PATCH] xen/xenbus: fix W=1 build warning in xenbus_va_dev_error function

jiang.peng9@zte.com.cn posted 1 patch 3 months, 3 weeks ago
drivers/xen/xenbus/xenbus_client.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] xen/xenbus: fix W=1 build warning in xenbus_va_dev_error function
Posted by jiang.peng9@zte.com.cn 3 months, 3 weeks ago
From: Peng Jiang <jiang.peng9@zte.com.cn>

This patch fixes a W=1 format-string warning reported by GCC 12.3.0
by annotating xenbus_switch_fatal() and xenbus_va_dev_error()
with the __printf attribute. The attribute enables compile-time
validation of printf-style format strings in these functions.

The original warning trace:
drivers/xen/xenbus/xenbus_client.c:304:9: warning: function 'xenbus_va_dev_error' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn>
---
 drivers/xen/xenbus/xenbus_client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index 51b3124b0d56..e73ec225d4a6 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -202,6 +202,7 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev,
 }
 EXPORT_SYMBOL_GPL(xenbus_watch_pathfmt);
 
+__printf(4, 5)
 static void xenbus_switch_fatal(struct xenbus_device *, int, int,
                                const char *, ...);
 
@@ -287,6 +288,7 @@ int xenbus_frontend_closed(struct xenbus_device *dev)
 }
 EXPORT_SYMBOL_GPL(xenbus_frontend_closed);
 
+__printf(3, 0)
 static void xenbus_va_dev_error(struct xenbus_device *dev, int err,
                                const char *fmt, va_list ap)
 {
-- 
2.25.1
Re: [PATCH] xen/xenbus: fix W=1 build warning in xenbus_va_dev_error function
Posted by Jürgen Groß 3 months, 3 weeks ago
On 18.06.25 04:01, jiang.peng9@zte.com.cn wrote:
> From: Peng Jiang <jiang.peng9@zte.com.cn>
> 
> 
> This patch fixes a W=1 format-string warning reported by GCC 12.3.0
> 
> by annotating xenbus_switch_fatal() and xenbus_va_dev_error()
> 
> with the __printf attribute. The attribute enables compile-time
> 
> validation of printf-style format strings in these functions.
> 
> 
> The original warning trace:
> 
> drivers/xen/xenbus/xenbus_client.c:304:9: warning: function 
> 'xenbus_va_dev_error' might be
> 
> a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
> 
> Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn>

I'm fine with the changes as such, but please send the patch as a
plain text email (no HTML). Otherwise I'm not able to apply it.

You should look into Documentation/process/email-clients.rst in the
kernel source tree.


Juergen
Re: [PATCH v2] xen/xenbus: fix W=1 build warning in xenbus_va_dev_error function
Posted by jiang.peng9@zte.com.cn 3 months, 3 weeks ago
From: Peng Jiang <jiang.peng9@zte.com.cn>

This patch fixes a W=1 format-string warning reported by GCC 12.3.0
by annotating xenbus_switch_fatal() and xenbus_va_dev_error()
with the __printf attribute. The attribute enables compile-time
validation of printf-style format strings in these functions.

The original warning trace:
drivers/xen/xenbus/xenbus_client.c:304:9: warning: function 'xenbus_va_dev_error' might be
a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]

Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn>
---
 drivers/xen/xenbus/xenbus_client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c
index 51b3124b0d56..e73ec225d4a6 100644
--- a/drivers/xen/xenbus/xenbus_client.c
+++ b/drivers/xen/xenbus/xenbus_client.c
@@ -202,6 +202,7 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev,
 }
 EXPORT_SYMBOL_GPL(xenbus_watch_pathfmt);

+__printf(4, 5)
 static void xenbus_switch_fatal(struct xenbus_device *, int, int,
                                const char *, ...);

@@ -287,6 +288,7 @@ int xenbus_frontend_closed(struct xenbus_device *dev)
 }
 EXPORT_SYMBOL_GPL(xenbus_frontend_closed);

+__printf(3, 0)
 static void xenbus_va_dev_error(struct xenbus_device *dev, int err,
                                const char *fmt, va_list ap)
 {
-- 
2.25.1
Re: [PATCH v2] xen/xenbus: fix W=1 build warning in xenbus_va_dev_error function
Posted by Jürgen Groß 3 months, 2 weeks ago
On 20.06.25 02:41, jiang.peng9@zte.com.cn wrote:
> From: Peng Jiang <jiang.peng9@zte.com.cn>
> 
> This patch fixes a W=1 format-string warning reported by GCC 12.3.0
> by annotating xenbus_switch_fatal() and xenbus_va_dev_error()
> with the __printf attribute. The attribute enables compile-time
> validation of printf-style format strings in these functions.
> 
> The original warning trace:
> drivers/xen/xenbus/xenbus_client.c:304:9: warning: function 'xenbus_va_dev_error' might be
> a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
> 
> Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

PS: Next time please don't send another version of a patch as a reply,
     but as a new email thread.
Re: [PATCH v2] xen/xenbus: fix W=1 build warning in xenbus_va_dev_error function
Posted by jiang.peng9@zte.com.cn 3 months, 2 weeks ago
> PS: Next time please don't send another version of a patch as a reply,
>      but as a new email thread.

Got it! New threads for future patches - thanks for the heads up.Sorry for any inconvenience caused, 
and thanks again for your patience with a newcomer like me.

Best regards
Peng
Re: [PATCH] xen/xenbus: fix W=1 build warning in xenbus_va_dev_error function
Posted by jiang.peng9@zte.com.cn 3 months, 3 weeks ago
> I'm fine with the changes as such, but please send the patch as a
> plain text email (no HTML). Otherwise I'm not able to apply it.
>
> You should look into Documentation/process/email-clients.rst in the
> kernel source tree.

My sincere apologies for the HTML format issue. Thank you for your patience and for pointing me to the email guidelines  - I truly appreciate the guidance.
I'll resend the patch immediately as a plain text email to ensure it can be properly applied.

Thank you again for your understanding and for taking the time to review this.

Best regards
Peng