From: Diego Nieto Cid <[email protected]>
../../libstore/unknown.c: In function 'store_unknown_decode':
../../libstore/unknown.c:130:5: warning: ignoring return value of
'asprintf' declared with attribute 'warn_unused_result' [-Wunused-result]
130 | asprintf (&(*store)->name, "notype:%.*s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131 | (int) (us->data_len - us->cur_data), us->data +
us->cur_data);
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../libstore/unknown.c:133:5: warning: ignoring return value of
'asprintf' declared with attribute 'warn_unused_result' [-Wunused-result]
133 | asprintf (&(*store)->name, "type-%d:%.*s",
enc->ints[enc->cur_int],
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134 | (int) ( us->data_len - us->cur_data), us->data +
us->cur_data);
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
===============================================================================
../../libstore/nbd.c: In function 'store_nbd_open':
../../libstore/nbd.c:522:13: warning: ignoring return value of 'asprintf'
declared with attribute 'warn_unused_result' [-Wunused-result]
522 | asprintf (&(*store)->name, "%s%s", url_prefix, name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
libstore/nbd.c | 6 +++++-
libstore/unknown.c | 7 +++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/libstore/nbd.c b/libstore/nbd.c
index df949a78..5ddf2dc8 100644
--- a/libstore/nbd.c
+++ b/libstore/nbd.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
+#include <assert-backtrace.h>
// Avoid dragging in the resolver when linking statically.
@@ -519,7 +520,10 @@ store_nbd_open (const char *name, int flags, struct store
**store)
if (!strncmp (name, url_prefix, sizeof url_prefix - 1))
err = store_set_name (*store, name);
else
- asprintf (&(*store)->name, "%s%s", url_prefix, name);
+ {
+ int err2 = asprintf (&(*store)->name, "%s%s", url_prefix, name);
+ assert_backtrace (err2 != -1);
+ }
if (err)
store_free (*store);
}
diff --git a/libstore/unknown.c b/libstore/unknown.c
index 8b7f4268..0b06cbf7 100644
--- a/libstore/unknown.c
+++ b/libstore/unknown.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <assert-backtrace.h>
/* You can't do anything with an unknown store but encode it. */
@@ -127,12 +128,14 @@ store_unknown_decode (struct store_enc *enc,
/* Derive a name for this unknown store from its encoded type field
(or lack thereof) and the leading string of its encoded data bytes. */
if (enc->cur_int == enc->num_ints)
- asprintf (&(*store)->name, "notype:%.*s",
+ err = asprintf (&(*store)->name, "notype:%.*s",
(int) (us->data_len - us->cur_data), us->data + us->cur_data);
else
- asprintf (&(*store)->name, "type-%d:%.*s", enc->ints[enc->cur_int],
+ err = asprintf (&(*store)->name, "type-%d:%.*s", enc->ints[enc->cur_int],
(int) ( us->data_len - us->cur_data), us->data + us->cur_data);
+ assert_backtrace (err != -1);
+
return 0;
}
--
2.51.0