[PATCH v2] drivers/xen/xenbus: Replace deprecated strcpy in xenbus_transaction_end

Thorsten Blum posted 1 patch 2 weeks, 3 days ago
Failed in applying to current master (apply log)
There is a newer version of this series
drivers/xen/xenbus/xenbus_xs.c | 14 ++++----------
include/xen/xenbus.h           |  2 +-
2 files changed, 5 insertions(+), 11 deletions(-)
[PATCH v2] drivers/xen/xenbus: Replace deprecated strcpy in xenbus_transaction_end
Posted by Thorsten Blum 2 weeks, 3 days ago
strcpy() is deprecated; inline the read-only string instead. Fix the
function comment and use bool instead of int while we're at it.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/xen/xenbus/xenbus_xs.c | 14 ++++----------
 include/xen/xenbus.h           |  2 +-
 2 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index 528682bf0c7f..5d95a5f83119 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -546,18 +546,12 @@ int xenbus_transaction_start(struct xenbus_transaction *t)
 EXPORT_SYMBOL_GPL(xenbus_transaction_start);
 
 /* End a transaction.
- * If abandon is true, transaction is discarded instead of committed.
+ * If abort is true, transaction is discarded instead of committed.
  */
-int xenbus_transaction_end(struct xenbus_transaction t, int abort)
+int xenbus_transaction_end(struct xenbus_transaction t, bool abort)
 {
-	char abortstr[2];
-
-	if (abort)
-		strcpy(abortstr, "F");
-	else
-		strcpy(abortstr, "T");
-
-	return xs_error(xs_single(t, XS_TRANSACTION_END, abortstr, NULL));
+	return xs_error(xs_single(t, XS_TRANSACTION_END, abort ? "F" : "T",
+				  NULL));
 }
 EXPORT_SYMBOL_GPL(xenbus_transaction_end);
 
diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h
index 7dab04cf4a36..c94caf852aea 100644
--- a/include/xen/xenbus.h
+++ b/include/xen/xenbus.h
@@ -158,7 +158,7 @@ int xenbus_exists(struct xenbus_transaction t,
 		  const char *dir, const char *node);
 int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node);
 int xenbus_transaction_start(struct xenbus_transaction *t);
-int xenbus_transaction_end(struct xenbus_transaction t, int abort);
+int xenbus_transaction_end(struct xenbus_transaction t, bool abort);
 
 /* Single read and scanf: returns -errno or num scanned if > 0. */
 __scanf(4, 5)
-- 
2.51.0
Re: [PATCH v2] drivers/xen/xenbus: Replace deprecated strcpy in xenbus_transaction_end
Posted by Thorsten Blum 2 weeks, 3 days ago
On 13. Oct 2025, at 13:51, Thorsten Blum wrote:
> strcpy() is deprecated; inline the read-only string instead. Fix the
> function comment and use bool instead of int while we're at it.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---

I forgot to add:

Changes in v2:
- Use an inline ternary expression and remove 'char abortstr[2]' as
suggested by Jürgen
- Link to v1: https://lore.kernel.org/lkml/20251012195514.39003-2-thorsten.blum@linux.dev/
Re: [PATCH v2] drivers/xen/xenbus: Replace deprecated strcpy in xenbus_transaction_end
Posted by Jürgen Groß 2 weeks, 3 days ago
On 13.10.25 13:51, Thorsten Blum wrote:
> strcpy() is deprecated; inline the read-only string instead. Fix the
> function comment and use bool instead of int while we're at it.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

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


Juergen