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: fix output of ipv6_addrs_print() #18183

Closed
wants to merge 1 commit into from

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Jun 9, 2022

Contribution description

Output of ipv6_addrs_print() is broken when the fmt module is used.
There is also a duplication, so the output without fmt will be

{"IPv6 addresses": ["fe80::7837:fcff:fe7d:1aaf", ""]}

Just get rid of the fmt fallback and simplify the code.

Testing procedure

Run e.g. examples/telnet_server:

master

main(): This is RIOT! (Version: 2022.07-devel-726-g8e1f9)
RIOT telnet example application
╔═══════════════════════════════════════════════════╗
║telnet is entirely unencrypted and unauthenticated.║
║Do not use this on public networks.                ║
╚═══════════════════════════════════════════════════╝
{"IPv6 addresses": [""]}
All up, awaiting connection on port 23

this patch

main(): This is RIOT! (Version: 2022.07-devel-726-g8e1f9)
RIOT telnet example application
╔═══════════════════════════════════════════════════╗
║telnet is entirely unencrypted and unauthenticated.║
║Do not use this on public networks.                ║
╚═══════════════════════════════════════════════════╝
{"IPv6 addresses": ["fe80::7837:fcff:fe7d:1aaf"]}
All up, awaiting connection on port 23

Issues/PRs references

@benpicco benpicco requested a review from maribu June 9, 2022 07:20
@github-actions github-actions bot added Area: network Area: Networking Area: sys Area: System labels Jun 9, 2022
@benpicco benpicco force-pushed the ipv6_addrs_print-fix branch from ae834b7 to dffd339 Compare June 9, 2022 07:21
@benpicco benpicco added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label Jun 9, 2022
@kaspar030
Copy link
Contributor

kaspar030 commented Jun 9, 2022

Just get rid of the fmt fallback and simplify the code.

Hm, there's an underlying issue that causes this, which should be fixed, no?

There was also a chain that made the ipv6_addr_print() a function (vs. shell commant), now fmt support is removed.
I did use this on our smallest micros, and intentionally used fmt to drop the libc stdio dependency. It was first half-added by fmt using "fwrite()" in all cases, now ipv6_addr_print() drops fmt support altogether.
I guess I can live with that for the sake of simplicity, but honestly I'm not happy how these optimizations got "cleaned up".

@benpicco
Copy link
Contributor Author

benpicco commented Jun 9, 2022

Feel free to open an alternative PR :)

@maribu
Copy link
Member

maribu commented Jun 9, 2022

I hoped #18162 would fix the issue with broken output from fmt. The unit test in tests/fmt_print was extended to actually catch the issue. What board are you using? Does it pass the test?

@benpicco
Copy link
Contributor Author

benpicco commented Jun 9, 2022

This is on native

@maribu
Copy link
Member

maribu commented Jun 9, 2022

fmt still works fine on real hardware as well in the CI. I guess this is the general native being broken issue.

I indeed fucked up the printing when reverting the drop of fmt. But how about fixing it like this instead:

diff --git a/sys/net/network_layer/ipv6/addr/ipv6_addr.c b/sys/net/network_layer/ipv6/addr/ipv6_addr.c
index a6a7962b08..6efafd0ac1 100644
--- a/sys/net/network_layer/ipv6/addr/ipv6_addr.c
+++ b/sys/net/network_layer/ipv6/addr/ipv6_addr.c
@@ -176,10 +176,9 @@ void ipv6_addrs_print(const ipv6_addr_t *addrs, size_t num,
     ipv6_addr_to_str(buf, &addrs[num], sizeof(buf));
     if (IS_USED(MODULE_FMT)) {
         print_str(buf);
-        print_str(separator);
     }
     else {
-        printf("%s%s", buf, separator);
+        printf("%s", buf);
     }
 }

@benpicco
Copy link
Contributor Author

benpicco commented Jun 9, 2022

closing in favor of #18186

@benpicco benpicco closed this Jun 9, 2022
@benpicco benpicco deleted the ipv6_addrs_print-fix branch June 9, 2022 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Area: sys Area: System 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