Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
19963: sys/event/timeout: add event_timeout_is_pending() r=benpicco a=benpicco



19971: sys/shell/gnrc_netif: Fix a few blockers for sharing ifconfig shell r=benpicco a=yarrick



19974: gnrc_ipv6_ext_frag: _completed: Add comment why list head is not checked for NULL pointer dereference r=benpicco a=miri64

 


19975: pkg/nanocbor: Bump to latest commit r=benpicco a=bergzand

### Contribution description

Not much to see here

Important changes:
- Add stream-like interface for encoder
- Separate functions for number of items left in arrays and maps

### Testing procedure

The usual test should still work

### Issues/PRs references

None

19976: core: Express -1 as ~0 in thread_status_t cast r=benpicco a=SimonIT



Co-authored-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
Co-authored-by: Erik Ekman <eekman@google.com>
Co-authored-by: Martine Lenders <m.lenders@fu-berlin.de>
Co-authored-by: Koen Zandberg <koen@bergzand.net>
Co-authored-by: SimonIT <simonit.orig@gmail.com>
  • Loading branch information
6 people committed Oct 16, 2023
6 parents 554efb7 + 2dc4412 + ee6ca2b + 988db69 + a250dfe + d778e2e commit 910e0e2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/include/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ typedef enum {
*/
#define STATUS_ON_RUNQUEUE STATUS_RUNNING /**< to check if on run queue:
`st >= STATUS_ON_RUNQUEUE` */
#define STATUS_NOT_FOUND ((thread_status_t)-1) /**< Describes an illegal thread status */
#define STATUS_NOT_FOUND ((thread_status_t)~0) /**< Describes an illegal thread status */
/** @} */
/**
* @def SCHED_PRIO_LEVELS
Expand Down
2 changes: 1 addition & 1 deletion pkg/nanocbor/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PKG_NAME = nanocbor
PKG_URL = https://github.com/bergzand/nanocbor
PKG_VERSION = 1bc789705057c42be32aea17aeec97763aece3c7
PKG_VERSION = ae01e393f152b8294028986256f8451c93f75cfc
PKG_LICENSE = CC-0

include $(RIOTBASE)/pkg/pkg.mk
Expand Down
12 changes: 12 additions & 0 deletions sys/include/event/timeout.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout);
*/
void event_timeout_clear(event_timeout_t *event_timeout);

/**
* @brief Check if a timeout event is scheduled to be executed in the future
*
* @param[in] event_timeout event_timout context object to use
* @return true if the event is scheduled, false otherwise
*/
static inline bool event_timeout_is_pending(const event_timeout_t *event_timeout)
{
return ztimer_is_set(event_timeout->clock, &event_timeout->timer)
|| event_is_queued(event_timeout->queue, event_timeout->event);
}

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ static gnrc_pktsnip_t *_completed(gnrc_ipv6_ext_frag_rbuf_t *rbuf)
/* clist: first element is second element ;-) (from next of head) */
gnrc_ipv6_ext_frag_limits_t *ptr =
(gnrc_ipv6_ext_frag_limits_t *)rbuf->limits.next->next;
/* ptr should not be NULL at this point so it is safe to dereference with ptr->start here */
if (rbuf->last && (ptr->start == 0)) {
gnrc_pktsnip_t *res = NULL;

Expand Down
3 changes: 3 additions & 0 deletions sys/shell/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ USEMODULE += stdin
ifneq (,$(filter shell_cmds_default,$(USEMODULE)))
USEMODULE += shell_cmd_sys

ifneq (,$(filter netif,$(USEMODULE)))
USEMODULE += l2util
endif
ifneq (,$(filter app_metadata,$(USEMODULE)))
USEMODULE += shell_cmd_app_metadata
endif
Expand Down
21 changes: 12 additions & 9 deletions sys/shell/cmds/gnrc_netif.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "net/gnrc/netif.h"
#include "net/gnrc/netif/hdr.h"
#include "net/ipv6/addr.h"
#include "net/l2util.h"
#include "net/lora.h"
#include "net/loramac.h"
#include "net/netif.h"
Expand Down Expand Up @@ -579,7 +580,7 @@ static unsigned _netif_list_flag(netif_t *iface, netopt_t opt, char *str,
return line_thresh;
}

#ifdef MODULE_GNRC_IPV6
#ifdef MODULE_IPV6
static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags)
{
char addr_str[IPV6_ADDR_MAX_STR_LEN];
Expand All @@ -599,6 +600,7 @@ static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags)
else {
printf("unknown");
}
#if MODULE_GNRC_IPV6
if (flags & GNRC_NETIF_IPV6_ADDRS_FLAGS_ANYCAST) {
printf(" [anycast]");
}
Expand All @@ -619,6 +621,7 @@ static void _netif_list_ipv6(ipv6_addr_t *addr, uint8_t flags)
break;
}
}
#endif
_newline(0U, _LINE_THRESHOLD);
}

Expand All @@ -635,7 +638,7 @@ static void _netif_list_groups(ipv6_addr_t *addr)

static void _netif_list(netif_t *iface)
{
#ifdef MODULE_GNRC_IPV6
#ifdef MODULE_IPV6
ipv6_addr_t ipv6_addrs[CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF];
ipv6_addr_t ipv6_groups[GNRC_NETIF_IPV6_GROUPS_NUMOF];
#endif
Expand All @@ -657,7 +660,7 @@ static void _netif_list(netif_t *iface)
if (res >= 0) {
char hwaddr_str[res * 3];
printf(" HWaddr: %s ",
gnrc_netif_addr_to_str(hwaddr, res, hwaddr_str));
l2util_addr_to_str(hwaddr, res, hwaddr_str));
}
res = netif_get_opt(iface, NETOPT_CHANNEL, 0, &u16, sizeof(u16));
if (res >= 0) {
Expand Down Expand Up @@ -791,7 +794,7 @@ static void _netif_list(netif_t *iface)
if (res >= 0) {
char hwaddr_str[res * 3];
printf("Long HWaddr: ");
printf("%s ", gnrc_netif_addr_to_str(hwaddr, res, hwaddr_str));
printf("%s ", l2util_addr_to_str(hwaddr, res, hwaddr_str));
line_thresh++;
}
line_thresh = _newline(0U, line_thresh);
Expand Down Expand Up @@ -897,11 +900,11 @@ static void _netif_list(netif_t *iface)
line_thresh++;
}
line_thresh = _newline(0U, line_thresh);
#ifdef MODULE_GNRC_IPV6
printf("Link type: %s",
(netif_get_opt(iface, NETOPT_IS_WIRED, 0, &u16, sizeof(u16)) > 0) ?
"wired" : "wireless");
_newline(0U, ++line_thresh);
#ifdef MODULE_IPV6
res = netif_get_opt(iface, NETOPT_IPV6_ADDR, 0, ipv6_addrs,
sizeof(ipv6_addrs));
if (res >= 0) {
Expand Down Expand Up @@ -938,8 +941,8 @@ static void _netif_list(netif_t *iface)
for (unsigned i = 0; i < CONFIG_L2FILTER_LISTSIZE; i++) {
if (filter[i].addr_len > 0) {
char hwaddr_str[filter[i].addr_len * 3];
gnrc_netif_addr_to_str(filter[i].addr, filter[i].addr_len,
hwaddr_str);
l2util_addr_to_str(filter[i].addr, filter[i].addr_len,
hwaddr_str);
printf(" %2i: %s\n", count++, hwaddr_str);
}
}
Expand Down Expand Up @@ -1303,7 +1306,7 @@ static int _netif_set_lw_key(netif_t *iface, netopt_t opt, char *key_str)
static int _netif_set_addr(netif_t *iface, netopt_t opt, char *addr_str)
{
uint8_t addr[GNRC_NETIF_L2ADDR_MAXLEN];
size_t addr_len = gnrc_netif_addr_from_str(addr_str, addr);
size_t addr_len = l2util_addr_from_str(addr_str, addr);

if (addr_len == 0) {
printf("error: unable to parse address.\n"
Expand Down Expand Up @@ -1452,7 +1455,7 @@ static int _netif_set_encrypt_key(netif_t *iface, netopt_t opt, char *key_str)
static int _netif_addrm_l2filter(netif_t *iface, char *val, bool add)
{
uint8_t addr[GNRC_NETIF_L2ADDR_MAXLEN];
size_t addr_len = gnrc_netif_addr_from_str(val, addr);
size_t addr_len = l2util_addr_from_str(val, addr);

if ((addr_len == 0) || (addr_len > CONFIG_L2FILTER_ADDR_MAXLEN)) {
printf("error: given address is invalid\n");
Expand Down
2 changes: 2 additions & 0 deletions tests/sys/events/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ int main(void)
before = xtimer_now_usec();
#endif
event_timeout_set(&event_timeout, (1 * US_PER_SEC));
expect(event_timeout_is_pending(&event_timeout));

event_timeout_t event_timeout_canceled;

Expand All @@ -205,6 +206,7 @@ int main(void)
(event_t *)&noevent_callback);
event_timeout_set(&event_timeout_canceled, 500 * US_PER_MS);
event_timeout_clear(&event_timeout_canceled);
expect(!event_timeout_is_pending(&event_timeout_canceled));

puts("launching event queue");
event_loop(&queue);
Expand Down

0 comments on commit 910e0e2

Please sign in to comment.