38
38
#include <fcntl.h>
39
39
40
40
#include "shared/helpers.h"
41
+ #include "shared/string-helpers.h"
41
42
#include "weston-test-fixture-compositor.h"
42
43
#include "weston.h"
43
44
#include "test-config.h"
@@ -116,7 +117,8 @@ get_lock_path(void)
116
117
return NULL ;
117
118
}
118
119
119
- if (asprintf (& lock_path , "%s/%s" , env_path , suffix ) == -1 )
120
+ str_printf (& lock_path , "%s/%s" , env_path , suffix );
121
+ if (!lock_path )
120
122
return NULL ;
121
123
122
124
return lock_path ;
@@ -345,10 +347,10 @@ execute_compositor(const struct compositor_setup *setup,
345
347
prog_args_init (& args );
346
348
347
349
/* argv[0] */
348
- asprintf (& tmp , "weston-%s" , setup -> testset_name );
350
+ str_printf (& tmp , "weston-%s" , setup -> testset_name );
349
351
prog_args_take (& args , tmp );
350
352
351
- asprintf (& tmp , "--backend=%s" , backend_to_str (setup -> backend ));
353
+ str_printf (& tmp , "--backend=%s" , backend_to_str (setup -> backend ));
352
354
prog_args_take (& args , tmp );
353
355
354
356
if (setup -> backend == WESTON_BACKEND_DRM ) {
@@ -362,7 +364,7 @@ execute_compositor(const struct compositor_setup *setup,
362
364
ret = RESULT_SKIP ;
363
365
goto out ;
364
366
}
365
- asprintf (& tmp , "--drm-device=%s" , drm_device );
367
+ str_printf (& tmp , "--drm-device=%s" , drm_device );
366
368
prog_args_take (& args , tmp );
367
369
368
370
prog_args_take (& args , strdup ("--seat=weston-test-seat" ));
@@ -379,36 +381,36 @@ execute_compositor(const struct compositor_setup *setup,
379
381
/* Test suite needs the debug protocol to be able to take screenshots */
380
382
prog_args_take (& args , strdup ("--debug" ));
381
383
382
- asprintf (& tmp , "--socket=%s" , setup -> testset_name );
384
+ str_printf (& tmp , "--socket=%s" , setup -> testset_name );
383
385
prog_args_take (& args , tmp );
384
386
385
- asprintf (& tmp , "--modules=%s%s%s" , TESTSUITE_PLUGIN_PATH ,
386
- setup -> extra_module ? "," : "" ,
387
- setup -> extra_module ? setup -> extra_module : "" );
387
+ str_printf (& tmp , "--modules=%s%s%s" , TESTSUITE_PLUGIN_PATH ,
388
+ setup -> extra_module ? "," : "" ,
389
+ setup -> extra_module ? setup -> extra_module : "" );
388
390
prog_args_take (& args , tmp );
389
391
390
392
if (setup -> backend != WESTON_BACKEND_DRM &&
391
393
setup -> backend != WESTON_BACKEND_FBDEV ) {
392
- asprintf (& tmp , "--width=%d" , setup -> width );
394
+ str_printf (& tmp , "--width=%d" , setup -> width );
393
395
prog_args_take (& args , tmp );
394
396
395
- asprintf (& tmp , "--height=%d" , setup -> height );
397
+ str_printf (& tmp , "--height=%d" , setup -> height );
396
398
prog_args_take (& args , tmp );
397
399
}
398
400
399
401
if (setup -> scale != 1 ) {
400
- asprintf (& tmp , "--scale=%d" , setup -> scale );
402
+ str_printf (& tmp , "--scale=%d" , setup -> scale );
401
403
prog_args_take (& args , tmp );
402
404
}
403
405
404
406
if (setup -> transform != WL_OUTPUT_TRANSFORM_NORMAL ) {
405
- asprintf (& tmp , "--transform=%s" ,
406
- transform_to_str (setup -> transform ));
407
+ str_printf (& tmp , "--transform=%s" ,
408
+ transform_to_str (setup -> transform ));
407
409
prog_args_take (& args , tmp );
408
410
}
409
411
410
412
if (setup -> config_file ) {
411
- asprintf (& tmp , "--config=%s" , setup -> config_file );
413
+ str_printf (& tmp , "--config=%s" , setup -> config_file );
412
414
prog_args_take (& args , tmp );
413
415
free (setup -> config_file );
414
416
} else {
@@ -419,11 +421,11 @@ execute_compositor(const struct compositor_setup *setup,
419
421
if (ctmp )
420
422
prog_args_take (& args , strdup (ctmp ));
421
423
422
- asprintf (& tmp , "--shell=%s" , shell_to_str (setup -> shell ));
424
+ str_printf (& tmp , "--shell=%s" , shell_to_str (setup -> shell ));
423
425
prog_args_take (& args , tmp );
424
426
425
427
if (setup -> logging_scopes ) {
426
- asprintf (& tmp , "--logger-scopes=%s" , setup -> logging_scopes );
428
+ str_printf (& tmp , "--logger-scopes=%s" , setup -> logging_scopes );
427
429
prog_args_take (& args , tmp );
428
430
}
429
431
@@ -472,7 +474,8 @@ open_ini_file(struct compositor_setup *setup)
472
474
wd = realpath ("." , NULL );
473
475
assert (wd );
474
476
475
- if (asprintf (& tmp_path , "%s/%s.ini" , wd , setup -> testset_name ) == -1 ) {
477
+ str_printf (& tmp_path , "%s/%s.ini" , wd , setup -> testset_name );
478
+ if (!tmp_path ) {
476
479
fprintf (stderr , "Fail formatting Weston.ini file name.\n" );
477
480
goto out ;
478
481
}
0 commit comments