Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/xen/xenbus: Replace deprecated strcpy in xenbus_transaction_end

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
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Juergen Gross <jgross@suse.com>
Message-ID: <20251031112145.103257-2-thorsten.blum@linux.dev>

authored by

Thorsten Blum and committed by
Juergen Gross
a73d4a05 6fec913f

+5 -11
+4 -10
drivers/xen/xenbus/xenbus_xs.c
··· 546 546 EXPORT_SYMBOL_GPL(xenbus_transaction_start); 547 547 548 548 /* End a transaction. 549 - * If abandon is true, transaction is discarded instead of committed. 549 + * If abort is true, transaction is discarded instead of committed. 550 550 */ 551 - int xenbus_transaction_end(struct xenbus_transaction t, int abort) 551 + int xenbus_transaction_end(struct xenbus_transaction t, bool abort) 552 552 { 553 - char abortstr[2]; 554 - 555 - if (abort) 556 - strcpy(abortstr, "F"); 557 - else 558 - strcpy(abortstr, "T"); 559 - 560 - return xs_error(xs_single(t, XS_TRANSACTION_END, abortstr, NULL)); 553 + return xs_error(xs_single(t, XS_TRANSACTION_END, abort ? "F" : "T", 554 + NULL)); 561 555 } 562 556 EXPORT_SYMBOL_GPL(xenbus_transaction_end); 563 557
+1 -1
include/xen/xenbus.h
··· 158 158 const char *dir, const char *node); 159 159 int xenbus_rm(struct xenbus_transaction t, const char *dir, const char *node); 160 160 int xenbus_transaction_start(struct xenbus_transaction *t); 161 - int xenbus_transaction_end(struct xenbus_transaction t, int abort); 161 + int xenbus_transaction_end(struct xenbus_transaction t, bool abort); 162 162 163 163 /* Single read and scanf: returns -errno or num scanned if > 0. */ 164 164 __scanf(4, 5)