[riot-notifications] [RIOT-OS/RIOT] gnrc_pktdump: fix dependencies (#14028)

Martine Lenders notifications at github.com
Tue May 5 21:04:53 CEST 2020

The RIOT community cares a lot about code quality.
Therefore, before describing what your contribution is about, we would like
you to make sure that your modifications are compliant with the RIOT
coding conventions, see https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions.

### Contribution description
This fixes several quality defects in `gnrc_pktdump`:

- the switch-cases for the NETTYPE are now guarded by the dedicate `gnrc_nettype_*` modules.
- only use `print` functions when the corresponding module is compiled in (not the `gnrc` module that pulls in that dependency), otherwise fall-back to `od_hex_dump()`
- optimize how and when the `od_hex_dump()` function is called.
- re-order switch-cases according to the `gnrc_nettype_t` enum.
Put here the description of your contribution:
- describe which part(s) of RIOT is (are) involved
- if it's a bug fix, describe the bug that it solves and how it is solved
- you can also give more information to reviewers about how to test your changes

### Testing procedure
Ideally, all applications using `gnrc_pktdump` should be tested.

- `examples/ccn-lite-relay`
- `examples/default`
- `examples/gnrc_lorawan`
- `examples/gnrc_networking`
- `examples/gnrc_networking_mac`
- `tests/driver_cc110x`
- `tests/driver_netdev_common`
- `tests/gnrc_dhcpv6_client_6lbr`
- `tests/gnrc_gomach`
- `tests/gnrc_ipv6_ext`
- `tests/gnrc_ipv6_ext_frag`
- `tests/gnrc_lwmac`
- `tests/gnrc_netif`
- `tests/gnrc_netif_ieee802154`
- `tests/gnrc_rpl_srh`
- `tests/gnrc_sixlowpan`
- `tests/gnrc_sock_async_event`
- `tests/slip`

However, there are many duplicates of NETTYPE registrations:

$ git grep gnrc_netreg_register -- $(git grep --name-only "\<gnrc_pktdump\>" -- examples/*/Makefile tests/*/Makefile | xargs dirname) 
examples/ccn-lite-relay/main.c:    gnrc_netreg_register(GNRC_NETTYPE_CCN_CHUNK, &dump);
examples/default/main.c:    gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
examples/gnrc_lorawan/main.c:    gnrc_netreg_register(GNRC_NETTYPE_LORAWAN, &dump);
examples/gnrc_networking/udp.c:    gnrc_netreg_register(GNRC_NETTYPE_UDP, &server);
examples/gnrc_networking_mac/udp.c:    gnrc_netreg_register(GNRC_NETTYPE_UDP, &server);
tests/driver_cc110x/main.c:            if (gnrc_netreg_register(GNRC_NETTYPE_SIXLOWPAN, &dump)) {
tests/driver_netdev_common/main.c:    gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
tests/gnrc_gomach/main.c:    gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
tests/gnrc_ipv6_ext/main.c:        gnrc_netreg_register(GNRC_NETTYPE_IPV6, &ip_entry);
tests/gnrc_ipv6_ext_frag/udp.c:    gnrc_netreg_register(GNRC_NETTYPE_UDP, &server);
tests/gnrc_lwmac/main.c:    gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
tests/gnrc_netif/common.c:    gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dumper_undef);
tests/gnrc_netif/common.c:    gnrc_netreg_register(GNRC_NETTYPE_IPV6, &dumper_ipv6);
tests/gnrc_netif_ieee802154/main.c:    gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
tests/gnrc_rpl_srh/main.c:        gnrc_netreg_register(GNRC_NETTYPE_IPV6, &ip_entry);
tests/gnrc_sixlowpan/main.c:    gnrc_netreg_register(GNRC_NETTYPE_SIXLOWPAN, &dump_6lowpan);
tests/gnrc_sixlowpan/main.c:    gnrc_netreg_register(GNRC_NETTYPE_IPV6, &dump_ipv6);
tests/gnrc_sixlowpan/main.c:    gnrc_netreg_register(GNRC_NETTYPE_UDP, &dump_udp);
tests/gnrc_sixlowpan/main.c:    gnrc_netreg_register(GNRC_NETTYPE_UDP, &dump_udp_61616);
tests/gnrc_sock_async_event/main.c:    gnrc_netreg_register(GNRC_NETTYPE_IPV6, &_pktdump);
tests/slip/main.c:    gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);

So a subset should be enough.
Details steps to test your contribution:
- which test/example to compile for which board and is there a 'test' command
- how to know that it was not working/available in master
- the expected success test output

### Issues/PRs references
Depends on PR #13994.
Examples: Fixes #1234. See also #5678. Depends on PR #9876.

Please use keywords (e.g., fixes, resolve) with the links to the issues you
resolved, this way they will be automatically closed when your pull request
is merged. See https://help.github.com/articles/closing-issues-using-keywords/.

You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * Merge branch 'gnrc_nettype/enh/use-pseudomodules' into gnrc/fix/circ-deps
  * gnrc_pktdump: use gnrc_nettype_% module where appropriate
  * gnrc_pktdump: remove some duplicate calls to od_hex_dump()
  * gnrc_pktdump: reorder switch-cases in accordance with enum order

-- File Changes --

    M Makefile.dep (9)
    M makefiles/pseudomodules.inc.mk (1)
    M pkg/ccn-lite/Makefile.dep (1)
    M pkg/ndn-riot/Makefile.dep (1)
    M sys/include/net/gnrc/nettype.h (76)
    M sys/net/gnrc/pktdump/gnrc_pktdump.c (87)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200505/0839c081/attachment.htm>

More information about the notifications mailing list