arduino / arduino/ArduinoCore-API

Clean up use of sprintf

Offen
#209 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
306
Forks
150
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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`

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Lokalisieren Sie die API-Implementierungen von String und IPAddress sowie die itoa- und dtostrf-Hilfsfunktionen der Testsuite. Lesen Sie zuerst die vorhandenen sprintf-Pragmas und Konvertierungspfade. Als abgeschlossen gilt die Aufgabe, wenn die Unterdrückungen entfernt und die identifizierten veralteten sprintf-Verwendungen behoben sind, ohne String-, IPAddress- oder String-Tests zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
cpp
Bereich
api, embedded-iot
Issue-Typ
Refactoring
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
28/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.