@@ -24,12 +24,12 @@ static char *test_buffer __initdata;
24
24
static char * fmt_buffer __initdata ;
25
25
static struct rnd_state rnd_state __initdata ;
26
26
27
- typedef int (* check_fn )(const void * check_data , const char * string ,
28
- const char * fmt , int n_args , va_list ap );
27
+ typedef int (* check_fn )(const char * file , const int line , const void * check_data ,
28
+ const char * string , const char * fmt , int n_args , va_list ap );
29
29
30
- static void __scanf (4 , 6 ) __init
31
- _test (check_fn fn , const void * check_data , const char * string , const char * fmt ,
32
- int n_args , ...)
30
+ static void __scanf (6 , 8 ) __init
31
+ _test (const char * file , const int line , check_fn fn , const void * check_data , const char * string ,
32
+ const char * fmt , int n_args , ...)
33
33
{
34
34
va_list ap , ap_copy ;
35
35
int ret ;
@@ -42,12 +42,12 @@ _test(check_fn fn, const void *check_data, const char *string, const char *fmt,
42
42
va_end (ap_copy );
43
43
44
44
if (ret != n_args ) {
45
- pr_warn ("vsscanf(\"%s\", \"%s\", ...) returned %d expected %d\n" ,
46
- string , fmt , ret , n_args );
45
+ pr_warn ("%s:%d: vsscanf(\"%s\", \"%s\", ...) returned %d expected %d\n" ,
46
+ file , line , string , fmt , ret , n_args );
47
47
goto fail ;
48
48
}
49
49
50
- ret = (* fn )(check_data , string , fmt , n_args , ap );
50
+ ret = (* fn )(file , line , check_data , string , fmt , n_args , ap );
51
51
if (ret )
52
52
goto fail ;
53
53
@@ -67,88 +67,88 @@ do { \
67
67
typeof(*expect) got = *va_arg(ap, typeof(expect)); \
68
68
pr_debug("\t" arg_fmt "\n", got); \
69
69
if (got != *expect) { \
70
- pr_warn("vsscanf(\"%s\", \"%s\", ...) expected " arg_fmt " got " arg_fmt "\n", \
71
- str, fmt, *expect, got); \
70
+ pr_warn("%s:%d, vsscanf(\"%s\", \"%s\", ...) expected " arg_fmt " got " arg_fmt "\n", \
71
+ file, line, str, fmt, *expect, got); \
72
72
return 1; \
73
73
} \
74
74
} \
75
75
return 0; \
76
76
} while (0)
77
77
78
- static int __init check_ull (const void * check_data , const char * string ,
79
- const char * fmt , int n_args , va_list ap )
78
+ static int __init check_ull (const char * file , const int line , const void * check_data ,
79
+ const char * string , const char * fmt , int n_args , va_list ap )
80
80
{
81
81
const unsigned long long * pval = check_data ;
82
82
83
83
_check_numbers_template ("%llu" , pval , string , fmt , n_args , ap );
84
84
}
85
85
86
- static int __init check_ll (const void * check_data , const char * string ,
87
- const char * fmt , int n_args , va_list ap )
86
+ static int __init check_ll (const char * file , const int line , const void * check_data ,
87
+ const char * string , const char * fmt , int n_args , va_list ap )
88
88
{
89
89
const long long * pval = check_data ;
90
90
91
91
_check_numbers_template ("%lld" , pval , string , fmt , n_args , ap );
92
92
}
93
93
94
- static int __init check_ulong (const void * check_data , const char * string ,
95
- const char * fmt , int n_args , va_list ap )
94
+ static int __init check_ulong (const char * file , const int line , const void * check_data ,
95
+ const char * string , const char * fmt , int n_args , va_list ap )
96
96
{
97
97
const unsigned long * pval = check_data ;
98
98
99
99
_check_numbers_template ("%lu" , pval , string , fmt , n_args , ap );
100
100
}
101
101
102
- static int __init check_long (const void * check_data , const char * string ,
103
- const char * fmt , int n_args , va_list ap )
102
+ static int __init check_long (const char * file , const int line , const void * check_data ,
103
+ const char * string , const char * fmt , int n_args , va_list ap )
104
104
{
105
105
const long * pval = check_data ;
106
106
107
107
_check_numbers_template ("%ld" , pval , string , fmt , n_args , ap );
108
108
}
109
109
110
- static int __init check_uint (const void * check_data , const char * string ,
111
- const char * fmt , int n_args , va_list ap )
110
+ static int __init check_uint (const char * file , const int line , const void * check_data ,
111
+ const char * string , const char * fmt , int n_args , va_list ap )
112
112
{
113
113
const unsigned int * pval = check_data ;
114
114
115
115
_check_numbers_template ("%u" , pval , string , fmt , n_args , ap );
116
116
}
117
117
118
- static int __init check_int (const void * check_data , const char * string ,
119
- const char * fmt , int n_args , va_list ap )
118
+ static int __init check_int (const char * file , const int line , const void * check_data ,
119
+ const char * string , const char * fmt , int n_args , va_list ap )
120
120
{
121
121
const int * pval = check_data ;
122
122
123
123
_check_numbers_template ("%d" , pval , string , fmt , n_args , ap );
124
124
}
125
125
126
- static int __init check_ushort (const void * check_data , const char * string ,
127
- const char * fmt , int n_args , va_list ap )
126
+ static int __init check_ushort (const char * file , const int line , const void * check_data ,
127
+ const char * string , const char * fmt , int n_args , va_list ap )
128
128
{
129
129
const unsigned short * pval = check_data ;
130
130
131
131
_check_numbers_template ("%hu" , pval , string , fmt , n_args , ap );
132
132
}
133
133
134
- static int __init check_short (const void * check_data , const char * string ,
135
- const char * fmt , int n_args , va_list ap )
134
+ static int __init check_short (const char * file , const int line , const void * check_data ,
135
+ const char * string , const char * fmt , int n_args , va_list ap )
136
136
{
137
137
const short * pval = check_data ;
138
138
139
139
_check_numbers_template ("%hd" , pval , string , fmt , n_args , ap );
140
140
}
141
141
142
- static int __init check_uchar (const void * check_data , const char * string ,
143
- const char * fmt , int n_args , va_list ap )
142
+ static int __init check_uchar (const char * file , const int line , const void * check_data ,
143
+ const char * string , const char * fmt , int n_args , va_list ap )
144
144
{
145
145
const unsigned char * pval = check_data ;
146
146
147
147
_check_numbers_template ("%hhu" , pval , string , fmt , n_args , ap );
148
148
}
149
149
150
- static int __init check_char (const void * check_data , const char * string ,
151
- const char * fmt , int n_args , va_list ap )
150
+ static int __init check_char (const char * file , const int line , const void * check_data ,
151
+ const char * string , const char * fmt , int n_args , va_list ap )
152
152
{
153
153
const signed char * pval = check_data ;
154
154
@@ -196,7 +196,7 @@ do { \
196
196
T result = ~expect_val; /* should be overwritten */ \
197
197
\
198
198
snprintf (test_buffer , BUF_SIZE , gen_fmt , expect_val ); \
199
- _test (fn , & expect_val , test_buffer , "%" scan_fmt , 1 , & result ); \
199
+ _test (__FILE__ , __LINE__ , fn , & expect_val , test_buffer , "%" scan_fmt , 1 , & result ); \
200
200
} while (0 )
201
201
202
202
#define simple_numbers_loop (T , gen_fmt , scan_fmt , fn ) \
@@ -344,7 +344,7 @@ static void __init append_delim(char *str_buf, int *str_buf_pos, int str_buf_len
344
344
#define test_array_8 (fn , check_data , string , fmt , arr ) \
345
345
do { \
346
346
BUILD_BUG_ON(ARRAY_SIZE(arr) != 8); \
347
- _test(fn, check_data, string, fmt, 8, \
347
+ _test(__FILE__, __LINE__, fn, check_data, string, fmt, 8, \
348
348
&(arr)[0], &(arr)[1], &(arr)[2], &(arr)[3], \
349
349
&(arr)[4], &(arr)[5], &(arr)[6], &(arr)[7]); \
350
350
} while (0)
@@ -608,7 +608,7 @@ do { \
608
608
const T expect[2] = { expect0, expect1 }; \
609
609
T result[2] = { (T)~expect[0], (T)~expect[1] }; \
610
610
\
611
- _test(fn, &expect, str, scan_fmt, n_args, &result[0], &result[1]); \
611
+ _test(__FILE__, __LINE__, fn, &expect, str, scan_fmt, n_args, &result[0], &result[1]); \
612
612
} while (0)
613
613
614
614
/*
0 commit comments