drivers/at86rf2xx: fix assert

The assert is reversed. It must check if the config value does not
exceed the maximum address length, not the other way round.

previously this would lead to a crash when setting a short address:

2020-08-23 13:59:56,080 #  ifconfig 7 set addr_short 2
2020-08-23 13:59:56,081 # 0xdcad
2020-08-23 13:59:56,083 # *** RIOT kernel panic:
2020-08-23 13:59:56,085 # FAILED ASSERTION.

With this it works as expected

2020-08-23 14:05:07,988 #  ifconfig 7 set addr_short 2
2020-08-23 14:05:07,992 # success: set (short) address on interface 7 to 2
This commit is contained in:
Benjamin Valentin 2020-08-23 14:05:52 +02:00
parent 6e504bf326
commit 0f4c5f5b10

View File

@ -498,12 +498,12 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *val, size_t len)
switch (opt) {
case NETOPT_ADDRESS:
assert(len >= sizeof(network_uint16_t));
assert(len <= sizeof(network_uint16_t));
at86rf2xx_set_addr_short(dev, val);
/* don't set res to set netdev_ieee802154_t::short_addr */
break;
case NETOPT_ADDRESS_LONG:
assert(len >= sizeof(eui64_t));
assert(len <= sizeof(eui64_t));
at86rf2xx_set_addr_long(dev, val);
/* don't set res to set netdev_ieee802154_t::long_addr */
break;