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

Clean up use of sprintf #209

Open
jboynes opened this issue Sep 8, 2023 · 0 comments
Open

Clean up use of sprintf #209

jboynes opened this issue Sep 8, 2023 · 0 comments

Comments

@jboynes
Copy link
Contributor

jboynes commented Sep 8, 2023

In #208 I added pragmas to suppress deprecation warnings related to sprintf that were added in newer versions of GCC and CLang, and which caused compilation failure. These suppressions should be removed.

One usage is in the test suite's implemention of itoa that is needed to run String tests. I have a quick fix for that relying on snprintf but I also thought of just using a more basic implementation of itoa such as the one from K&R or even just copying the implementation from the SAMD core.

Thinking a bit deeper though, the only use in API code is in String and it looks to be unnecessarily double buffering during those conversions. I think there's an opportunity to remove String's dependency on itoa and make it more efficient, which would also eliminate the need for an implementation of itoa in the test suite. I plan to look in to that approach.

A similar use is in the test suite's implementation of dtostrf which delegates the deprecated avr impl. For that, I think String can be improved to avoid the double buffering although it would still delegate to the core for the conversion, assuming the core may have implementation-specific FP support.

The final use was in IPAddress and that looks like it can simply be changed to used snprintf

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

No branches or pull requests

1 participant