summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Majewski <m.majewski2@samsung.com>2019-09-06 10:59:02 +0200
committerMateusz Majewski <m.majewski2@samsung.com>2019-09-09 08:38:18 +0200
commit4b557a2193b968d7cc0f922b097256a727b9acb2 (patch)
tree2bd6c9494f67e27fc3d77501fd91b815c0fc9261
parentae2740f519836000d30c8442113524735a228df1 (diff)
downloaddlog-4b557a2193b968d7cc0f922b097256a727b9acb2.tar.gz
dlog-4b557a2193b968d7cc0f922b097256a727b9acb2.tar.bz2
dlog-4b557a2193b968d7cc0f922b097256a727b9acb2.zip
Move buffer choice validation into create_initial_fdis
Change-Id: I3328790d7ef438aaa7dd99a22b12c3243145c292
-rw-r--r--src/logutil/logutil.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/logutil/logutil.c b/src/logutil/logutil.c
index 2cf95b9f..b396328a 100644
--- a/src/logutil/logutil.c
+++ b/src/logutil/logutil.c
@@ -417,12 +417,29 @@ enomem:
return -ENOMEM;
}
+int validate_buffers(int *enabled_buffers)
+{
+ if (*enabled_buffers & (1 << LOG_ID_KMSG)
+ && *enabled_buffers & ~(1 << LOG_ID_KMSG)) {
+ ERR("Error: mixing KMSG and other buffers is not allowed\n");
+ return -EINVAL;
+ }
+
+ if (!*enabled_buffers)
+ *enabled_buffers = default_buffers;
+
+ return 0;
+}
+
int create_initial_fdis(struct fd_info ***fdis, int enabled_buffers, struct fd_ops *buffer_op, const struct log_config *conf)
{
assert(fdis);
assert(buffer_op);
assert(conf);
+ if (validate_buffers(&enabled_buffers) < 0)
+ return 1;
+
struct fd_info **fdi_ptrs = calloc(bit_count(enabled_buffers) + 1 /* NULL terminator */, sizeof *fdi_ptrs);
if (!fdi_ptrs)
return -ENOMEM;
@@ -477,20 +494,6 @@ failure:
return ret;
}
-int validate_buffers(int *enabled_buffers)
-{
- if (*enabled_buffers & (1 << LOG_ID_KMSG)
- && *enabled_buffers & ~(1 << LOG_ID_KMSG)) {
- ERR("Error: mixing KMSG and other buffers is not allowed\n");
- return -EINVAL;
- }
-
- if (!*enabled_buffers)
- *enabled_buffers = default_buffers;
-
- return 0;
-}
-
#ifndef UNIT_TEST
int main(int argc, char **argv)
{
@@ -520,9 +523,6 @@ int main(int argc, char **argv)
if (r)
return r < 0 ? 1 : 0;
- if (validate_buffers(&enabled_buffers) < 0)
- return 1;
-
/** Optimisation for short-lived (i.e. dumping) instances.
We can assume that such instances will not see a timezone