Hello,

Mikhail Karpov, le jeu. 11 juin 2026 21:58:52 +0700, a ecrit:
> diff --git a/boot/boot.c b/boot/boot.c
> index 70a82f06..b957a199 100644
> --- a/boot/boot.c
> +++ b/boot/boot.c
> @@ -898,9 +898,23 @@ read_reply (void)
>    pthread_spin_unlock (&queuelock);
>  
>    if (qr->type == DEV_READ)
> -    buf = mmap (0, qr->amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
> +    {
> +      buf = mmap (0, qr->amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
> +      if (buf == MAP_FAILED)
> +     {
> +       pthread_spin_unlock (&readlock);
> +       return;

Since we can't return an error code, better use assert_backtrace to
crash.

> +        }
> +    }
>    else
> -    buf = alloca (qr->amount);
> +    {
> +      buf = alloca (qr->amount);
> +      if (!buf)
> +     {
> +       pthread_spin_unlock (&readlock);
> +       return;

Same here.

> +     }
> +    }
>    amtread = read (0, buf, qr->amount);
>  
>    pthread_spin_unlock (&readlock);

> diff --git a/fatfs/main.c b/fatfs/main.c
> index da6aa949..448e7e30 100644
> --- a/fatfs/main.c
> +++ b/fatfs/main.c
> @@ -235,6 +235,8 @@ main (int argc, char **argv)
>  
>    zerocluster = (vm_address_t) mmap (0, bytes_per_cluster, 
> PROT_READ|PROT_WRITE,
>                                    MAP_ANON, 0, 0);
> +  if (zerocluster == MAP_FAILED)
> +    return errno;

This is a main function, we can't return errno :)

Better assert_backtrace

> diff --git a/libmachdev/trivfs_server.c b/libmachdev/trivfs_server.c
> index 2c905a63..92672490 100644
> --- a/libmachdev/trivfs_server.c
> +++ b/libmachdev/trivfs_server.c
> @@ -294,6 +294,9 @@ trivfs_S_fsys_init (struct trivfs_control *fsys,
>  
>    portarray = mmap (0, INIT_PORT_MAX * sizeof *portarray,
>                      PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
> +  if (portarray == MAP_FAILED)
> +    return errno;
> +

At bootstrap we have little error recovery management, better just
assert_backtrace like above.

> diff --git a/libnetfs/file-get-translator.c b/libnetfs/file-get-translator.c
> index 63c74c0b..61c1156e 100644
> --- a/libnetfs/file-get-translator.c
> +++ b/libnetfs/file-get-translator.c
> @@ -55,7 +55,16 @@ netfs_S_file_get_translator (struct protid *user,
>        if (!err)
>       {
>         if (len > *translen)
> -         *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
> +            {

Note the discrepancy between tab and spaces. The existing coding style
is to replace 8-spaces with a tab, please tell your editor to do so.

Thanks,
Samuel

Reply via email to