Hello,

Mikhail Karpov, le mer. 21 oct. 2026 18:02:23 +0700, a ecrit:
> Also, I’d like to know whether the return value of
> mach_port_mod_refs should be checked as well.

Yes, we'd want to check that rather than letting refs miscounted.

> diff --git a/lwip/port/netif/hurdethif.c b/lwip/port/netif/hurdethif.c
> index 0370281..6444662 100644
> --- a/lwip/port/netif/hurdethif.c
> +++ b/lwip/port/netif/hurdethif.c
> @@ -174,8 +174,11 @@ hurdethif_device_open (struct netif *netif)
>    else
>      {
>        ethif->readptname = ports_get_right (ethif->readpt);
> -      mach_port_insert_right (mach_task_self (), ethif->readptname,
> -                           ethif->readptname, MACH_MSG_TYPE_MAKE_SEND);
> +      err = mach_port_insert_right (mach_task_self (), ethif->readptname,
> +                                 ethif->readptname,
> +                                 MACH_MSG_TYPE_MAKE_SEND);
> +      if (err)
> +        error (0, err, "mach_port_insert_right");

We'd also want to avoid doing the rest of the function. Actually the
function could be simplified first in a preparatory patch, with some
return err; rather than "else" statements.

> diff --git a/trans/streamio.c b/trans/streamio.c
> index 694da06..57bbf04 100644
> --- a/trans/streamio.c
> +++ b/trans/streamio.c
> @@ -834,14 +834,13 @@ dev_open (const char *name, dev_mode_t mode)
>    err = ports_create_port (phys_reply_class, streamdev_bucket,
>                          sizeof (struct port_info), &phys_reply_pi);
>    if (err)
> -    {
> -      mach_port_deallocate (mach_task_self (), device_master);
> -      return err;
> -    }
> +    goto device_master_deallocate;

Yes, that makes things simpler.

Samuel

Reply via email to