ptp: drop redundant kasprintf() to create worker name
Subsystems (3)
PATCH 1/1 ptp: drop redundant kasprintf() to create worker name
Building with -Wformat-nonliteral, gcc complains
drivers/ptp/ptp_clock.c: In function ‘ptp_clock_register’:drivers/ptp/ptp_clock.c:239:26: warning: format not a string literal and no format arguments [-Wformat-nonliteral]
worker_name : info->name);
kthread_create_worker takes fmt+varargs to set the name of the worker, and that happens with a vsnprintf() to a stack buffer (that is then copied into task_comm). So there's no reason not to just pass "ptp%d", ptp->index to kthread_create_worker() and avoid the intermediate worker_name variable.
--- drivers/ptp/ptp_clock.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/ptp/ptp_clock.c +1 -5
@@ -232,12 +232,8 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,init_waitqueue_head (&ptp->tsev_wq);if (ptp->info->do_aux_work) { -char *worker_name =kasprintf (GFP_KERNEL ,"ptp%d" , ptp->index); -kthread_init_delayed_work (&ptp->aux_work, ptp_aux_kworker); - ptp->kworker =kthread_create_worker (0 , worker_name ? - worker_name : info->name); -kfree (worker_name); + ptp->kworker =kthread_create_worker (0 ,"ptp%d" , ptp->index);if (IS_ERR (ptp->kworker)) { err =PTR_ERR (ptp->kworker);pr_err ("failed to create ptp aux_worker %d\n" , err);
Signature · 1 line
2.19.1.6.gbde171bbf5
Quoted 11 lines · Rasmus Villemoes
Building with -Wformat-nonliteral, gcc complains
drivers/ptp/ptp_clock.c: In function ‘ptp_clock_register’:drivers/ptp/ptp_clock.c:239:26: warning: format not a string literal and no format arguments [-Wformat-nonliteral]worker_name : info->name);
kthread_create_workertakes fmt+varargs to set the name of the worker, and that happens with avsnprintf()to a stack buffer (that is then copied intotask_comm). So there's no reason not to just pass "ptp%d",ptp->indextokthread_create_worker()and avoid the intermediateworker_namevariable.
Quoted 6 lines · Rasmus Villemoes
Building with -Wformat-nonliteral, gcc complains
drivers/ptp/ptp_clock.c: In function ‘ptp_clock_register’:drivers/ptp/ptp_clock.c:239:26: warning: format not a string literal and no format arguments [-Wformat-nonliteral]worker_name : info->name);
Quoted 7 lines
kthread_create_workertakes fmt+varargs to set the name of the worker, and that happens with avsnprintf()to a stack buffer (that is then copied intotask_comm). So there's no reason not to just pass "ptp%d",ptp->indextokthread_create_worker()and avoid the intermediateworker_namevariable.Signed-off-by Rasmus Villemoes <[email protected]>
-Kees
Quoted 25 lines
--- drivers/ptp/ptp_clock.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)drivers/ptp/ptp_clock.c +1
-6@@ -232,12 +232,8 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info,init_waitqueue_head (&ptp->tsev_wq);if (ptp->info->do_aux_work) { -char *worker_name =kasprintf (GFP_KERNEL ,"ptp%d" , ptp->index); -kthread_init_delayed_work (&ptp->aux_work, ptp_aux_kworker); - ptp->kworker =kthread_create_worker (0 , worker_name ? - worker_name : info->name); -kfree (worker_name); + ptp->kworker =kthread_create_worker (0 ,"ptp%d" , ptp->index);if (IS_ERR (ptp->kworker)) { err =PTR_ERR (ptp->kworker);pr_err ("failed to create ptp aux_worker %d\n" , err); --2.19.1.6.gbde171bbf5
Signature · 1 line
Kees Cook
From: Rasmus Villemoes <[email protected]>
Date: Fri, 26 Oct 2018 23:22:59 +0200
Quoted 6 lines
Building with -Wformat-nonliteral, gcc complains
drivers/ptp/ptp_clock.c: In function ‘ptp_clock_register’:drivers/ptp/ptp_clock.c:239:26: warning: format not a string literal and no format arguments [-Wformat-nonliteral]worker_name : info->name);
Quoted 7 lines
kthread_create_workertakes fmt+varargs to set the name of the worker, and that happens with avsnprintf()to a stack buffer (that is then copied intotask_comm). So there's no reason not to just pass "ptp%d",ptp->indextokthread_create_worker()and avoid the intermediateworker_namevariable.Signed-off-by Rasmus Villemoes <[email protected]>
Applied.