fix: clang-tidy fixes
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
|
||||
#define C_TEMPLATE_VERSION_MAJOR 0
|
||||
#define C_TEMPLATE_VERSION_MINOR 0
|
||||
#define C_TEMPLATE_VERSION_PATCH 32
|
||||
#define C_TEMPLATE_COMMIT_HASH "b6301a6aea6730b4138dcc3716aa904dae88128e"
|
||||
#define C_TEMPLATE_BUILD_TIMESTAMP 1754424524
|
||||
#define C_TEMPLATE_VERSION_PATCH 33
|
||||
#define C_TEMPLATE_COMMIT_HASH "efd29765c3c53957f20692106e8283cda5e53b3e"
|
||||
#define C_TEMPLATE_BUILD_TIMESTAMP 1754425203
|
||||
|
||||
#endif // INCLUDE_C_TEMPLATE_VERSION_H_
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "command_lines_args.h"
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "logger.h"
|
||||
#include <cargs.h>
|
||||
#include <linux/limits.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "common.h"
|
||||
#include "logger.h"
|
||||
|
||||
static const struct cag_option options[] = {
|
||||
{.identifier = 'l',
|
||||
@@ -25,7 +26,7 @@ static const struct cag_option options[] = {
|
||||
|
||||
bool parse_command_line(const char *argv[], int argc) {
|
||||
c_template_config_t *config = get_config();
|
||||
const char* value = NULL;
|
||||
const char *value = NULL;
|
||||
int log_level = 0;
|
||||
|
||||
cag_option_context context;
|
||||
@@ -34,30 +35,30 @@ bool parse_command_line(const char *argv[], int argc) {
|
||||
switch (cag_option_get_identifier(&context)) {
|
||||
case 'l':
|
||||
value = cag_option_get_value(&context);
|
||||
if(value == NULL) {
|
||||
fprintf(stderr, "Failed to extract log level from command line");
|
||||
exit(EXIT_FAILURE);
|
||||
if (value == NULL) {
|
||||
fprintf(stderr, "Failed to extract log level from command line");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
log_level = log_level_str_to_int(value);
|
||||
if(log_level < 0) {
|
||||
fprintf(stderr, "Invalid log level %s", value);
|
||||
exit(EXIT_FAILURE);
|
||||
if (log_level < 0) {
|
||||
fprintf(stderr, "Invalid log level %s", value);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
config->console_logger.enabled = true;
|
||||
config->console_logger.log_level = log_level;
|
||||
break;
|
||||
case 'L':
|
||||
value = cag_option_get_value(&context);
|
||||
if(value == NULL) {
|
||||
fprintf(stderr, "Failed to extract log level from command line");
|
||||
exit(EXIT_FAILURE);
|
||||
if (value == NULL) {
|
||||
fprintf(stderr, "Failed to extract log level from command line");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
log_level = log_level_str_to_int(value);
|
||||
if(log_level < 0) {
|
||||
fprintf(stderr, "Invalid log level %s", value);
|
||||
exit(EXIT_FAILURE);
|
||||
if (log_level < 0) {
|
||||
fprintf(stderr, "Invalid log level %s", value);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
config->file_logger.enabled = true;
|
||||
config->file_logger.log_level = log_level;
|
||||
@@ -84,4 +85,3 @@ bool parse_command_line(const char *argv[], int argc) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
|
||||
bool parse_command_line(const char *argv[], int argc);
|
||||
|
||||
#endif // INCLUDE_SRC_COMMAND_LINES_ARGS_H_
|
||||
#endif // INCLUDE_SRC_COMMAND_LINES_ARGS_H_
|
||||
|
||||
@@ -18,4 +18,4 @@
|
||||
void timestamp_to_iso8601(time_t timestamp, char *output, size_t size);
|
||||
void print_version();
|
||||
|
||||
#endif // INCLUDE_SRC_COMMON_H_
|
||||
#endif // INCLUDE_SRC_COMMON_H_
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
#include "config.h"
|
||||
#include "zlog.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <linux/limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define MAX_RULE_SIZE 1024 * 16
|
||||
#define MAX_RULE_SIZE (1024 * 16)
|
||||
|
||||
/**
|
||||
* @brief Creates a directory and all necessary parent directories, similar to `mkdir -p`.
|
||||
|
||||
17
src/logger.h
17
src/logger.h
@@ -26,10 +26,10 @@
|
||||
zlog_error(zlog_get_category("default"), fmt ": %s (%d)", ##__VA_ARGS__, _errno_str, _errno_tmp); \
|
||||
} while (0)
|
||||
|
||||
#define LOGGER_BUILD_CONFIG_FAILED -1
|
||||
#define LOGGER_INIT_FAILED -2
|
||||
#define LOGGER_INIT_DEFAULT_CATEGORY_FAILED -3
|
||||
#define LOGGER_RELOAD_CONFIG_FAILED -4
|
||||
#define LOGGER_BUILD_CONFIG_FAILED (-1)
|
||||
#define LOGGER_INIT_FAILED (-2)
|
||||
#define LOGGER_INIT_DEFAULT_CATEGORY_FAILED (-3)
|
||||
#define LOGGER_RELOAD_CONFIG_FAILED (-4)
|
||||
|
||||
/**
|
||||
* @brief Returns a human-readable string describing the given logger error code.
|
||||
@@ -62,15 +62,14 @@ int logger_reload();
|
||||
*/
|
||||
void logger_cleanup();
|
||||
|
||||
|
||||
/**
|
||||
* @brief Converts a string representation of log-level into the correspondent numeric value
|
||||
*/
|
||||
*/
|
||||
int log_level_str_to_int(const char *level);
|
||||
|
||||
/**
|
||||
* @brief Converts a numeric representation of log-level into the correspondent string
|
||||
*/
|
||||
* @brief Converts a numeric representation of log-level into the correspondent string
|
||||
*/
|
||||
char *log_level_int_to_str(int level);
|
||||
|
||||
#endif // INCLUDE_SRC_LOGGER_H_
|
||||
#endif // INCLUDE_SRC_LOGGER_H_
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <stdlib.h>
|
||||
#include "command_lines_args.h"
|
||||
#include "logger.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
parse_command_line(argv, argc);
|
||||
|
||||
Reference in New Issue
Block a user