Message ID | ba07663c444baf7dfe539f41f9cb088354af4106.1737584895.git.msakai@redhat.com (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Mikulas Patocka |
Headers | show |
Series | [v2] dm vdo: use a short static string for thread name prefix | expand |
On 22/01/2025 22:30, Matthew Sakai wrote: > Also remove MODULE_NAME and a BUG_ON check, both unneeded. > > This fixes a warning about string truncation in snprintf that > will never happen in practice: > > drivers/md/dm-vdo/vdo.c: In function ‘vdo_make’: > drivers/md/dm-vdo/vdo.c:564:5: error: ‘%s’ directive output may be truncated writing up to 55 bytes into a region of size 16 [-Werror=format-truncation=] > "%s%u", MODULE_NAME, instance); > ^~ > drivers/md/dm-vdo/vdo.c:563:2: note: ‘snprintf’ output between 2 and 66 bytes into a destination of size 16 > snprintf(vdo->thread_name_prefix, sizeof(vdo->thread_name_prefix), > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > "%s%u", MODULE_NAME, instance); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Reported-by: John Garry<john.g.garry@oracle.com> > Signed-off-by: Matthew Sakai<msakai@redhat.com> > --- Looks ok: Reviewed-by: John Garry <john.g.garry@oracle.com> btw, maybe there is some #include which is not required since MODULE_NAME is no longer referenced. I am not sure. Cheers
On 1/24/25 8:28 AM, John Garry wrote: > On 22/01/2025 22:30, Matthew Sakai wrote: >> Also remove MODULE_NAME and a BUG_ON check, both unneeded. >> >> This fixes a warning about string truncation in snprintf that >> will never happen in practice: >> >> drivers/md/dm-vdo/vdo.c: In function ‘vdo_make’: >> drivers/md/dm-vdo/vdo.c:564:5: error: ‘%s’ directive output may be >> truncated writing up to 55 bytes into a region of size 16 [- >> Werror=format-truncation=] >> "%s%u", MODULE_NAME, instance); >> ^~ >> drivers/md/dm-vdo/vdo.c:563:2: note: ‘snprintf’ output between 2 and >> 66 bytes into a destination of size 16 >> snprintf(vdo->thread_name_prefix, sizeof(vdo->thread_name_prefix), >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> "%s%u", MODULE_NAME, instance); >> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> >> Reported-by: John Garry<john.g.garry@oracle.com> >> Signed-off-by: Matthew Sakai<msakai@redhat.com> >> --- > > Looks ok: > > Reviewed-by: John Garry <john.g.garry@oracle.com> > > btw, maybe there is some #include which is not required since > MODULE_NAME is no longer referenced. I am not sure. I think I can cut at least one. I'll respin the patch. It's not completely clear to me; does the Reviewed-by: tag supersede the Reported-by: tag, or should I include both? Thanks. > Cheers >
On 1/24/25 8:56 AM, Heinz Mauelshagen wrote: > Hi, > > avoid needless format processing as in > > + "vdo%u", instance); Indeed, I'll make this change. > > > On Fri, Jan 24, 2025 at 2:34 PM John Garry <john.g.garry@oracle.com > <mailto:john.g.garry@oracle.com>> wrote: > > On 22/01/2025 22:30, Matthew Sakai wrote: > > Also remove MODULE_NAME and a BUG_ON check, both unneeded. > > > > This fixes a warning about string truncation in snprintf that > > will never happen in practice: > > > > drivers/md/dm-vdo/vdo.c: In function ‘vdo_make’: > > drivers/md/dm-vdo/vdo.c:564:5: error: ‘%s’ directive output may > be truncated writing up to 55 bytes into a region of size 16 [- > Werror=format-truncation=] > > "%s%u", MODULE_NAME, instance); > > ^~ > > drivers/md/dm-vdo/vdo.c:563:2: note: ‘snprintf’ output between 2 > and 66 bytes into a destination of size 16 > > snprintf(vdo->thread_name_prefix, sizeof(vdo->thread_name_prefix), > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > "%s%u", MODULE_NAME, instance); > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > Reported-by: John Garry<john.g.garry@oracle.com > <mailto:john.g.garry@oracle.com>> > > Signed-off-by: Matthew Sakai<msakai@redhat.com > <mailto:msakai@redhat.com>> > > --- > > Looks ok: > > Reviewed-by: John Garry <john.g.garry@oracle.com > <mailto:john.g.garry@oracle.com>> > > btw, maybe there is some #include which is not required since > MODULE_NAME is no longer referenced. I am not sure. > > Cheers >
On 24/01/2025 19:26, Matthew Sakai wrote: > It's not completely clear to me; does the Reviewed-by: tag supersede the > Reported-by: tag, or should I include both? both is fine, I think John
diff --git a/drivers/md/dm-vdo/vdo.c b/drivers/md/dm-vdo/vdo.c index a7e32baab4af..eb4a9e2442dc 100644 --- a/drivers/md/dm-vdo/vdo.c +++ b/drivers/md/dm-vdo/vdo.c @@ -142,12 +142,6 @@ static void finish_vdo_request_queue(void *ptr) vdo_unregister_allocating_thread(); } -#ifdef MODULE -#define MODULE_NAME THIS_MODULE->name -#else -#define MODULE_NAME "dm-vdo" -#endif /* MODULE */ - static const struct vdo_work_queue_type default_queue_type = { .start = start_vdo_request_queue, .finish = finish_vdo_request_queue, @@ -559,8 +553,7 @@ int vdo_make(unsigned int instance, struct device_config *config, char **reason, *vdo_ptr = vdo; snprintf(vdo->thread_name_prefix, sizeof(vdo->thread_name_prefix), - "%s%u", MODULE_NAME, instance); - BUG_ON(vdo->thread_name_prefix[0] == '\0'); + "%s%u", "vdo", instance); result = vdo_allocate(vdo->thread_config.thread_count, struct vdo_thread, __func__, &vdo->threads); if (result != VDO_SUCCESS) {
Also remove MODULE_NAME and a BUG_ON check, both unneeded. This fixes a warning about string truncation in snprintf that will never happen in practice: drivers/md/dm-vdo/vdo.c: In function ‘vdo_make’: drivers/md/dm-vdo/vdo.c:564:5: error: ‘%s’ directive output may be truncated writing up to 55 bytes into a region of size 16 [-Werror=format-truncation=] "%s%u", MODULE_NAME, instance); ^~ drivers/md/dm-vdo/vdo.c:563:2: note: ‘snprintf’ output between 2 and 66 bytes into a destination of size 16 snprintf(vdo->thread_name_prefix, sizeof(vdo->thread_name_prefix), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "%s%u", MODULE_NAME, instance); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: John Garry <john.g.garry@oracle.com> Signed-off-by: Matthew Sakai <msakai@redhat.com> --- drivers/md/dm-vdo/vdo.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)