arduino / arduino/ArduinoCore-API

Clean up use of sprintf

未关闭
#209 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
306
派生
150
PR 合并指标
30 天内没有已合并 PR

描述

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`

贡献指南

这个仓库没有索引到贡献指南

调研方向

定位 String 和 IPAddress API 的实现,以及测试套件中的 itoa 和 dtostrf 辅助函数。先阅读现有的 sprintf pragma 和转换路径。完成的标准是移除抑制项,并处理已识别的弃用 sprintf 用法,同时不破坏 String、IPAddress 或 String 测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
cpp
领域
api, embedded-iot
Issue 类型
重构
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
28/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。