All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/xs: Check asprintf result
@ 2021-07-18 13:56 Jason Andryuk
  2021-07-20 14:31 ` Ian Jackson
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Andryuk @ 2021-07-18 13:56 UTC (permalink / raw)
  To: xen-devel; +Cc: jgross, Jason Andryuk, Ian Jackson, Wei Liu

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.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
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(-)

diff --git a/tools/tests/xenstore/xs-test.c b/tools/tests/xenstore/xs-test.c
index c4c99c0661..f42c1cfe66 100644
--- a/tools/tests/xenstore/xs-test.c
+++ b/tools/tests/xenstore/xs-test.c
@@ -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);
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] tests/xs: Check asprintf result
  2021-07-18 13:56 [PATCH] tests/xs: Check asprintf result Jason Andryuk
@ 2021-07-20 14:31 ` Ian Jackson
  2021-07-20 14:41   ` Jason Andryuk
  2021-07-20 15:40   ` Andrew Cooper
  0 siblings, 2 replies; 5+ messages in thread
From: Ian Jackson @ 2021-07-20 14:31 UTC (permalink / raw)
  To: Jason Andryuk
  Cc: xen-devel, jgross, Ian Jackson, Wei Liu, Jan Beulich, Andrew Cooper

Jason Andryuk writes ("[PATCH] tests/xs: Check asprintf result"):
> Compiling xs-test.c on 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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tests/xs: Check asprintf result
  2021-07-20 14:31 ` Ian Jackson
@ 2021-07-20 14:41   ` Jason Andryuk
  2021-07-20 15:40   ` Andrew Cooper
  1 sibling, 0 replies; 5+ messages in thread
From: Jason Andryuk @ 2021-07-20 14:41 UTC (permalink / raw)
  To: Ian Jackson; +Cc: xen-devel, Juergen Gross, Wei Liu, Jan Beulich, Andrew Cooper

On Tue, Jul 20, 2021 at 10:31 AM Ian Jackson <iwj@xenproject.org> wrote:
>
> Jason Andryuk writes ("[PATCH] tests/xs: Check asprintf result"):
> > Compiling xs-test.c on 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)

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tests/xs: Check asprintf result
  2021-07-20 14:31 ` Ian Jackson
  2021-07-20 14:41   ` Jason Andryuk
@ 2021-07-20 15:40   ` Andrew Cooper
  2021-07-20 15:59     ` Ian Jackson
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2021-07-20 15:40 UTC (permalink / raw)
  To: Ian Jackson, Jason Andryuk; +Cc: xen-devel, jgross, Wei Liu, Jan Beulich

On 20/07/2021 15:31, Ian Jackson wrote:
> Jason Andryuk writes ("[PATCH] tests/xs: Check asprintf result"):
>> Compiling xs-test.c on 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)

?  Literally half of the commit message pertains to this failure.

~Andrew



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] tests/xs: Check asprintf result
  2021-07-20 15:40   ` Andrew Cooper
@ 2021-07-20 15:59     ` Ian Jackson
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Jackson @ 2021-07-20 15:59 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Jason Andryuk, xen-devel, jgross, Wei Liu, Jan Beulich

Andrew Cooper writes ("Re: [PATCH] tests/xs: Check asprintf result"):
> On 20/07/2021 15:31, Ian Jackson wrote:
> > 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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-20 16:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-18 13:56 [PATCH] tests/xs: Check asprintf result Jason Andryuk
2021-07-20 14:31 ` Ian Jackson
2021-07-20 14:41   ` Jason Andryuk
2021-07-20 15:40   ` Andrew Cooper
2021-07-20 15:59     ` Ian Jackson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.