Use proper format constants for size_t/uintX_t etc
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 22s

This commit is contained in:
Stephen Seo 2024-11-25 16:01:49 +09:00
parent 0ecb8d6801
commit d6edaa3bdd
3 changed files with 13 additions and 7 deletions

View file

@ -129,7 +129,7 @@ Args parse_args(int32_t argc, char **argv) {
exit(1); exit(1);
} else { } else {
printf( printf(
"NOTICE set cache-entry-lifetime to %lu\n", "NOTICE set cache-entry-lifetime to %zu\n",
args.cache_lifespan_seconds); args.cache_lifespan_seconds);
} }
} else if (strncmp(argv[0], "--enable-static-dir=", 20) == 0) { } else if (strncmp(argv[0], "--enable-static-dir=", 20) == 0) {

View file

@ -19,6 +19,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#include <inttypes.h>
// Linux/Unix includes. // Linux/Unix includes.
#include <sys/socket.h> #include <sys/socket.h>
@ -232,7 +233,7 @@ int c_simple_http_manage_connections(void *data, void *ud) {
snprintf( snprintf(
content_length_buf + content_length_buf_size, content_length_buf + content_length_buf_size,
127 - content_length_buf_size, 127 - content_length_buf_size,
"%lu\n%n", "%zu\n%n",
response_size, response_size,
&written); &written);
if (written <= 0) { if (written <= 0) {
@ -304,7 +305,7 @@ int c_simple_http_manage_connections(void *data, void *ud) {
snprintf( snprintf(
content_length_buf, content_length_buf,
content_str_len + 1 + 16 + 1, content_str_len + 1 + 16 + 1,
"Content-Length: %lu\n", "Content-Length: %" PRIu64 "\n",
file_info.buf_size); file_info.buf_size);
CHECK_ERROR_WRITE_NO_FD(write( CHECK_ERROR_WRITE_NO_FD(write(
citem->fd, content_length_buf, content_str_len + 1 + 16)); citem->fd, content_length_buf, content_str_len + 1 + 16));
@ -385,7 +386,8 @@ int main(int argc, char **argv) {
socklen_t size = sizeof(ipv6_addr); socklen_t size = sizeof(ipv6_addr);
int ret = getsockname(tcp_socket, (struct sockaddr*)&ipv6_addr, &size); int ret = getsockname(tcp_socket, (struct sockaddr*)&ipv6_addr, &size);
if (ret == 0) { if (ret == 0) {
printf("Listening on port: %u\n", u16_be_swap(ipv6_addr.sin6_port)); printf("Listening on port: %" PRIu16 "\n",
u16_be_swap(ipv6_addr.sin6_port));
} else { } else {
fprintf( fprintf(
stderr, stderr,
@ -462,7 +464,7 @@ int main(int argc, char **argv) {
++config_try_reload_attempts; ++config_try_reload_attempts;
fprintf( fprintf(
stderr, stderr,
"Attempting to reload config now (try %u of %u)...\n", "Attempting to reload config now (try %" PRIu32 " of %u)...\n",
config_try_reload_attempts, config_try_reload_attempts,
C_SIMPLE_HTTP_TRY_CONFIG_RELOAD_MAX_ATTEMPTS); C_SIMPLE_HTTP_TRY_CONFIG_RELOAD_MAX_ATTEMPTS);
C_SIMPLE_HTTP_ParsedConfig new_parsed_config = C_SIMPLE_HTTP_ParsedConfig new_parsed_config =
@ -532,7 +534,7 @@ int main(int argc, char **argv) {
} }
} else if (read_ret > 0) { } else if (read_ret > 0) {
#ifndef NDEBUG #ifndef NDEBUG
printf("DEBUG inotify_event->mask: %x\n", inotify_event->mask); printf("DEBUG inotify_event->mask: %" PRIx32 "\n", inotify_event->mask);
#endif #endif
if ((inotify_event->mask & IN_MODIFY) != 0 if ((inotify_event->mask & IN_MODIFY) != 0
|| (inotify_event->mask & IN_CLOSE_WRITE) != 0) { || (inotify_event->mask & IN_CLOSE_WRITE) != 0) {

View file

@ -3,6 +3,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <inttypes.h>
// POSIX includes. // POSIX includes.
#include <unistd.h> #include <unistd.h>
@ -28,7 +29,10 @@ static int32_t checks_passed = 0;
#define RETURN() \ #define RETURN() \
do { \ do { \
fprintf(stderr, "checked %d\npassed %d\n", checks_checked, checks_passed);\ fprintf(stderr, \
"checked %" PRId32 "\npassed %" PRId32 "\n", \
checks_checked, \
checks_passed); \
return checks_checked == checks_passed ? 0 : 1; \ return checks_checked == checks_passed ? 0 : 1; \
} while (0); } while (0);