@@ -56,6 +56,7 @@ static_assert(0, "kselftest harness requires _GNU_SOURCE to be defined");
56
56
#include <asm/types.h>
57
57
#include <ctype.h>
58
58
#include <errno.h>
59
+ #include <limits.h>
59
60
#include <stdbool.h>
60
61
#include <stdint.h>
61
62
#include <stdio.h>
@@ -1216,7 +1217,7 @@ void __run_test(struct __fixture_metadata *f,
1216
1217
struct __test_metadata * t )
1217
1218
{
1218
1219
struct __test_xfail * xfail ;
1219
- char * test_name ;
1220
+ char test_name [ LINE_MAX ] ;
1220
1221
const char * diagnostic ;
1221
1222
1222
1223
/* reset test struct */
@@ -1227,12 +1228,8 @@ void __run_test(struct __fixture_metadata *f,
1227
1228
memset (t -> env , 0 , sizeof (t -> env ));
1228
1229
memset (t -> results -> reason , 0 , sizeof (t -> results -> reason ));
1229
1230
1230
- if (asprintf (& test_name , "%s%s%s.%s" , f -> name ,
1231
- variant -> name [0 ] ? "." : "" , variant -> name , t -> name ) == -1 ) {
1232
- ksft_print_msg ("ERROR ALLOCATING MEMORY\n" );
1233
- t -> exit_code = KSFT_FAIL ;
1234
- _exit (t -> exit_code );
1235
- }
1231
+ snprintf (test_name , sizeof (test_name ), "%s%s%s.%s" ,
1232
+ f -> name , variant -> name [0 ] ? "." : "" , variant -> name , t -> name );
1236
1233
1237
1234
ksft_print_msg (" RUN %s ...\n" , test_name );
1238
1235
@@ -1270,7 +1267,6 @@ void __run_test(struct __fixture_metadata *f,
1270
1267
1271
1268
ksft_test_result_code (t -> exit_code , test_name ,
1272
1269
diagnostic ? "%s" : NULL , diagnostic );
1273
- free (test_name );
1274
1270
}
1275
1271
1276
1272
static int test_harness_run (int argc , char * * argv )
0 commit comments