Unsupported buffer set retval: EINVAL → ENOTSUP 07/217907/2
authorMichal Bloch <m.bloch@samsung.com>
Fri, 15 Nov 2019 11:18:34 +0000 (12:18 +0100)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Wed, 20 Nov 2019 01:03:10 +0000 (01:03 +0000)
Change-Id: I370bfc46d6326a8ae14cae89da87623adb8c7a03
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/shared/logretrieve.c
src/tests/logutil.c

index 6f7e5a4..089321a 100644 (file)
@@ -10,9 +10,17 @@ static const int default_buffers = (1 << LOG_ID_MAIN) | (1 << LOG_ID_SYSTEM) | (
 
 int validate_buffers(int *enabled_buffers)
 {
+       /* KMSG lacks some timestamps so we have trouble sorting
+        * it with core buffers, thus mixing them is not supported
+        * at the moment. Possibly in the future we could reduce
+        * the timestamp bloat and allow it.
+        *
+        * Ideally, this would only happen for modes that actually
+        * want to sort the buffers (so would be allowed for clearing
+        * buffers, for example). */
        if (*enabled_buffers &  (1 << LOG_ID_KMSG)
        &&  *enabled_buffers & ~(1 << LOG_ID_KMSG))
-               return -EINVAL;
+               return -ENOTSUP;
 
        if (!*enabled_buffers)
                *enabled_buffers = default_buffers;
@@ -25,8 +33,9 @@ int create_initial_fdis(struct fd_info ***fdis, int enabled_buffers, bool is_pip
        assert(fdis);
        assert(conf);
 
-       if (validate_buffers(&enabled_buffers) < 0)
-               return -EINVAL;
+       int ret = validate_buffers(&enabled_buffers);
+       if (ret < 0)
+               return ret;
 
        struct fd_info **fdi_ptrs = calloc(bit_count(enabled_buffers) + 1 /* NULL terminator */, sizeof *fdi_ptrs);
        if (!fdi_ptrs)
@@ -35,7 +44,6 @@ int create_initial_fdis(struct fd_info ***fdis, int enabled_buffers, bool is_pip
        __attribute__ ((cleanup(list_clear_free_contents))) list_head used_paths = NULL;
 
        int fdi_cnt = 0;
-       int ret = 0;
        for (int i = 0; i < LOG_ID_MAX; ++i) {
                if (!bit_test(enabled_buffers, i))
                        continue;
index 0893146..9fa6845 100644 (file)
@@ -217,7 +217,7 @@ int main()
        assert(buf == (1 << LOG_ID_MAIN));
 
        buf |= 1 << LOG_ID_KMSG;
-       assert(validate_buffers(&buf) == -EINVAL);
+       assert(validate_buffers(&buf) == -ENOTSUP);
 
        sort_vector_free(&sv);
 }