stbsp_sprintf: `count` argument should use `size_t` instead of `int`

Aperta
#41 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
c
Ambito
tooling

Direzione di ricerca

Start with the declarations of stbsp_snprintf and stbsp_vsnprintf in stb_sprintf.h, then follow the count parameter into the internal formatting code to find where it is compared or decremented as a signed int. Change the parameter type to size_t and fix any sign-comparison warnings it causes. Done means the prototypes match the C standard library and the header still compiles cleanly. The issue leaves open whether the return type should change too, so check with a maintainer before touching that.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Looks like stbsp_snprintf and stbsp_vsnprintf uses int (signed) for buf size, while according to the standard C APIs it should use size_t (unsigned) . This may impose limitations for writing very large strings, the function will probably break when writing with buffers of 2GB of bytes on x86_64. Though I am not sure if system's snprintf doesn't also break in that range, because snprintf still returns an int. Nevertheless it would be good to change just for the conciseness of having the same declaration as the C APIs.

Lingua principale
C
Stelle
18
Fork
5
Merge medio
1m
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nothings/stb_sprintf

Tutte le issue di nothings/stb_sprintf

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.