agroal / pgagroal

High-performance connection pool for PostgreSQL
https://agroal.github.io/pgagroal/
BSD 3-Clause "New" or "Revised" License
667 stars 59 forks source link

Fix sprintf of size_t #405

Closed df7cb closed 4 months ago

df7cb commented 4 months ago

This failed on 32-bit platforms.

/home/myon/projects/postgresql/pgagroal/pgagroal/src/libpgagroal/prometheus.c: In function ‘send_chunk’:
/home/myon/projects/postgresql/pgagroal/pgagroal/src/libpgagroal/prometheus.c:2104:18: error: format ‘%lX’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘size_t’ {aka ‘unsigned int’} [-Werror=format=]
 2104 |    sprintf(m, "%lX\r\n", strlen(data));
      |                ~~^       ~~~~~~~~~~~~
      |                  |       |
      |                  |       size_t {aka unsigned int}
      |                  long unsigned int
      |                %X
jesperpedersen commented 4 months ago

Merged.

Thanks for your contribution !

jesperpedersen commented 4 months ago

BTW, do you need a release for this ? Or, can we look at feedback for a bit ?

df7cb commented 4 months ago

I patched it locally for Debian first to see if it actually works, so no release needed. Thanks!

jesperpedersen commented 4 months ago

Great :+1: Thanks !