Skip to contentSkip to conversation

kthread: add __printf attributes

PATCH New [email protected] 1 participant 1 message Dec 13, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/123 kthread: add __printf attributes

From: Nicolas Iooss <[email protected]>
Subject: kthread: add __printf attributes

When commit fbae2d44aa1d ("kthread: add kthread_create_worker*()") introduced some kthread_create_...() functions which were taking printf-like parametter, it introduced __printf attributes to some functions (e.g. kthread_create_worker()). Nevertheless some new functions were forgotten (they have been detected thanks to -Wmissing-format-attribute warning flag).

Add the missing __printf attributes to the newly-introduced functions in order to detect formatting issues at build-time with -Wformat flag.

---

 include/linux/kthread.h |    2 +-
 kernel/kthread.c        |    5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)
include/linux/kthread.h renamed from include/linux/kthread.h~kthread-add-__printf-attributes +1 -1
diff -puN include/linux/kthread.h~kthread-add-__printf-attributes include/linux/kthread.h
@@ -175,7 +175,7 @@ __printf(2, 3)
 struct kthread_worker *
 kthread_create_worker(unsigned int flags, const char namefmt[], ...);
 
-struct kthread_worker *
+__printf(3, 4) struct kthread_worker *
 kthread_create_worker_on_cpu(int cpu, unsigned int flags,
 			     const char namefmt[], ...);
 
kernel/kthread.c renamed from kernel/kthread.c~kthread-add-__printf-attributes +3 -2
diff -puN kernel/kthread.c~kthread-add-__printf-attributes kernel/kthread.c
@@ -261,7 +261,8 @@ static void create_kthread(struct kthrea
 	}
 }
 
-static struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
+static __printf(4, 0)
+struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data),
 						    void *data, int node,
 						    const char namefmt[],
 						    va_list args)
@@ -635,7 +636,7 @@ repeat:
 }
 EXPORT_SYMBOL_GPL(kthread_worker_fn);
 
-static struct kthread_worker *
+static __printf(3, 0) struct kthread_worker *
 __kthread_create_worker(int cpu, unsigned int flags,
 			const char namefmt[], va_list args)
 {

_