aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2017-11-26 19:19:33 +0100
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2017-11-26 19:19:33 +0100
commit348222d78a40502d7867ab98f581b2ddea4162a1 (patch)
tree0e218b88d502883716556474c6e3472e18b452d7
parenta7786e31ef1494f67e9782f067468fbc8b661366 (diff)
downloadembedlog-348222d78a40502d7867ab98f581b2ddea4162a1.tar.gz
embedlog-348222d78a40502d7867ab98f581b2ddea4162a1.tar.bz2
embedlog-348222d78a40502d7867ab98f581b2ddea4162a1.zip
Fix clang warnings
-rw-r--r--include/embedlog.h4
-rw-r--r--src/el-file.c4
-rw-r--r--src/el-options.c18
-rw-r--r--src/el-pmemory.c22
-rw-r--r--tst/el-file.c4
-rw-r--r--tst/el-options.c6
-rw-r--r--tst/el-perror.c1
-rw-r--r--tst/el-pmemory.c1
-rw-r--r--tst/el-print.c10
9 files changed, 38 insertions, 32 deletions
diff --git a/include/embedlog.h b/include/embedlog.h
index b2bdcb7..30ab236 100644
--- a/include/embedlog.h
+++ b/include/embedlog.h
@@ -123,7 +123,7 @@ struct el_options
int el_init(void);
int el_cleanup(void);
-int el_option(enum el_option option, ...);
+int el_option(int option, ...);
int el_puts(const char *string);
int el_print(const char *file, size_t line, enum el_level level,
const char *fmt, ...);
@@ -137,7 +137,7 @@ int el_perror(const char *file, size_t line, enum el_level level,
int el_oinit(struct el_options *options);
int el_ocleanup(struct el_options *options);
-int el_ooption(struct el_options *options, enum el_option option, ...);
+int el_ooption(struct el_options *options, int option, ...);
int el_oputs(struct el_options *options, const char *string);
int el_oprint(const char *file, size_t line, enum el_level level,
struct el_options *options, const char *fnt, ...);
diff --git a/src/el-file.c b/src/el-file.c
index f56d66a..d6fc041 100644
--- a/src/el-file.c
+++ b/src/el-file.c
@@ -99,7 +99,7 @@ static char current_log[PATH_MAX + 1]; /* full path to current log file */
static int el_file_exists
(
- struct el_options *options
+ void
)
{
#if HAVE_ACCESS
@@ -430,7 +430,7 @@ int el_file_puts
}
}
- if (el_file_exists(options) == 0)
+ if (el_file_exists() == 0)
{
/*
* file doesn't exist, it may happen when someone unlinks currently
diff --git a/src/el-options.c b/src/el-options.c
index 1b1dbbd..9cfa3e5 100644
--- a/src/el-options.c
+++ b/src/el-options.c
@@ -383,7 +383,7 @@ int el_log_allowed
enum el_level level /* log level to check */
)
{
- return options->level >= level;
+ return options->level >= (int)level;
}
@@ -394,15 +394,15 @@ int el_log_allowed
int el_option
(
- enum el_option option, /* option to set */
- ... /* option value */
+ int option, /* option to set */
+ ... /* option value */
)
{
- va_list ap; /* variadic arguments */
- int rc; /* return code from el_voooption */
+ va_list ap; /* variadic arguments */
+ int rc; /* return code from el_voooption */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
- va_start(ap, option);
+ va_start(ap, (int)option);
rc = el_vooption(&g_options, option, ap);
va_end(ap);
@@ -418,12 +418,12 @@ int el_option
int el_ooption
(
struct el_options *options, /* options object to set option to */
- enum el_option option, /* option to set */
+ int option, /* option to set */
... /* option value(s) */
)
{
- va_list ap; /* variadic arguments */
- int rc; /* return code from el_voooption */
+ va_list ap; /* variadic arguments */
+ int rc; /* return code from el_voooption */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
diff --git a/src/el-pmemory.c b/src/el-pmemory.c
index 58bbf38..b6b105b 100644
--- a/src/el-pmemory.c
+++ b/src/el-pmemory.c
@@ -71,7 +71,7 @@
========================================================================== */
-static void el_print_line
+static int el_print_line
(
const char *file, /* file name where log is printed */
size_t num, /* line number where log is printed */
@@ -127,7 +127,7 @@ static void el_print_line
* print constructed line
*/
- el_oprint(file, num, level, options, "0x%04x %-*s %s",
+ return el_oprint(file, num, level, options, "0x%04x %-*s %s",
offset, EL_MEM_HEX_LEN, hex_data, char_data);
}
@@ -212,7 +212,8 @@ int el_opmemory
const size_t lines_count = msg_size / EL_MEM_LINE_SIZE;
const size_t last_line_size = msg_size % EL_MEM_LINE_SIZE;
- size_t line_number; /* current line number being printed */
+ size_t line_number; /* current line number being printed */
+ int rv; /* return value of print functions */
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
@@ -233,16 +234,17 @@ int el_opmemory
* ------ ----------------------------------------------- ----------------
*/
- el_oprint(file, num, level, options, "%.*s %.*s %.*s",
+ rv = 0;
+ rv |= el_oprint(file, num, level, options, "%.*s %.*s %.*s",
EL_MEM_OFFSET_LEN - 2, separator,
EL_MEM_HEX_LEN - 1, separator,
EL_MEM_CHAR_LEN, separator);
- el_oprint(file, num, level, options, "%-*s%-*s%s",
+ rv |= el_oprint(file, num, level, options, "%-*s%-*s%s",
EL_MEM_OFFSET_LEN, "offset",
EL_MEM_HEX_LEN + 1, "hex", "ascii");
- el_oprint(file, num, level, options, "%.*s %.*s %.*s",
+ rv |= el_oprint(file, num, level, options, "%.*s %.*s %.*s",
EL_MEM_OFFSET_LEN - 2, separator,
EL_MEM_HEX_LEN - 1, separator,
EL_MEM_CHAR_LEN, separator);
@@ -255,7 +257,7 @@ int el_opmemory
for (line_number = 0; line_number < lines_count; ++line_number)
{
- el_print_line(file, num, level, options,
+ rv |= el_print_line(file, num, level, options,
mem, EL_MEM_LINE_SIZE, line_number);
/*
@@ -272,7 +274,7 @@ int el_opmemory
if (last_line_size)
{
- el_print_line(file, num, level, options,
+ rv |= el_print_line(file, num, level, options,
mem, last_line_size, line_number);
}
@@ -282,8 +284,10 @@ int el_opmemory
* ------ ----------------------------------------------- ----------------
*/
- el_oprint(file, num, level, options, "%.*s %.*s %.*s",
+ rv |= el_oprint(file, num, level, options, "%.*s %.*s %.*s",
EL_MEM_OFFSET_LEN - 2, separator,
EL_MEM_HEX_LEN - 1, separator,
EL_MEM_CHAR_LEN, separator);
+
+ return rv;
}
diff --git a/tst/el-file.c b/tst/el-file.c
index af98023..a6ff651 100644
--- a/tst/el-file.c
+++ b/tst/el-file.c
@@ -280,7 +280,7 @@ static void file_print_without_init(void)
========================================================================== */
-static int file_print_after_cleanup(void)
+static void file_print_after_cleanup(void)
{
el_init();
el_option(EL_OPT_OUTPUT, EL_OPT_OUT_FILE);
@@ -296,7 +296,7 @@ static int file_print_after_cleanup(void)
========================================================================== */
-static int file_print_without_setting_file(void)
+static void file_print_without_setting_file(void)
{
el_init();
el_option(EL_OPT_OUTPUT, EL_OPT_OUT_FILE);
diff --git a/tst/el-options.c b/tst/el-options.c
index a3859b7..898edbb 100644
--- a/tst/el-options.c
+++ b/tst/el-options.c
@@ -162,11 +162,11 @@ static void options_output(void)
mt_fok(el_option(EL_OPT_OUTPUT, EL_OPT_OUT_STDERR));
mt_fail(g_options.outputs == EL_OPT_OUT_STDERR);
- mt_fok(el_option(EL_OPT_OUTPUT, EL_OPT_OUT_STDERR | EL_OPT_OUT_FILE));
- mt_fail(g_options.outputs == EL_OPT_OUT_STDERR | EL_OPT_OUT_FILE);
+ mt_fok(el_option(EL_OPT_OUTPUT, (EL_OPT_OUT_STDERR | EL_OPT_OUT_FILE)));
+ mt_fail(g_options.outputs == (EL_OPT_OUT_STDERR | EL_OPT_OUT_FILE));
mt_ferr(el_option(EL_OPT_OUTPUT, EL_OPT_OUT_ALL + 7), EINVAL);
- mt_fail(g_options.outputs == EL_OPT_OUT_STDERR | EL_OPT_OUT_FILE);
+ mt_fail(g_options.outputs == (EL_OPT_OUT_STDERR | EL_OPT_OUT_FILE));
}
diff --git a/tst/el-perror.c b/tst/el-perror.c
index d260b76..5b53112 100644
--- a/tst/el-perror.c
+++ b/tst/el-perror.c
@@ -70,6 +70,7 @@ static int print_to_buffer
)
{
strcat(logbuf, s);
+ return 0;
}
diff --git a/tst/el-pmemory.c b/tst/el-pmemory.c
index 1bcb1db..cc1fe56 100644
--- a/tst/el-pmemory.c
+++ b/tst/el-pmemory.c
@@ -70,6 +70,7 @@ static int print_to_buffer
)
{
strcat(logbuf, s);
+ return 0;
}
diff --git a/tst/el-print.c b/tst/el-print.c
index cf4de4c..f277e65 100644
--- a/tst/el-print.c
+++ b/tst/el-print.c
@@ -40,10 +40,10 @@
struct log_message
{
- const char *file;
- size_t line;
- enum el_level level;
- const char *msg;
+ const char *file;
+ size_t line;
+ int level;
+ const char *msg;
};
@@ -300,7 +300,7 @@ static int print_check(void)
msg++; /* skip ']' character */
tmp[i] = '\0';
- if (atoi(tmp) != expected.line)
+ if ((size_t)atoi(tmp) != expected.line)
{
/*
* line number in printed log is different than what was set