tests/xs: Check asprintf result
PATCH 1/1 tests/xs: Check asprintf result
Compiling xs-test.c on Ubuntu 21.04 fails with:
xs-test.c: In function ‘main’:
xs-test.c:486:5: error: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
486 | asprintf(&path, "%s/%u", TEST_PATH, getpid());
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Check the asprintf return and exit if it failed.
---
Using exit(2) since it is used for the xs_open failure.
--- tools/tests/xenstore/xs-test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/tests/xenstore/xs-test.c +11 -2
@@ -483,11 +483,20 @@ int main(int argc, char *argv[])return 0 ; } -asprintf (&path,"%s/%u" ,TEST_PATH ,getpid ()); + ret =asprintf (&path,"%s/%u" ,TEST_PATH ,getpid ()); +if (ret ==-1 ) { +perror ("asprintf" ); +exit (2 ); + } +for ( t =0 ; t <WRITE_BUFFERS_N ; t++ ) {memset (write_buffers[t],'a' + t,WRITE_BUFFERS_SIZE ); -asprintf (&paths[t],"%s/%c" , path,'a' + t); + ret =asprintf (&paths[t],"%s/%c" , path,'a' + t); +if (ret ==-1 ) { +perror ("asprintf" ); +exit (2 ); + } } xsh =xs_open (0 );
Signature · 1 line
2.30.2
Jason Andryuk writes ("[PATCH] tests/xs: Check asprintf result"):
Quoted 1 line
Compiling
xs-test.con Ubuntu 21.04 fails with:
Thanks. However, your patch doesn't apply to staging; the files have been reorganised AFAICT. Also, I think
93c9edbef51b31056f93a37a778326c90a83158c
tests/xenstore: Rework Makefile
fixed this (with slightly different style, and despite not mentioning this change in the commit message)
Ian.
Quoted 4 lines · Ian Jackson
Jason Andryuk writes ("[PATCH] tests/xs: Check asprintf result"):
Quoted 1 line
Compiling
xs-test.con Ubuntu 21.04 fails with:
Quoted 8 lines
Thanks. However, your patch doesn't apply to staging; the files have been reorganised AFAICT. Also, I think
93c9edbef51b31056f93a37a778326c90a83158c
tests/xenstore: ReworkMakefilefixed this (with slightly different style, and despite not mentioning this change in the commit message)
Yes, that looks like it fixed it.
Sorry, I was working off a stale branch, so I didn't realize this was fixed.
Regards,
Jason
Quoted 10 lines · Ian Jackson
Jason Andryuk writes ("[PATCH] tests/xs: Check asprintf result"):
Quoted 1 line
Compiling
xs-test.con Ubuntu 21.04 fails with:Thanks. However, your patch doesn't apply to staging; the files have been reorganised AFAICT. Also, I think
93c9edbef51b31056f93a37a778326c90a83158c
tests/xenstore: ReworkMakefilefixed this (with slightly different style, and despite not mentioning this change in the commit message)
? Literally half of the commit message pertains to this failure.
~Andrew
Andrew Cooper writes ("Re: [PATCH] tests/xs: Check asprintf result"):
Quoted 5 lines · Ian Jackson
Quoted 2 lines
fixed this (with slightly different style, and despite not mentioning this change in the commit message)
? Literally half of the commit message pertains to this failure.
Sorry, I meant the title, which talks only about Makefile stuff.
Ian.