Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nderjung/904248c57659b2084ffc91aa5cb65d07 to your computer and use it in GitHub Desktop.
Save nderjung/904248c57659b2084ffc91aa5cb65d07 to your computer and use it in GitHub Desktop.
From f56ddf297d2ba1d15187df8b4d4ecbd46e9718d9 Mon Sep 17 00:00:00 2001
From: Alexander Jung <a.jung@lancs.ac.uk>
Date: Tue, 25 Jun 2019 18:14:40 +0000
Subject: [PATCH] xs-test: fix asprintf unused result
The XenStore test suite assigns values to a path via a pass-by-reference but
the method asprintf returns a success int which is unsed. This causes builds
to fail via -Werror=unused-result. This patch remedies this by exiting the
xs-test program if on the unlikely occassion it could not assign the variables
to the path format.
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
---
tools/tests/xenstore/xs-test.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/tests/xenstore/xs-test.c b/tools/tests/xenstore/xs-test.c
index c4c99c0..ba27dcb 100644
--- a/tools/tests/xenstore/xs-test.c
+++ b/tools/tests/xenstore/xs-test.c
@@ -483,11 +483,14 @@ int main(int argc, char *argv[])
return 0;
}
- asprintf(&path, "%s/%u", TEST_PATH, getpid());
+ if(!asprintf(&path, "%s/%u", TEST_PATH, getpid()))
+ 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);
+ if(!asprintf(&paths[t], "%s/%c", path, 'a' + t))
+ exit(-2);
}
xsh = xs_open(0);
--
2.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment