Skip to content
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

sys/net/coap: cast in non-config define #20497

Merged
merged 1 commit into from
Mar 22, 2024

Conversation

MrKevinWeiss
Copy link
Contributor

Contribution description

If we try to set the compile-time config we need to always remember casting, instead, just cast in the places that are not exposed to users.

Testing procedure

In master run:

CFLAGS="-DCONFIG_COAP_ACK_TIMEOUT_MS=2000 -DCONFIG_COAP_RANDOM_FACTOR_1000=1500"  BOARD=atmega256rfr2-xpro make -C tests/net/gcoap_dns/

it should fail with:

/home/weiss/repos/RIOT/sys/net/application_layer/gcoap/gcoap.c: In function ‘_on_resp_timeout’:
/home/weiss/repos/RIOT/sys/net/application_layer/gcoap/gcoap.c:53:55: error: integer overflow in expression [-Werror=overflow]
 #define TIMEOUT_RANGE_END (CONFIG_COAP_ACK_TIMEOUT_MS * CONFIG_COAP_RANDOM_FACTOR_1000 / 1000)
                                                       ^
/home/weiss/repos/RIOT/sys/net/application_layer/gcoap/gcoap.c:596:34: note: in expansion of macro ‘TIMEOUT_RANGE_END’
         uint32_t end = (uint32_t)TIMEOUT_RANGE_END << i;
                                  ^
/home/weiss/repos/RIOT/sys/net/application_layer/gcoap/gcoap.c: In function ‘gcoap_req_send_tl’:
/home/weiss/repos/RIOT/sys/net/application_layer/gcoap/gcoap.c:53:55: error: integer overflow in expression [-Werror=overflow]
 #define TIMEOUT_RANGE_END (CONFIG_COAP_ACK_TIMEOUT_MS * CONFIG_COAP_RANDOM_FACTOR_1000 / 1000)
                                                       ^
/home/weiss/repos/RIOT/sys/net/application_layer/gcoap/gcoap.c:1682:56: note: in expansion of macro ‘TIMEOUT_RANGE_END’
                 timeout = random_uint32_range(timeout, TIMEOUT_RANGE_END);
                                                        ^
cc1: all warnings being treated as errors
make[3]: *** [/home/weiss/repos/RIOT/Makefile.base:143: /home/weiss/repos/RIOT/tests/net/gcoap_dns/bin/atmega256rfr2-xpro/gcoap/gcoap.o] Error 1
make[2]: *** [/home/weiss/repos/RIOT/Makefile.base:31: ALL--/home/weiss/repos/RIOT/sys/net/application_layer/gcoap] Error 2
make[1]: *** [/home/weiss/repos/RIOT/Makefile.base:31: ALL--/home/weiss/repos/RIOT/sys] Error 2
make: *** [/home/weiss/repos/RIOT/tests/net/gcoap_dns/../../../Makefile.include:769: application_tests_gcoap_dns.module] Error 2
make: Leaving directory '/home/weiss/repos/RIOT/tests/net/gcoap_dns'

With PR should fix it

Issues/PRs references

@MrKevinWeiss MrKevinWeiss added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label Mar 21, 2024
@github-actions github-actions bot added Area: network Area: Networking Area: tests Area: tests and testing framework Area: CoAP Area: Constrained Application Protocol implementations Area: sys Area: System labels Mar 21, 2024
@benpicco benpicco added Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 21, 2024
@riot-ci
Copy link

riot-ci commented Mar 21, 2024

Murdock results

✔️ PASSED

575ab68 sys/net/coap: cast in non-config define

Success Failures Total Runtime
10009 0 10009 10m:56s

Artifacts

If we try to set the compile-time config we need to always remember casting, instead, just cast in the places that are not exposed to users
@MrKevinWeiss
Copy link
Contributor Author

Thanks!

@MrKevinWeiss MrKevinWeiss added this pull request to the merge queue Mar 21, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 21, 2024
@benpicco benpicco added this pull request to the merge queue Mar 22, 2024
Merged via the queue into RIOT-OS:master with commit e2a2c42 Mar 22, 2024
25 checks passed
@MrKevinWeiss MrKevinWeiss deleted the pr/fix/gcoapsize branch April 9, 2024 11:32
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: CoAP Area: Constrained Application Protocol implementations Area: network Area: Networking Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer 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.

3 participants