From 060e29f0ff765b83b8351c63232d03e022dfb032 Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Fri, 14 Feb 2025 22:04:27 +0000 Subject: [PATCH 01/10] Refactor messages string, subsystem, and category truncation --- src/config.c | 32 ++++++++++++----- src/config.h | 6 ++-- test/test_config.c | 90 ++++++++++++++++++++++++++++++++-------------- 3 files changed, 90 insertions(+), 38 deletions(-) diff --git a/src/config.c b/src/config.c index 0b422a4f..e9da4256 100644 --- a/src/config.c +++ b/src/config.c @@ -38,9 +38,9 @@ bool is_regular_file_or_pipe(int fd, FlogError *error); -const int subsystem_len = 257; -const int category_len = 257; -const int message_len = 8193; +const size_t subsystem_len = 128; +const size_t category_len = 128; +const size_t message_len = 1024; FlogConfigLevel flog_config_parse_level(const char *str); @@ -205,7 +205,7 @@ flog_config_set_subsystem(FlogConfig *config, const char *subsystem) { assert(subsystem != NULL); if (strlcpy(config->subsystem, subsystem, subsystem_len) >= subsystem_len) { - fprintf(stderr, "%s: subsystem name truncated to %d bytes\n", PROGRAM_NAME, subsystem_len - 1); + fprintf(stderr, "%s: subsystem name truncated to %lu bytes\n", PROGRAM_NAME, subsystem_len); } } @@ -222,7 +222,7 @@ flog_config_set_category(FlogConfig *config, const char *category) { assert(category != NULL); if (strlcpy(config->category, category, category_len) >= category_len) { - fprintf(stderr, "%s: category name truncated to %d bytes\n", PROGRAM_NAME, category_len - 1); + fprintf(stderr, "%s: category name truncated to %lu bytes\n", PROGRAM_NAME, category_len); } } @@ -293,7 +293,7 @@ flog_config_set_message(FlogConfig *config, const char *message) { assert(message != NULL); if (strlcpy(config->message, message, message_len) >= message_len) { - fprintf(stderr, "%s: message string was truncated to %d bytes\n", PROGRAM_NAME, message_len - 1); + fprintf(stderr, "%s: message string was truncated to %lu bytes\n", PROGRAM_NAME, message_len); } } @@ -320,7 +320,7 @@ flog_config_set_message_from_args(FlogConfig *config, const char **args) { } if (message_truncated) { - fprintf(stderr, "%s: message was truncated to %d bytes\n", PROGRAM_NAME, message_len - 1); + fprintf(stderr, "%s: message was truncated to %lu bytes\n", PROGRAM_NAME, message_len); } } @@ -329,9 +329,23 @@ flog_config_set_message_from_stream(FlogConfig *config, FILE *restrict stream) { assert(config != NULL); assert(stream != NULL); - if (fread(config->message, sizeof(char), message_len, stream) >= message_len) { - fprintf(stderr, "%s: message was truncated to %d bytes\n", PROGRAM_NAME, message_len - 1); + size_t bytes_read = 0; + size_t total_read = 0; + + while ((bytes_read = fread(config->message, sizeof(char), message_len - total_read, stream)) > 0) { + total_read += bytes_read; + } + + if (total_read >= message_len) { config->message[message_len - 1] = '\0'; + fprintf(stderr, "%s: message was truncated to %lu bytes\n", PROGRAM_NAME, message_len); + } else { + config->message[total_read] = '\0'; + } + + if (ferror(stream)) { + fprintf(stderr, "%s: error reading message from stream\n", PROGRAM_NAME); + return; } } diff --git a/src/config.h b/src/config.h index 0015c287..3422ca96 100644 --- a/src/config.h +++ b/src/config.h @@ -33,9 +33,9 @@ #include #include "common.h" -extern const int subsystem_len; -extern const int category_len; -extern const int message_len; +extern const size_t subsystem_len; +extern const size_t category_len; +extern const size_t message_len; /*! \brief An enumerated type representing the log level. */ typedef enum FlogConfigLevelData { diff --git a/test/test_config.c b/test/test_config.c index 0f1b0131..8e55a145 100644 --- a/test/test_config.c +++ b/test/test_config.c @@ -743,33 +743,42 @@ flog_config_new_with_message_from_pipe_stream_succeeds(void **state) { int pipe_fd[2]; const char *message = "0123456789ABCDEF"; - // Create a pipe and allocate a file descriptor pair for reading the message string + // Create a pipe and allocate a file descriptor pair for the message string if (pipe(pipe_fd) == -1) { perror("pipe"); fail(); }; - // Write a test message to the write end of the pipe and close its file descriptor - write(pipe_fd[1], message, strlen(message)); - close(pipe_fd[1]); - // Associate a stream with the read end of the pipe - FILE *pipe_file = fdopen(pipe_fd[0], "r"); - if (pipe_file == NULL) { - perror("fdopen"); + FILE *pipe_read_stream = fdopen(pipe_fd[0], "r"); + if (pipe_read_stream == NULL) { + perror("fdopen(pipe_fd[0])"); + close(pipe_fd[0]); + close(pipe_fd[1]); + fail(); + } + + // Associate a stream with the write end of the pipe + FILE *pipe_write_stream = fdopen(pipe_fd[1], "w"); + if (pipe_write_stream == NULL) { + perror("fdopen(pipe_fd[1])"); close(pipe_fd[0]); + close(pipe_fd[1]); fail(); } + // Write a test message to the pipe stream and close the stream and file descriptor + fprintf(pipe_write_stream, "%s", message); + fclose(pipe_write_stream); + // Save stdin and reassign temporarily to the pipe stream FILE *saved_stdin = stdin; - stdin = pipe_file; + stdin = pipe_read_stream; FlogConfig *config = flog_config_new(mock_argc, mock_argv, &error); // Ensure stdin stream is restored before making assertions in order to avoid impacting // other tests if an assertion fails and leaves stdin pointing to the pipe stream - fclose(pipe_file); stdin = saved_stdin; assert_non_null(config); @@ -777,6 +786,7 @@ flog_config_new_with_message_from_pipe_stream_succeeds(void **state) { assert_string_equal(flog_config_get_message(config), message); flog_config_free(config); + fclose(pipe_read_stream); } static void @@ -788,39 +798,39 @@ flog_config_new_with_message_from_regular_file_stream_succeeds(void **state) { TEST_PROGRAM_NAME ) - int fd; + int temp_fd; char template[] = "/tmp/flog.XXXXXXXX"; - // Create a temporary file for reading the message string - if ((fd = mkstemp(template)) == -1) { + // Create a temporary file for the message string + if ((temp_fd = mkstemp(template)) == -1) { perror("mkstemp"); fail(); } - // Write a test message to the temporary file - const char *message = "0123456789ABCDEF"; - write(fd, message, strlen(message)); - // Associate a stream with the temporary file - FILE *temp_file = fdopen(fd, "r"); - if (temp_file == NULL) { + FILE *temp_stream = fdopen(temp_fd, "r+"); + if (temp_stream == NULL) { perror("fdopen"); - close(fd); + close(temp_fd); + unlink(template); fail(); } + // Write a test message to the temporary file stream + const char *message = "0123456789ABCDEF"; + fprintf(temp_stream, "%s", message); + // Set the file position indicator for the stream to the beginning of the file - rewind(temp_file); + rewind(temp_stream); // Save stdin and reassign temporarily to the temporary file stream FILE *saved_stdin = stdin; - stdin = temp_file; + stdin = temp_stream; FlogConfig *config = flog_config_new(mock_argc, mock_argv, &error); // Ensure stdin stream is restored before making assertions in order to avoid impacting // other tests if an assertion fails and leaves stdin pointing to the temporary file stream - fclose(temp_file); stdin = saved_stdin; assert_non_null(config); @@ -829,6 +839,7 @@ flog_config_new_with_message_from_regular_file_stream_succeeds(void **state) { flog_config_free(config); unlink(template); + fclose(temp_stream); } static void @@ -1343,19 +1354,46 @@ flog_config_set_message_from_stream_with_long_message_truncates(void **state) { TEST_MESSAGE ) + int temp_fd; + char template[] = "/tmp/flog.XXXXXXXX"; + + // Create a temporary file for the message string + if ((temp_fd = mkstemp(template)) == -1) { + perror("mkstemp"); + fail(); + } + + // Associate a stream with the temporary file + FILE *temp_stream = fdopen(temp_fd, "r+"); + if (temp_stream == NULL) { + perror("fdopen"); + close(temp_fd); + unlink(template); + fail(); + } + + // Write a test message that exceeds message_len to the temporary file char *message = malloc(message_len + 1); memset(message, TEST_CHAR, message_len); message[message_len] = '\0'; + fprintf(temp_stream, "%s", message); - FILE *mock_stream = fmemopen(message, strlen(message), "r"); + // Set the file position indicator for the stream to the beginning of the file + rewind(temp_stream); + + // Initialise a FlogConfig object with message string from arguments FlogConfig *config = flog_config_new(mock_argc, mock_argv, &error); - flog_config_set_message_from_stream(config, mock_stream); + // Test message truncation when read from a stream + flog_config_set_message_from_stream(config, temp_stream); assert_int_equal(strlen(flog_config_get_message(config)), message_len - 1); + assert_string_not_equal(flog_config_get_message(config), message); + message[message_len - 1] = '\0'; + assert_string_equal(flog_config_get_message(config), message); - fclose(mock_stream); flog_config_free(config); free(message); + fclose(temp_stream); } static void From 8687a6976ac04ac0a9afecf01e991bf04359e843 Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Fri, 14 Feb 2025 22:26:31 +0000 Subject: [PATCH 02/10] Add unit test coverage for stream read failures --- test/test_config.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/test_config.c b/test/test_config.c index 8e55a145..4a0f78bf 100644 --- a/test/test_config.c +++ b/test/test_config.c @@ -1321,6 +1321,49 @@ flog_config_set_message_from_stream_with_null_stream_arg_fails(void **state) { flog_config_free(config); } +static void +flog_config_set_message_from_stream_with_broken_stream_fails(void **state) { + UNUSED(state); + + FlogError error = TEST_ERROR; + MOCK_ARGS( + TEST_PROGRAM_NAME, + TEST_MESSAGE + ) + + int temp_fd; + char template[] = "/tmp/flog.XXXXXXXX"; + + // Create a temporary file + if ((temp_fd = mkstemp(template)) == -1) { + perror("mkstemp"); + fail(); + } + + // Associate a stream with the temporary file + FILE *temp_stream = fdopen(temp_fd, "r+"); + if (temp_stream == NULL) { + perror("fdopen"); + close(temp_fd); + unlink(template); + fail(); + } + + // Simulate a broken stream + fclose(temp_stream); + + // Initialise a FlogConfig object with message string from arguments + FlogConfig *config = flog_config_new(mock_argc, mock_argv, &error); + + // Test message parsing when read from a broken stream + flog_config_set_message_from_stream(config, temp_stream); + + assert_non_null(config); + assert_string_equal(flog_config_get_message(config), ""); + + flog_config_free(config); +} + static void flog_config_set_and_get_message_from_stream_succeeds(void **state) { UNUSED(state); @@ -1615,6 +1658,9 @@ int main(void) { cmocka_unit_test(flog_config_set_message_from_stream_with_null_config_arg_fails), cmocka_unit_test(flog_config_set_message_from_stream_with_null_stream_arg_fails), + // flog_config_set_message_from_stream() failure tests + cmocka_unit_test(flog_config_set_message_from_stream_with_broken_stream_fails), + // flog_config_set_message_from_stream() success tests cmocka_unit_test(flog_config_set_and_get_message_from_stream_succeeds), From 4c5078fc56dda53ab72ac90adfd5f56165362831 Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Fri, 14 Feb 2025 23:08:37 +0000 Subject: [PATCH 03/10] Simplify stream reading logic --- src/config.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/config.c b/src/config.c index e9da4256..370fc80e 100644 --- a/src/config.c +++ b/src/config.c @@ -329,23 +329,17 @@ flog_config_set_message_from_stream(FlogConfig *config, FILE *restrict stream) { assert(config != NULL); assert(stream != NULL); - size_t bytes_read = 0; - size_t total_read = 0; + size_t bytes_read = fread(config->message, sizeof(char), message_len - 1, stream); + config->message[bytes_read] = '\0'; - while ((bytes_read = fread(config->message, sizeof(char), message_len - total_read, stream)) > 0) { - total_read += bytes_read; - } - - if (total_read >= message_len) { - config->message[message_len - 1] = '\0'; - fprintf(stderr, "%s: message was truncated to %lu bytes\n", PROGRAM_NAME, message_len); - } else { - config->message[total_read] = '\0'; + // Attempt to read another byte to determine if there's more data available + char c; + if (fread(&c, sizeof(char), 1, stream) > 0) { + fprintf(stderr, "%s: message was truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); } if (ferror(stream)) { fprintf(stderr, "%s: error reading message from stream\n", PROGRAM_NAME); - return; } } From e2934e66e9d71071f9c640c6a3264f271b4c61c9 Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Fri, 14 Feb 2025 23:42:08 +0000 Subject: [PATCH 04/10] Improve stream bounds checking and null termination --- src/config.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index 370fc80e..d827a6fd 100644 --- a/src/config.c +++ b/src/config.c @@ -329,7 +329,18 @@ flog_config_set_message_from_stream(FlogConfig *config, FILE *restrict stream) { assert(config != NULL); assert(stream != NULL); + config->message[0] = '\0'; + size_t bytes_read = fread(config->message, sizeof(char), message_len - 1, stream); + + if (ferror(stream)) { + fprintf(stderr, "%s: error reading message from stream\n", PROGRAM_NAME); + clearerr(stream); + return; + } + + // Ensure safe bounds and null termination + bytes_read = (bytes_read >= message_len - 1) ? message_len - 1 : bytes_read; config->message[bytes_read] = '\0'; // Attempt to read another byte to determine if there's more data available @@ -337,10 +348,6 @@ flog_config_set_message_from_stream(FlogConfig *config, FILE *restrict stream) { if (fread(&c, sizeof(char), 1, stream) > 0) { fprintf(stderr, "%s: message was truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); } - - if (ferror(stream)) { - fprintf(stderr, "%s: error reading message from stream\n", PROGRAM_NAME); - } } FlogConfigMessageType From ede4559e943884d706a87aa3446ab45ff824a7b2 Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Sat, 15 Feb 2025 00:01:28 +0000 Subject: [PATCH 05/10] Clear error state and use consistent error messsage --- src/config.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index d827a6fd..3cadbe4d 100644 --- a/src/config.c +++ b/src/config.c @@ -331,8 +331,8 @@ flog_config_set_message_from_stream(FlogConfig *config, FILE *restrict stream) { config->message[0] = '\0'; + // Read message from stream size_t bytes_read = fread(config->message, sizeof(char), message_len - 1, stream); - if (ferror(stream)) { fprintf(stderr, "%s: error reading message from stream\n", PROGRAM_NAME); clearerr(stream); @@ -343,11 +343,12 @@ flog_config_set_message_from_stream(FlogConfig *config, FILE *restrict stream) { bytes_read = (bytes_read >= message_len - 1) ? message_len - 1 : bytes_read; config->message[bytes_read] = '\0'; - // Attempt to read another byte to determine if there's more data available + // Check for message truncation char c; if (fread(&c, sizeof(char), 1, stream) > 0) { - fprintf(stderr, "%s: message was truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); + fprintf(stderr, "%s: message truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); } + clearerr(stream); } FlogConfigMessageType From 795a9f9ef8d96d74aba124524a3cd0c389f19efa Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Sat, 15 Feb 2025 00:01:49 +0000 Subject: [PATCH 06/10] Use consistent truncation messages --- src/config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index 3cadbe4d..4816e531 100644 --- a/src/config.c +++ b/src/config.c @@ -205,7 +205,7 @@ flog_config_set_subsystem(FlogConfig *config, const char *subsystem) { assert(subsystem != NULL); if (strlcpy(config->subsystem, subsystem, subsystem_len) >= subsystem_len) { - fprintf(stderr, "%s: subsystem name truncated to %lu bytes\n", PROGRAM_NAME, subsystem_len); + fprintf(stderr, "%s: subsystem name truncated to %lu bytes\n", PROGRAM_NAME, subsystem_len - 1); } } @@ -222,7 +222,7 @@ flog_config_set_category(FlogConfig *config, const char *category) { assert(category != NULL); if (strlcpy(config->category, category, category_len) >= category_len) { - fprintf(stderr, "%s: category name truncated to %lu bytes\n", PROGRAM_NAME, category_len); + fprintf(stderr, "%s: category name truncated to %lu bytes\n", PROGRAM_NAME, category_len - 1); } } @@ -293,7 +293,7 @@ flog_config_set_message(FlogConfig *config, const char *message) { assert(message != NULL); if (strlcpy(config->message, message, message_len) >= message_len) { - fprintf(stderr, "%s: message string was truncated to %lu bytes\n", PROGRAM_NAME, message_len); + fprintf(stderr, "%s: message truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); } } @@ -320,7 +320,7 @@ flog_config_set_message_from_args(FlogConfig *config, const char **args) { } if (message_truncated) { - fprintf(stderr, "%s: message was truncated to %lu bytes\n", PROGRAM_NAME, message_len); + fprintf(stderr, "%s: message truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); } } From 847cdb2693a061abd81f09e5b1489ff3c2972541 Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Sat, 15 Feb 2025 11:00:30 +0000 Subject: [PATCH 07/10] Fix format specifiers --- src/config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index 4816e531..677ad2fb 100644 --- a/src/config.c +++ b/src/config.c @@ -205,7 +205,7 @@ flog_config_set_subsystem(FlogConfig *config, const char *subsystem) { assert(subsystem != NULL); if (strlcpy(config->subsystem, subsystem, subsystem_len) >= subsystem_len) { - fprintf(stderr, "%s: subsystem name truncated to %lu bytes\n", PROGRAM_NAME, subsystem_len - 1); + fprintf(stderr, "%s: subsystem name truncated to %zu bytes\n", PROGRAM_NAME, subsystem_len - 1); } } @@ -222,7 +222,7 @@ flog_config_set_category(FlogConfig *config, const char *category) { assert(category != NULL); if (strlcpy(config->category, category, category_len) >= category_len) { - fprintf(stderr, "%s: category name truncated to %lu bytes\n", PROGRAM_NAME, category_len - 1); + fprintf(stderr, "%s: category name truncated to %zu bytes\n", PROGRAM_NAME, category_len - 1); } } @@ -293,7 +293,7 @@ flog_config_set_message(FlogConfig *config, const char *message) { assert(message != NULL); if (strlcpy(config->message, message, message_len) >= message_len) { - fprintf(stderr, "%s: message truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); + fprintf(stderr, "%s: message truncated to %zu bytes\n", PROGRAM_NAME, message_len - 1); } } @@ -320,7 +320,7 @@ flog_config_set_message_from_args(FlogConfig *config, const char **args) { } if (message_truncated) { - fprintf(stderr, "%s: message truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); + fprintf(stderr, "%s: message truncated to %zu bytes\n", PROGRAM_NAME, message_len - 1); } } From 7b4deba639f8f63172522d842a6040c7044d7f0e Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Sat, 15 Feb 2025 11:50:04 +0000 Subject: [PATCH 08/10] Refactor version information --- src/common.c | 13 ++++++++++--- src/common.h | 5 ++++- test/test_common.c | 13 ++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/common.c b/src/common.c index 233a1f93..808c87ca 100644 --- a/src/common.c +++ b/src/common.c @@ -53,7 +53,7 @@ flog_print_error(FlogError error) { void flog_usage(void) { printf( - "%s %s\n" + "%s v%d.%d.%d\n" "\n" "Usage:\n" " %s [options] message\n" @@ -73,12 +73,19 @@ flog_usage(void) { " default, info, debug, error, fault\n" "\n", PROGRAM_NAME, - PROGRAM_VERSION, + PROGRAM_VERSION_MAJOR, + PROGRAM_VERSION_MINOR, + PROGRAM_VERSION_PATCH, PROGRAM_NAME ); } void flog_version(void) { - printf("%s %s\n", PROGRAM_NAME, PROGRAM_VERSION); + printf("%s v%d.%d.%d\n", + PROGRAM_NAME, + PROGRAM_VERSION_MAJOR, + PROGRAM_VERSION_MINOR, + PROGRAM_VERSION_PATCH + ); } diff --git a/src/common.h b/src/common.h index 566fa3e8..79b6f56f 100644 --- a/src/common.h +++ b/src/common.h @@ -28,8 +28,11 @@ * Constants, helper functions, and error handling types for common operations. */ +/* Program information */ #define PROGRAM_NAME "flog" -#define PROGRAM_VERSION "v1.7.2" +#define PROGRAM_VERSION_MAJOR 1 +#define PROGRAM_VERSION_MINOR 7 +#define PROGRAM_VERSION_PATCH 2 /*! \brief An enumerated type representing error conditions. */ typedef enum FlogErrorData { diff --git a/test/test_common.c b/test/test_common.c index dd669f01..6b078bae 100644 --- a/test/test_common.c +++ b/test/test_common.c @@ -108,7 +108,7 @@ flog_usage_succeeds(void **state) { char expected_string[1024] = {0}; sprintf(expected_string, - "%s %s\n" + "%s v%d.%d.%d\n" "\n" "Usage:\n" " %s [options] message\n" @@ -128,7 +128,9 @@ flog_usage_succeeds(void **state) { " default, info, debug, error, fault\n" "\n", PROGRAM_NAME, - PROGRAM_VERSION, + PROGRAM_VERSION_MAJOR, + PROGRAM_VERSION_MINOR, + PROGRAM_VERSION_PATCH, PROGRAM_NAME ); @@ -142,7 +144,12 @@ flog_version_succeeds(void **state) { UNUSED(state); char expected_string[ERROR_STRING_LEN] = {0}; - sprintf(expected_string, "%s %s\n", PROGRAM_NAME, PROGRAM_VERSION); + sprintf(expected_string, "%s v%d.%d.%d\n", + PROGRAM_NAME, + PROGRAM_VERSION_MAJOR, + PROGRAM_VERSION_MINOR, + PROGRAM_VERSION_PATCH + ); flog_version(); From 0dde02eb0d624dbaf65777f434357d66fee59ae2 Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Sat, 15 Feb 2025 11:51:28 +0000 Subject: [PATCH 09/10] Organise errors by category --- src/common.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common.h b/src/common.h index 79b6f56f..c85e378b 100644 --- a/src/common.h +++ b/src/common.h @@ -36,15 +36,20 @@ /*! \brief An enumerated type representing error conditions. */ typedef enum FlogErrorData { + /* General errors */ FLOG_ERROR_NONE, FLOG_ERROR_ALLOC, + + /* I/O errors */ FLOG_ERROR_APPEND, + FLOG_ERROR_FILE, + FLOG_ERROR_STAT, + + /* Configuration errors */ FLOG_ERROR_LVL, FLOG_ERROR_MSG, FLOG_ERROR_OPTS, - FLOG_ERROR_SUBSYS, - FLOG_ERROR_FILE, - FLOG_ERROR_STAT, + FLOG_ERROR_SUBSYS } FlogError; /*! \brief Print usage information to stdout stream. */ From 9b0bde0538c60591a985d463132942844262c703 Mon Sep 17 00:00:00 2001 From: Marc Ransome Date: Sun, 16 Feb 2025 15:43:56 +0000 Subject: [PATCH 10/10] Fix format specifier --- src/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 677ad2fb..c985263d 100644 --- a/src/config.c +++ b/src/config.c @@ -346,7 +346,7 @@ flog_config_set_message_from_stream(FlogConfig *config, FILE *restrict stream) { // Check for message truncation char c; if (fread(&c, sizeof(char), 1, stream) > 0) { - fprintf(stderr, "%s: message truncated to %lu bytes\n", PROGRAM_NAME, message_len - 1); + fprintf(stderr, "%s: message truncated to %zu bytes\n", PROGRAM_NAME, message_len - 1); } clearerr(stream); }