[email protected], le sam. 27 sept. 2025 21:50:33 +0100, a ecrit:
> 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     | 7 ++++++-
>  libstore/unknown.c | 7 +++++--
>  2 files changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libstore/nbd.c b/libstore/nbd.c
> index df949a78..5a7219fa 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,11 @@ 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 err;
> +           err = asprintf (&(*store)->name, "%s%s", url_prefix, name);

That will sooner or later warn that the previous `err` variable is being
shadowed.

> +           assert_backtrace (err != -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
> 
> 

-- 
Samuel
Anyone who thinks UNIX is intuitive should be forced to write 5000 lines of 
code using nothing but vi or emacs. AAAAACK!
(Discussion in comp.os.linux.misc on the intuitiveness of commands, especially
Emacs.)

Reply via email to