[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/4] lwip: Use the right error type.
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 2/4] lwip: Use the right error type. |
Date: |
Sun, 31 Mar 2019 20:01:47 +0200 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
Joan Lledó, le dim. 31 mars 2019 19:55:39 +0200, a ecrit:
> Use lwip's err_t as return type for functions called from lwip
> and error_t for functions called from the translator.
Applied, thanks!
> * lwip/io-ops.c: Include <errno.h>
> * as is not being included for other headers anymore.
> * lwip/lwip-util.h: Likewise.
> * lwip/port/include/netif/hurdethif.h:
> * Include <errno.h>
> * Change the return type of the init function to err_t.
> * lwip/port/include/netif/hurdloopif.h: Liekwise.
> * lwip/port/include/netif/hurdtunif.h: Likewise.
> * lwip/port/include/netif/ifcommon.h: Likewise.
> * lwip/port/netif/ifcommon.c: Likewise.
> * lwip/port/netif/hurdloopif.c:
> * Include <errno.h>
> * Change output function return type to err_t.
> * Return lwip's err_t codes.
> * lwip/port/netif/hurdethif.c:
> * Include <errno.h>
> * Change init function return type to err_t.
> * Change output function return type to err_t.
> * Return lwip's err_t codes.
> * lwip/port/netif/hurdtunif.c: Likewise.
> ---
> lwip/io-ops.c | 1 +
> lwip/lwip-util.h | 2 ++
> lwip/port/include/netif/hurdethif.h | 2 +-
> lwip/port/include/netif/hurdloopif.h | 2 +-
> lwip/port/include/netif/hurdtunif.h | 2 +-
> lwip/port/include/netif/ifcommon.h | 5 +++--
> lwip/port/netif/hurdethif.c | 8 ++++----
> lwip/port/netif/hurdloopif.c | 8 ++++----
> lwip/port/netif/hurdtunif.c | 19 +++++++++++--------
> lwip/port/netif/ifcommon.c | 5 +++--
> 10 files changed, 31 insertions(+), 23 deletions(-)
>
> diff --git a/lwip/io-ops.c b/lwip/io-ops.c
> index 72e08e26..89d596a4 100644
> --- a/lwip/io-ops.c
> +++ b/lwip/io-ops.c
> @@ -28,6 +28,7 @@
> #include <unistd.h>
> #include <stdlib.h>
> #include <time.h>
> +#include <errno.h>
>
> #include <lwip/sockets.h>
>
> diff --git a/lwip/lwip-util.h b/lwip/lwip-util.h
> index 03022331..c1bf8c58 100644
> --- a/lwip/lwip-util.h
> +++ b/lwip/lwip-util.h
> @@ -25,6 +25,8 @@
>
> #define LOOP_DEV_NAME "lo"
>
> +#include <errno.h>
> +
> #include <lwip/netif.h>
>
> void init_ifs (void *arg);
> diff --git a/lwip/port/include/netif/hurdethif.h
> b/lwip/port/include/netif/hurdethif.h
> index 326b1cf9..0ecbbd91 100644
> --- a/lwip/port/include/netif/hurdethif.h
> +++ b/lwip/port/include/netif/hurdethif.h
> @@ -31,7 +31,7 @@
> typedef struct ifcommon hurdethif;
>
> /* Device initialization */
> -error_t hurdethif_device_init (struct netif *netif);
> +err_t hurdethif_device_init (struct netif *netif);
>
> /* Module initialization */
> error_t hurdethif_module_init ();
> diff --git a/lwip/port/include/netif/hurdloopif.h
> b/lwip/port/include/netif/hurdloopif.h
> index fb5c5b83..71ac6f43 100644
> --- a/lwip/port/include/netif/hurdloopif.h
> +++ b/lwip/port/include/netif/hurdloopif.h
> @@ -31,6 +31,6 @@
> typedef struct ifcommon hurdloopif;
>
> /* Device initialization */
> -error_t hurdloopif_device_init (struct netif *netif);
> +err_t hurdloopif_device_init (struct netif *netif);
>
> #endif /* LWIP_HURDLOOPIF_H */
> diff --git a/lwip/port/include/netif/hurdtunif.h
> b/lwip/port/include/netif/hurdtunif.h
> index 938465bb..65e34ac3 100644
> --- a/lwip/port/include/netif/hurdtunif.h
> +++ b/lwip/port/include/netif/hurdtunif.h
> @@ -57,7 +57,7 @@ struct port_class *tunnel_cntlclass;
> struct port_class *tunnel_class;
>
> /* Device initialization */
> -error_t hurdtunif_device_init (struct netif *netif);
> +err_t hurdtunif_device_init (struct netif *netif);
>
> /* Module initialization */
> error_t hurdtunif_module_init ();
> diff --git a/lwip/port/include/netif/ifcommon.h
> b/lwip/port/include/netif/ifcommon.h
> index 15493dc9..51abae1c 100644
> --- a/lwip/port/include/netif/ifcommon.h
> +++ b/lwip/port/include/netif/ifcommon.h
> @@ -26,6 +26,7 @@
> #include <stdint.h>
> #include <sys/types.h>
> #include <device/device.h>
> +#include <errno.h>
>
> #include <lwip/netif.h>
>
> @@ -42,7 +43,7 @@ struct ifcommon
> uint16_t flags;
>
> /* Callbacks */
> - error_t (*init) (struct netif * netif);
> + err_t (*init) (struct netif * netif);
> error_t (*terminate) (struct netif * netif);
> error_t (*open) (struct netif * netif);
> error_t (*close) (struct netif * netif);
> @@ -50,7 +51,7 @@ struct ifcommon
> error_t (*change_flags) (struct netif * netif, uint16_t flags);
> };
>
> -error_t if_init (struct netif *netif);
> +err_t if_init (struct netif *netif);
> error_t if_terminate (struct netif *netif);
> error_t if_change_flags (struct netif *netif, uint16_t flags);
>
> diff --git a/lwip/port/netif/hurdethif.c b/lwip/port/netif/hurdethif.c
> index 4b088344..e076a3ac 100644
> --- a/lwip/port/netif/hurdethif.c
> +++ b/lwip/port/netif/hurdethif.c
> @@ -263,7 +263,7 @@ hurdethif_device_close (struct netif *netif)
> /*
> * Called from lwip when outgoing data is ready
> */
> -static error_t
> +static err_t
> hurdethif_output (struct netif *netif, struct pbuf *p)
> {
> error_t err;
> @@ -453,8 +453,8 @@ hurdethif_device_terminate (struct netif *netif)
> *
> * The module must be initialized before calling this function.
> */
> -error_t
> -hurdethif_device_init (struct netif * netif)
> +err_t
> +hurdethif_device_init (struct netif *netif)
> {
> error_t err;
> size_t count = 2;
> @@ -494,7 +494,7 @@ hurdethif_device_init (struct netif * netif)
> /* We need the device to be opened to configure it */
> err = hurdethif_device_open (netif);
> if (err)
> - return err;
> + return ERR_IF;
>
> /* Get the MAC address */
> ether_port = netif_get_state (netif)->ether_port;
> diff --git a/lwip/port/netif/hurdloopif.c b/lwip/port/netif/hurdloopif.c
> index ef64b8b6..9888e9a2 100644
> --- a/lwip/port/netif/hurdloopif.c
> +++ b/lwip/port/netif/hurdloopif.c
> @@ -25,6 +25,7 @@
> #include <net/if.h>
> #include <net/if_arp.h>
> #include <string.h>
> +#include <errno.h>
>
> #include <lwip-util.h>
>
> @@ -72,10 +73,9 @@ hurdloopif_device_terminate (struct netif *netif)
> /*
> * Set up the LwIP loopback interface
> */
> -error_t
> -hurdloopif_device_init (struct netif * netif)
> +err_t
> +hurdloopif_device_init (struct netif *netif)
> {
> - error_t err = 0;
> hurdloopif *loopif;
>
> /*
> @@ -108,5 +108,5 @@ hurdloopif_device_init (struct netif * netif)
> loopif->update_mtu = hurdloopif_device_update_mtu;
> loopif->change_flags = hurdloopif_device_set_flags;
>
> - return err;
> + return ERR_OK;
> }
> diff --git a/lwip/port/netif/hurdtunif.c b/lwip/port/netif/hurdtunif.c
> index d7991baa..80b5280d 100644
> --- a/lwip/port/netif/hurdtunif.c
> +++ b/lwip/port/netif/hurdtunif.c
> @@ -27,6 +27,7 @@
> #include <net/if_arp.h>
> #include <error.h>
> #include <sys/mman.h>
> +#include <errno.h>
>
> #include <lwip-hurd.h>
>
> @@ -117,11 +118,10 @@ hurdtunif_device_terminate (struct netif *netif)
> *
> * Just enqueue the data.
> */
> -static error_t
> +static err_t
> hurdtunif_output (struct netif *netif, struct pbuf *p,
> const ip4_addr_t * ipaddr)
> {
> - error_t err = 0;
> struct hurdtunif *tunif;
> struct pbuf *pcopy, *oldest;
>
> @@ -161,14 +161,14 @@ hurdtunif_output (struct netif *netif, struct pbuf *p,
>
> pthread_mutex_unlock (&tunif->lock);
>
> - return err;
> + return ERR_OK;
> }
>
> /*
> * Set up the tunnel a new tunnel device
> */
> -error_t
> -hurdtunif_device_init (struct netif * netif)
> +err_t
> +hurdtunif_device_init (struct netif *netif)
> {
> error_t err = 0;
> struct hurdtunif *tunif;
> @@ -229,7 +229,7 @@ hurdtunif_device_init (struct netif * netif)
> if (tunif->underlying == MACH_PORT_NULL)
> {
> error (0, 0, "%s", tunif->comm.devname);
> - return -1;
> + return ERR_IF;
> }
>
> err = trivfs_create_control (tunif->underlying, tunnel_cntlclass,
> @@ -246,7 +246,10 @@ hurdtunif_device_init (struct netif * netif)
> }
>
> if (err)
> - error (0, err, "%s", tunif->comm.devname);
> + {
> + error (0, err, "%s", tunif->comm.devname);
> + return ERR_IF;
> + }
>
> /* We'll need to get the netif from trivfs operations */
> tunif->cntl->hook = netif;
> @@ -260,7 +263,7 @@ hurdtunif_device_init (struct netif * netif)
> pthread_cond_init (&tunif->select, NULL);
> tunif->read_blocked = 0;
>
> - return err;
> + return ERR_OK;
> }
>
> /*
> diff --git a/lwip/port/netif/ifcommon.c b/lwip/port/netif/ifcommon.c
> index c6179683..5a1c68a2 100644
> --- a/lwip/port/netif/ifcommon.c
> +++ b/lwip/port/netif/ifcommon.c
> @@ -23,6 +23,7 @@
> #include <netif/ifcommon.h>
>
> #include <net/if.h>
> +#include <errno.h>
>
> #include <lwip/netifapi.h>
>
> @@ -70,8 +71,8 @@ if_close (struct netif *netif)
> * This function doesn't assume there's a device nor tries to open it.
> * If a device is present, it must be opened from the ifc->init() callback.
> */
> -error_t
> -if_init (struct netif * netif)
> +err_t
> +if_init (struct netif *netif)
> {
> struct ifcommon *ifc = netif_get_state (netif);
>
> --
> 2.17.1
>
>
--
Samuel
<v> je viens d'inventer mutt version magritte :D
<y> ?
<v> dans mutt
<v> tape "cceci" return