Applied, thanks!

[email protected], le dim. 28 sept. 2025 19:17:20 +0100, a ecrit:
> From: Diego Nieto Cid <[email protected]>
> 
>     ../../trans/mtab.c: In function 'mtab_populate':
>     ../../trans/mtab.c:460:9: warning: ignoring return value of 'asprintf' 
> declared with attribute 'warn_unused_result' [-Wunused-result]
> 
>     ../../trans/mtab.c: In function 'argz_add_device':
>     ../../trans/mtab.c:538:3: warning: ignoring return value of 'asprintf' 
> declared with attribute 'warn_unused_result' [-Wunused-result]
> 
>     ../../trans/mtab.c: In function 'map_device_to_path':
>     ../../trans/mtab.c:580:9: warning: ignoring return value of 'asprintf' 
> declared with attribute 'warn_unused_result' [-Wunused-result]
>     ../../trans/mtab.c:582:9: warning: ignoring return value of 'asprintf' 
> declared with attribute 'warn_unused_result' [-Wunused-result]
>     ../../trans/mtab.c:587:5: warning: ignoring return value of 'asprintf' 
> declared with attribute 'warn_unused_result' [-Wunused-result]
> ---
>  trans/mtab.c | 27 +++++++++++++++++----------
>  1 file changed, 17 insertions(+), 10 deletions(-)
> 
> diff --git a/trans/mtab.c b/trans/mtab.c
> index b5b4a9a8..f5cada4a 100644
> --- a/trans/mtab.c
> +++ b/trans/mtab.c
> @@ -457,11 +457,11 @@ mtab_populate (struct mtab *mtab, const char *path, 
> mach_port_t control,
>          if (! MACH_PORT_VALID (controls[i]))
>            continue;
>  
> -     asprintf (&p, "%s%s%s",
> -               path,
> -               path[strlen (path) - 1] == '/'? "": "/",
> -               c);
> -     if (! p)
> +     err = asprintf (&p, "%s%s%s",
> +                     path,
> +                     path[strlen (path) - 1] == '/'? "": "/",
> +                     c);
> +     if (err == -1)
>         {
>           err = ENOMEM;
>           goto errout;
> @@ -535,8 +535,8 @@ argz_add_device (char **options, size_t *options_len, 
> const char *device)
>  
>    /* device specifies a size.  */
>    char *arg = NULL;
> -  asprintf (&arg, "size=%s", device);
> -  if (! arg)
> +  err = asprintf (&arg, "size=%s", device);
> +  if (err == -1)
>      return ENOMEM;
>  
>    err = argz_add (options, options_len, arg);
> @@ -563,6 +563,7 @@ looks_like_block_device (const char *s)
>  error_t
>  map_device_to_path (const char *device, char **path)
>  {
> +  int err;
>    int part = -1;
>    if (strncmp (device, "part:", 5) == 0)
>      {
> @@ -577,14 +578,20 @@ map_device_to_path (const char *device, char **path)
>    if (strncmp (device, "device:", 7) == 0)
>      {
>        if (part >= 0)
> -     asprintf (path, "/dev/%ss%u", &device[7], part);
> +     err = asprintf (path, "/dev/%ss%u", &device[7], part);
>        else
> -     asprintf (path, "/dev/%s", &device[7]);
> +     err = asprintf (path, "/dev/%s", &device[7]);
> +      if (err == -1)
> +     return ENOMEM;
>      }
>    else if (strncmp (device, "/dev/", 5) == 0)
>      *path = strdup (device);
>    else if (looks_like_block_device (device))
> -    asprintf (path, "/dev/%s", device);
> +    {
> +      err = asprintf (path, "/dev/%s", device);
> +      if (err == -1)
> +     return ENOMEM;
> +    }
>    else
>      *path = strdup (device);
>  
> -- 
> 2.51.0
> 
> 

-- 
Samuel
What's this script do?
    unzip ; touch ; finger ; mount ; gasp ; yes ; umount ; sleep
Hint for the answer: not everything is computer-oriented. Sometimes you're
in a sleeping bag, camping out.
(Contributed by Frans van der Zande.)

Reply via email to