do_open_proc: annotate with printf attr

Submitted by Kir Kolyshkin on Feb. 13, 2017, 10:52 p.m.

Details

Message ID 20170213225232.21585-1-kir@openvz.org
State Accepted
Series "do_open_proc: annotate with printf attr"
Commit bd0319df7cefc48ae6390e5c0dc3d8b6f3b21864
Headers show

Commit Message

Kir Kolyshkin Feb. 13, 2017, 10:52 p.m.
This will help us catch bugs where the arguments are not in line
with the format string.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
---
 criu/include/util.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/include/util.h b/criu/include/util.h
index d1332ae..392fa8c 100644
--- a/criu/include/util.h
+++ b/criu/include/util.h
@@ -73,7 +73,8 @@  extern int set_proc_fd(int fd);
 #define PROC_GEN	-1
 #define PROC_NONE	-2
 
-extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
+extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...)
+	__attribute__ ((__format__ (__printf__, 3, 4)));
 
 #define __open_proc(pid, ier, flags, fmt, ...)				\
 	({								\

Comments

Andrey Vagin Feb. 15, 2017, 2:25 a.m.
Applied. Thanks!
On Mon, Feb 13, 2017 at 02:52:32PM -0800, Kir Kolyshkin wrote:
> This will help us catch bugs where the arguments are not in line
> with the format string.
> 
> Signed-off-by: Kir Kolyshkin <kir@openvz.org>
> ---
>  criu/include/util.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/include/util.h b/criu/include/util.h
> index d1332ae..392fa8c 100644
> --- a/criu/include/util.h
> +++ b/criu/include/util.h
> @@ -73,7 +73,8 @@ extern int set_proc_fd(int fd);
>  #define PROC_GEN	-1
>  #define PROC_NONE	-2
>  
> -extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
> +extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...)
> +	__attribute__ ((__format__ (__printf__, 3, 4)));
>  
>  #define __open_proc(pid, ier, flags, fmt, ...)				\
>  	({								\
> -- 
> 2.9.3
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu