Skip to content

dtls_debug: mock dsrv_log() when NDEBUG is set #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

benpicco
Copy link
Contributor

Setting NDEBUG already replaces dtls_dsrv_hexdump_log(), dtls_dsrv_log_addr() etc with dummy implementations.

This extends this to also replace dsrv_log() and dtls_{get,set}_log_level() with a no-op implementation.

Setting NDEBUG already replaces dtls_dsrv_hexdump_log(), dtls_dsrv_log_addr()
etc with dummy implementations.

This extends this to also replace dsrv_log() and dtls_{get,set}_log_level()
with a no-op implementation.
@boaks
Copy link
Contributor

boaks commented Mar 11, 2023

:-) how many bytes will be saved?

LGTM.

@benpicco
Copy link
Contributor Author

benpicco commented Mar 11, 2023

Actually none on the RIOT integration because it already doesn't use those functions.
The main motivation is to not having to compile them as the dsrv_log() implementations collides with our printf() wrapper that automatically places the format string in PROGMEM on AVR.
This requires the format string to be a literal which this implementation does not satisfy.

With this (and NDEBUG) build work on AVR (see RIOT-OS/RIOT#19346)

@boaks
Copy link
Contributor

boaks commented Mar 12, 2023

The main motivation is to not having to compile them as the dsrv_log() implementations collides with our printf() wrapper that automatically places the format string in PROGMEM on AVR.

Hm, then you will not be able to compile there without NDEBUG.
Would it be not better, to use a dummy implementation of "dsrv_log" for RIOT or RIOT in combination with some settings?

@benpicco
Copy link
Contributor Author

benpicco commented Mar 13, 2023

Hm, then you will not be able to compile there without NDEBUG.

Yea but that's something I can live with, it only affects AVR anyway.

Would it be not better, to use a dummy implementation of "dsrv_log" for RIOT

I can do that, but I thought it would be cleaner this way so NDEBUG behaves consistently. That it also fixes the build issue with our AVR magic is just a nice bonus.

@obgm
Copy link
Contributor

obgm commented Jul 22, 2023

LGTM

@boaks boaks merged commit ba830a3 into eclipse-tinydtls:main Jul 24, 2023
@benpicco benpicco deleted the dsrv_log-NDEBUG branch July 24, 2023 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants