public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH RFT v2] driver/scsi/mpi3mr: Fix build warning for mpi3mr_start_watchdog
@ 2025-10-28 14:55 Bartlomiej Kubik
  2025-11-12 20:29 ` Bartłomiej Kubik
  2025-11-12 20:55 ` Bart Van Assche
  0 siblings, 2 replies; 6+ messages in thread
From: Bartlomiej Kubik @ 2025-10-28 14:55 UTC (permalink / raw)
  To: sathya.prakash, kashyap.desai, sumit.saxena, sreekanth.reddy
  Cc: martin.petersen, mpi3mr-linuxdrv.pdl, linux-scsi, skhan, khalid,
	david.hunter.linux, linux-kernel-mentees, linux-kernel,
	Bartlomiej Kubik

GCC warning:
drivers/scsi/mpi3mr/mpi3mr_fw.c:2872:60: warning: ‘%s’ directive
output may be truncated writing up to 63 bytes into a region of size
41 [-Wformat-truncation=]

Change MPI3MR_WATCHDOG_NAME_LENGTH define to properly clarify
the required buffer size.

The mrioc->watchdog_work_q_name buffer in
the mpi3mr_start_watchdog() function no longer requires adding mrioc->id,
since mrioc->name already includes it.

mrioc->name is built using:
sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id)

Signed-off-by: Bartlomiej Kubik <kubik.bartlomiej@gmail.com>
---

I do not have the hardware to full tests it.
Tests only built kernel without warning and run kernel.

Changelog:
Changes since v1:
- Add define MPI3MR_WATCHDOG_NAME_LENGTH (MPI3MR_NAME_LENGTH + 15)
- Change watchdog_work_q_name buffer from size 50 to MPI3MR_WATCHDOG_NAME_LENGTH

Link to v1
https://lore.kernel.org/all/20251002063038.552399-1-kubik.bartlomiej@gmail.com/

 drivers/scsi/mpi3mr/mpi3mr.h    | 3 ++-
 drivers/scsi/mpi3mr/mpi3mr_fw.c | 3 +--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h
index 6742684e2990..be15d5ec8b58 100644
--- a/drivers/scsi/mpi3mr/mpi3mr.h
+++ b/drivers/scsi/mpi3mr/mpi3mr.h
@@ -66,6 +66,7 @@ extern atomic64_t event_counter;

 #define MPI3MR_NAME_LENGTH	64
 #define IOCNAME			"%s: "
+#define MPI3MR_WATCHDOG_NAME_LENGTH (sizeof("watchdog_") + MPI3MR_NAME_LENGTH + 1)

 #define MPI3MR_DEFAULT_MAX_IO_SIZE	(1 * 1024 * 1024)

@@ -1265,7 +1266,7 @@ struct mpi3mr_ioc {
 	spinlock_t fwevt_lock;
 	struct list_head fwevt_list;

-	char watchdog_work_q_name[50];
+	char watchdog_work_q_name[MPI3MR_WATCHDOG_NAME_LENGTH];
 	struct workqueue_struct *watchdog_work_q;
 	struct delayed_work watchdog_work;
 	spinlock_t watchdog_lock;
diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c
index 8fe6e0bf342e..18b176e358c5 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_fw.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c
@@ -2879,8 +2879,7 @@ void mpi3mr_start_watchdog(struct mpi3mr_ioc *mrioc)

 	INIT_DELAYED_WORK(&mrioc->watchdog_work, mpi3mr_watchdog_work);
 	snprintf(mrioc->watchdog_work_q_name,
-	    sizeof(mrioc->watchdog_work_q_name), "watchdog_%s%d", mrioc->name,
-	    mrioc->id);
+	    sizeof(mrioc->watchdog_work_q_name), "watchdog_%s", mrioc->name);
 	mrioc->watchdog_work_q = alloc_ordered_workqueue(
 		"%s", WQ_MEM_RECLAIM, mrioc->watchdog_work_q_name);
 	if (!mrioc->watchdog_work_q) {
--
2.39.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-15 14:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28 14:55 [PATCH RFT v2] driver/scsi/mpi3mr: Fix build warning for mpi3mr_start_watchdog Bartlomiej Kubik
2025-11-12 20:29 ` Bartłomiej Kubik
2025-11-12 20:55 ` Bart Van Assche
2025-11-15 13:47   ` Bartłomiej Kubik
2025-11-15 14:31     ` Bartłomiej Kubik
2025-11-15 14:47       ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox