Skip to content

Commit a959dbd

Browse files
cgzonesTetsuo Handa
authored andcommitted
tomoyo: add format attributes to functions
Format attributes on functions taking format string can help compilers detect argument type or count mismatches. Please the compiler when building with W=1: security/tomoyo/audit.c: In function ‘tomoyo_init_log’: security/tomoyo/audit.c:290:9: error: function ‘tomoyo_init_log’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] 290 | vsnprintf(buf + pos, len - pos, fmt, args); | ^~~~~~~~~ security/tomoyo/audit.c: In function ‘tomoyo_write_log2’: security/tomoyo/audit.c:376:9: error: function ‘tomoyo_write_log2’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] 376 | buf = tomoyo_init_log(r, len, fmt, args); | ^~~ security/tomoyo/common.c: In function ‘tomoyo_addprintf’: security/tomoyo/common.c:193:9: error: function ‘tomoyo_addprintf’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format] 193 | vsnprintf(buffer + pos, len - pos - 1, fmt, args); | ^~~~~~~~~ Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
1 parent c278253 commit a959dbd

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

security/tomoyo/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ static bool tomoyo_manage_by_non_root;
184184
*
185185
* Returns nothing.
186186
*/
187+
__printf(3, 4)
187188
static void tomoyo_addprintf(char *buffer, int len, const char *fmt, ...)
188189
{
189190
va_list args;

security/tomoyo/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ bool tomoyo_str_starts(char **src, const char *find);
954954
char *tomoyo_encode(const char *str);
955955
char *tomoyo_encode2(const char *str, int str_len);
956956
char *tomoyo_init_log(struct tomoyo_request_info *r, int len, const char *fmt,
957-
va_list args);
957+
va_list args) __printf(3, 0);
958958
char *tomoyo_read_token(struct tomoyo_acl_param *param);
959959
char *tomoyo_realpath_from_path(const struct path *path);
960960
char *tomoyo_realpath_nofollow(const char *pathname);
@@ -1067,7 +1067,7 @@ void tomoyo_warn_oom(const char *function);
10671067
void tomoyo_write_log(struct tomoyo_request_info *r, const char *fmt, ...)
10681068
__printf(2, 3);
10691069
void tomoyo_write_log2(struct tomoyo_request_info *r, int len, const char *fmt,
1070-
va_list args);
1070+
va_list args) __printf(3, 0);
10711071

10721072
/********** External variable definitions. **********/
10731073

0 commit comments

Comments
 (0)