Skip to content

sys/net/nanocoap: add missing dependency to sock_udp#22047

Queued
maribu wants to merge 1 commit intoRIOT-OS:masterfrom
maribu:sys/net/nanocoap/missing-dep
Queued

sys/net/nanocoap: add missing dependency to sock_udp#22047
maribu wants to merge 1 commit intoRIOT-OS:masterfrom
maribu:sys/net/nanocoap/missing-dep

Conversation

@maribu
Copy link
Member

@maribu maribu commented Feb 5, 2026

Contribution description

As the title says

Testing procedure

In master:

$ make BOARD=native64 tests-nanocoap flash test -j 32 -C tests/unittests
[...]
In file included from /home/marian.buschsieweke@ml-pa.loc/Repos/software/RIOT/master/sys/net/application_layer/nanocoap/nanocoap.c:31:
/home/marian.buschsieweke@ml-pa.loc/Repos/software/RIOT/master/sys/include/net/nanocoap_sock.h:211:16error: field ‘udp’ has incomplete type
  211 |     sock_udp_t udp;                         /**< UDP socket     */
      |                ^~~
/home/marian.buschsieweke@ml-pa.loc/Repos/software/RIOT/master/sys/include/net/nanocoap_sock.h:501:1:error: unknown type name ‘kernel_pid_t’
  501 | kernel_pid_t nanocoap_server_start(const sock_udp_ep_t *local);
      | ^~~~~~~~~~~~

This PR

$ make BOARD=native64 tests-nanocoap flash test -j 32 -C tests/unittests
make: Entering directory '/home/marian.buschsieweke@ml-pa.loc/Repos/software/RIOT/master/tests/unittests'
Building application "tests_unittests" for "native64" with CPU "native".
[...]
  text	  data	   bss	   dec	   hex	filename
149538	 36040	 78120	263698	 40612	/home/marian.buschsieweke@ml-pa.loc/Repos/software/RIOT/master/tests/unittests/bin/native64/tests_unittests.elf
[...]
main(): This is RIOT! (Version: 2026.01-devel-436-g816f586-sys/net/nanocoap/missing-dep)
.....................................
OK (37 tests)

Issues/PRs references

None

@maribu maribu requested a review from miri64 as a code owner February 5, 2026 11:20
@maribu maribu added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Feb 5, 2026
@github-actions github-actions bot added Area: network Area: Networking Area: CoAP Area: Constrained Application Protocol implementations Area: sys Area: System labels Feb 5, 2026
@maribu maribu force-pushed the sys/net/nanocoap/missing-dep branch from 816f586 to b7cf8a3 Compare February 5, 2026 11:39
@github-actions github-actions bot removed Area: network Area: Networking Area: CoAP Area: Constrained Application Protocol implementations labels Feb 5, 2026
Comment on lines +578 to +587
ifneq (,$(filter nanocoap,$(USEMODULE)))
USEMODULE += sock_udp
endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, but this looks wrong: why would nanocoap being the parser/generator part of the coap api require sock_udp?

In fact, the error message you provide shows an include of nanocoap_sock.h, which should probably not be in sys/net/nanocoap from my understanding.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in theory nanocoap should only be the parser. But in reality nanocoap is a hot mess. sys/net/application_layer/nanocoap/nanocoap.c includes nanocao_sock.h and therefore depends on sock_udp.h.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah fun, just digged where this is coming from, a commit co-authored by me :P

feeb684

Don't we have a way to fix this in nanocoap_sock, e.g. by doing the observe stuff before calling coap_handle_req? And thereby fixing the dependencies in nanocoap.c

Copy link
Member Author

@maribu maribu Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, coap_handle_req() is already out of scope of the CoAP message parsing and message building that pure nanocoap is supposed to be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. If you think moving these three lines out of coap_handle_req is too cumbersome, I would at least add comments both on those lines and in the Makefile.dep pointing out that this is not the proper dependency/place to have it.

Just imagining myself looking at this in some months from now and being completely confused about it again.

@crasbe crasbe requested a review from carl-tud February 5, 2026 11:53
@riot-ci
Copy link

riot-ci commented Feb 5, 2026

Murdock results

✔️ PASSED

1818821 sys/net/nanocoap: add missing dependency to sock_udp

Success Failures Total Runtime
11005 0 11005 08m:25s

Artifacts

Copy link
Contributor

@mguetschow mguetschow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's squash 🎾

@maribu maribu force-pushed the sys/net/nanocoap/missing-dep branch from b87729d to 1818821 Compare February 9, 2026 10:23
@maribu maribu enabled auto-merge February 9, 2026 10:23
@maribu maribu added this pull request to the merge queue Feb 9, 2026
@miri64 miri64 removed this pull request from the merge queue due to a manual request Feb 9, 2026
@miri64 miri64 added this pull request to the merge queue Feb 9, 2026
@miri64
Copy link
Member

miri64 commented Feb 9, 2026

Shunting in favor of the release note PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants