[PATCH rtems-lwip - v2 1/2] xemacpsif: fix compiler warnings

Kinsey Moore kinsey.moore at oarcorp.com
Fri Jan 5 19:30:25 UTC 2024


Two comments inline below.

On Fri, Jan 5, 2024 at 12:50 PM <berndmoessner80 at gmail.com> wrote:

> From: Bernd Moessner <berndmoessner80 at gmail.com>
>
> The compiler issues a couple of warnings as the Xilinx code omits to cast
> pointers ip_addr_t to
> the required ip4_addr_t or ip6_addr_t tpye.
>
> Note, ip_addr_t can hold ip4_addr_t and ip6_addr_t. Therefore, the
> complaints by GCC are correct, but
> do not indicate a major bug.
> ---
>  .../contrib/ports/xilinx/netif/xemacpsif.c    | 37 +++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git
> a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
> b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
> index 1bf3abb..70c72ee 100644
> ---
> a/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
> +++
> b/embeddedsw/ThirdParty/sw_services/lwip211/src/contrib/ports/xilinx/netif/xemacpsif.c
> @@ -61,14 +61,24 @@
>
>  #if LWIP_IGMP
>  static err_t xemacpsif_mac_filter_update (struct netif *netif,
> +#ifndef __rtems__
>                                                         ip_addr_t *group,
> u8_t action);
> +#else /* __rtems__ */
> +                                                       const ip4_addr_t
> *group,
> +                                                       enum
> netif_mac_filter_action action);
> +#endif
>
>  static u8_t xemacps_mcast_entry_mask = 0;
>  #endif
>
>  #if LWIP_IPV6 && LWIP_IPV6_MLD
>  static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
> +#ifndef __rtems__
>                                                         ip_addr_t *group,
> u8_t action);
> +#else /* __rtems__ */
> +                                                       const ip6_addr_t
> *group,
> +                                                       enum
> netif_mac_filter_action action);
> +#endif
>
>  static u8_t xemacps_mld6_mcast_entry_mask;
>  #endif
> @@ -236,10 +246,18 @@ static struct pbuf * low_level_input(struct netif
> *netif)
>   */
>
>  static err_t xemacpsif_output(struct netif *netif, struct pbuf *p,
> +#ifndef __rtems__
>                 const ip_addr_t *ipaddr)
> +#else /* __rtems__ */
> +               const ip4_addr_t *ipaddr)
> +#endif
>  {
>         /* resolve hardware address, then send (or queue) packet */
> +#ifndef __rtems__
>         return etharp_output(netif, p, ipaddr);
> +#else /* __rtems__ */
> +       return etharp_output(netif, p, (const ip4_addr_t*) ipaddr);
> +#endif
>

This change should not be necessary since the function signature above is
changing.


>  }
>
>  /*
> @@ -514,7 +532,11 @@ static u8_t
> xemacpsif_ip6_addr_ismulticast(ip6_addr_t* ip_addr)
>  }
>
>  static void xemacpsif_mld6_mac_hash_update (struct netif *netif, u8_t
> *ip_addr,
> +#ifndef __rtems__
>                 u8_t action)
> +#else /* __rtems__ */
> +               enum netif_mac_filter_action action)
> +#endif
>  {
>         u8_t multicast_mac_addr[6];
>         struct xemac_s *xemac = (struct xemac_s *) (netif->state);
> @@ -557,14 +579,24 @@ static void xemacpsif_mld6_mac_hash_update (struct
> netif *netif, u8_t *ip_addr,
>         SYS_ARCH_UNPROTECT(lev);
>  }
>
> +#ifndef __rtems__
>  static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
> ip_addr_t *group,
>                 u8_t action)
> +#else /* __rtems__ */
> +static err_t xemacpsif_mld6_mac_filter_update (struct netif *netif,
> +                                                       const ip6_addr_t
> *group,
> +                                                       enum
> netif_mac_filter_action action)
> +#endif
>  {
>         u8_t temp_mask;
>         unsigned int i;
>         u8_t * ip_addr = (u8_t *) group;
>
> +#ifndef __rtems__
>         if(!(xemacpsif_ip6_addr_ismulticast((ip6_addr_t*) ip_addr))) {
> +#else /* __rtems__ */
> +       if(!(xemacpsif_ip6_addr_ismulticast((ip6_addr_t*) group ))) {
> +#endif
>

It's better to change the function signature of
xemacpsif_ip6_addr_ismulticast to take a const instead of casting away
constness here since all its uses of the variable are macros that do not
modify it. Once xemacpsif_ip6_addr_ismulticast takes a const, the cast
becomes unnecessary.


>                 LWIP_DEBUGF(NETIF_DEBUG,
>                                  ("%s: The requested MAC address is not a
> multicast address.\r\n", __func__));
>                    LWIP_DEBUGF(NETIF_DEBUG,
>                                 ("Multicast address add operation failure
> !!\r\n"));
> @@ -620,8 +652,13 @@ static err_t xemacpsif_mld6_mac_filter_update (struct
> netif *netif, ip_addr_t *g
>  #endif
>
>  #if LWIP_IGMP
> +#ifndef __rtems__
>  static void xemacpsif_mac_hash_update (struct netif *netif, u8_t *ip_addr,
>                 u8_t action)
> +#else /* __rtems__ */
> +static void xemacpsif_mac_hash_update (struct netif *netif, u8_t
> *ip4_addr_t,
> +               enum netif_mac_filter_action action)
> +#endif
>  {
>         u8_t multicast_mac_addr[6];
>         struct xemac_s *xemac = (struct xemac_s *) (netif->state);
> --
> 2.34.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20240105/a2e1db7f/attachment-0001.htm>


More information about the devel mailing list