Align faultd_bson_get_timespec function to fit convention used in EJDB. 24/138924/4
authorKonrad Kuchciak <k.kuchciak@samsung.com>
Thu, 13 Jul 2017 15:24:33 +0000 (17:24 +0200)
committerKonrad Kuchciak <k.kuchciak@samsung.com>
Wed, 19 Jul 2017 07:30:13 +0000 (09:30 +0200)
Change-Id: I20549539cb05d84c67c742a9de3ae678db88c412

src/core/event.c
src/util/common.c
src/util/common.h

index 66305333ea6fbd1147d0054b27884e44bd032379..ff8f08b7e9c98a607db7589b78fe12e432763a4e 100644 (file)
@@ -172,7 +172,6 @@ int faultd_event_deserialize_internal(const bson* in, struct faultd_event_type *
        BSON_ITERATOR_INIT(&it, in);
 
        while ((bt = bson_iterator_next(&it)) != BSON_EOO) {
-               bson b;
                if ((bt == BSON_BINDATA) &&
                        (bson_iterator_bin_type(&it) == BSON_BIN_UUID) &&
                        (strcmp(EV_BOOT_ID, bson_iterator_key(&it)) == 0))
@@ -182,9 +181,7 @@ int faultd_event_deserialize_internal(const bson* in, struct faultd_event_type *
                else if ((bt == BSON_OBJECT) &&
                                   (strcmp(EV_TIMESTAMP, bson_iterator_key(&it)) == 0)) {
 
-                       bson_init_finished_data(&b, bson_iterator_value(&it));
-                       faultd_bson_get_timespec(&b, &ev->timestamp);
-
+                       faultd_bson_iterator_timespec(&it, &ev->timestamp);
                }
        }
        ret = 0;
index 161569105223a030d02e51e8dda4c1ffcd3dd8b4..01111fce051be3234934547ae925413b4fe9b518 100644 (file)
@@ -28,7 +28,7 @@ GENERATE_BSON_APPEND_STRUCT(timespec,
                                                        bson_append_long(out, "nsec", data->tv_nsec);
                                                        )
 
-int faultd_bson_get_timespec(const bson *in, struct timespec *t)
+int faultd_bson_iterator_timespec(const bson_iterator *i, struct timespec *t)
 {
        int ret = -EINVAL;
        bson_iterator it;
@@ -36,7 +36,7 @@ int faultd_bson_get_timespec(const bson *in, struct timespec *t)
        bool sec = false;
        bool nsec = false;
 
-       BSON_ITERATOR_INIT(&it, in);
+       bson_iterator_subiterator(i, &it);
        while ((bt = bson_iterator_next(&it)) != BSON_EOO) {
                if ((bt == BSON_LONG) &&
                        (strcmp("sec", bson_iterator_key(&it)) == 0)) {
index f182d1bdcef6079a1909000bca7c66a847c92b85..476ea742e8bf7a14af339e79b6dfb00f732de351 100644 (file)
@@ -77,7 +77,7 @@ static inline void freep(void *p)
        }
 
 DECLARE_BSON_APPEND_STRUCT(timespec);
-int faultd_bson_get_timespec(const bson *in, struct timespec *t);
+int faultd_bson_iterator_timespec(const bson_iterator *i, struct timespec *t);
 
 #define BSON_EMPTY_SIZE (4 /* len */ + 1 /* \0 */)