linix-generic => linux-generic in subject
Perhaps this can be corrected when merging?


On 10 December 2015 at 15:24, Maxim Uvarov <maxim.uva...@linaro.org> wrote:

> For some pktios like loop and ipc functions like mtu, promisc,
> and mac addr are not applicable. Instead of crash on deference
> null pointer just return error if functions are not defined.
> Signed-off-by: Maxim Uvarov <maxim.uva...@linaro.org>
> ---
>  platform/linux-generic/odp_packet_io.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/platform/linux-generic/odp_packet_io.c
> b/platform/linux-generic/odp_packet_io.c
> index 1e9d08c..c8b6502 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -725,7 +725,7 @@ int pktin_poll(pktio_entry_t *entry)
>  int odp_pktio_mtu(odp_pktio_t id)
>  {
>         pktio_entry_t *entry;
> -       int ret;
> +       int ret = -1;
>
>         entry = get_pktio_entry(id);
>         if (entry == NULL) {
> @@ -740,7 +740,9 @@ int odp_pktio_mtu(odp_pktio_t id)
>                 ODP_DBG("already freed pktio\n");
>                 return -1;
>         }
> -       ret = entry->s.ops->mtu_get(entry);
> +
> +       if (entry->s.ops->mtu_get)
> +               ret = entry->s.ops->mtu_get(entry);
>
>         unlock_entry(entry);
>         return ret;
> @@ -749,7 +751,7 @@ int odp_pktio_mtu(odp_pktio_t id)
>  int odp_pktio_promisc_mode_set(odp_pktio_t id, odp_bool_t enable)
>  {
>         pktio_entry_t *entry;
> -       int ret;
> +       int ret = -1;
>
>         entry = get_pktio_entry(id);
>         if (entry == NULL) {
> @@ -769,7 +771,8 @@ int odp_pktio_promisc_mode_set(odp_pktio_t id,
> odp_bool_t enable)
>                 return -1;
>         }
>
> -       ret = entry->s.ops->promisc_mode_set(entry, enable);
> +       if (entry->s.ops->promisc_mode_set)
> +               ret = entry->s.ops->promisc_mode_set(entry, enable);
>
>         unlock_entry(entry);
>         return ret;
> @@ -778,7 +781,7 @@ int odp_pktio_promisc_mode_set(odp_pktio_t id,
> odp_bool_t enable)
>  int odp_pktio_promisc_mode(odp_pktio_t id)
>  {
>         pktio_entry_t *entry;
> -       int ret;
> +       int ret = -1;
>
>         entry = get_pktio_entry(id);
>         if (entry == NULL) {
> @@ -794,13 +797,13 @@ int odp_pktio_promisc_mode(odp_pktio_t id)
>                 return -1;
>         }
>
> -       ret = entry->s.ops->promisc_mode_get(entry);
> +       if (entry->s.ops->promisc_mode_get)
> +               ret = entry->s.ops->promisc_mode_get(entry);
>         unlock_entry(entry);
>
>         return ret;
>  }
>
> -
>  int odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, int addr_size)
>  {
>         pktio_entry_t *entry;
> @@ -825,7 +828,12 @@ int odp_pktio_mac_addr(odp_pktio_t id, void
> *mac_addr, int addr_size)
>                 return -1;
>         }
>
> -       ret = entry->s.ops->mac_get(entry, mac_addr);
> +       if (entry->s.ops->mac_get) {
> +               ret = entry->s.ops->mac_get(entry, mac_addr);
> +       } else {
> +               ODP_DBG("pktio does not support mac addr get\n");
> +               ret = -1;
> +       }
>         unlock_entry(entry);
>
>         return ret;
> --
> 1.9.1
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to