2 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
3 * Copyright 2017 Philippe Proulx <jeremie.galarneau@efficios.com>
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 #define BT_LOG_TAG "PLUGIN-TEXT-DMESG-SRC"
31 #include <babeltrace/assert-internal.h>
32 #include <babeltrace/babeltrace.h>
33 #include <babeltrace/values-internal.h>
34 #include <babeltrace/compat/utc-internal.h>
35 #include <babeltrace/compat/stdio-internal.h>
38 #define NSEC_PER_USEC 1000UL
39 #define NSEC_PER_MSEC 1000000UL
40 #define NSEC_PER_SEC 1000000000ULL
41 #define USEC_PER_SEC 1000000UL
43 struct dmesg_component
;
45 struct dmesg_notif_iter
{
46 struct dmesg_component
*dmesg_comp
;
47 struct bt_private_connection_private_notification_iterator
*pc_notif_iter
; /* Weak */
51 struct bt_notification
*tmp_event_notif
;
54 STATE_EMIT_STREAM_BEGINNING
,
55 STATE_EMIT_PACKET_BEGINNING
,
57 STATE_EMIT_PACKET_END
,
58 STATE_EMIT_STREAM_END
,
63 struct dmesg_component
{
66 bt_bool read_from_stdin
;
70 struct bt_trace
*trace
;
71 struct bt_stream_class
*stream_class
;
72 struct bt_event_class
*event_class
;
73 struct bt_stream
*stream
;
74 struct bt_packet
*packet
;
75 struct bt_clock_class
*clock_class
;
76 struct bt_clock_class_priority_map
*cc_prio_map
;
80 struct bt_field_type
*create_packet_header_ft(void)
82 struct bt_field_type
*root_ft
= NULL
;
83 struct bt_field_type
*ft
= NULL
;
86 root_ft
= bt_field_type_structure_create();
88 BT_LOGE_STR("Cannot create an empty structure field type object.");
92 ft
= bt_field_type_integer_create(32);
94 BT_LOGE_STR("Cannot create an integer field type object.");
98 ret
= bt_field_type_structure_add_field(root_ft
, ft
, "magic");
100 BT_LOGE("Cannot add `magic` field type to structure field type: "
106 ft
= bt_field_type_integer_create(8);
108 BT_LOGE_STR("Cannot create an integer field type object.");
123 struct bt_field_type
*create_event_header_ft(
124 struct bt_clock_class
*clock_class
)
126 struct bt_field_type
*root_ft
= NULL
;
127 struct bt_field_type
*ft
= NULL
;
130 root_ft
= bt_field_type_structure_create();
132 BT_LOGE_STR("Cannot create an empty structure field type object.");
136 ft
= bt_field_type_integer_create(64);
138 BT_LOGE_STR("Cannot create an integer field type object.");
142 ret
= bt_field_type_integer_set_mapped_clock_class(ft
, clock_class
);
144 BT_LOGE("Cannot map integer field type to clock class: "
149 ret
= bt_field_type_structure_add_field(root_ft
,
152 BT_LOGE("Cannot add `timestamp` field type to structure field type: "
168 struct bt_field_type
*create_event_payload_ft(void)
170 struct bt_field_type
*root_ft
= NULL
;
171 struct bt_field_type
*ft
= NULL
;
174 root_ft
= bt_field_type_structure_create();
176 BT_LOGE_STR("Cannot create an empty structure field type object.");
180 ft
= bt_field_type_string_create();
182 BT_LOGE_STR("Cannot create a string field type object.");
186 ret
= bt_field_type_structure_add_field(root_ft
,
189 BT_LOGE("Cannot add `str` field type to structure field type: "
205 struct bt_clock_class
*create_clock_class(void)
207 return bt_clock_class_create("the_clock", 1000000000);
211 int create_meta(struct dmesg_component
*dmesg_comp
, bool has_ts
)
213 struct bt_field_type
*ft
= NULL
;
214 const char *trace_name
= NULL
;
215 gchar
*basename
= NULL
;
218 dmesg_comp
->trace
= bt_trace_create();
219 if (!dmesg_comp
->trace
) {
220 BT_LOGE_STR("Cannot create an empty trace object.");
224 ft
= create_packet_header_ft();
226 BT_LOGE_STR("Cannot create packet header field type.");
230 ret
= bt_trace_set_packet_header_field_type(dmesg_comp
->trace
, ft
);
232 BT_LOGE_STR("Cannot set trace's packet header field type.");
236 if (dmesg_comp
->params
.read_from_stdin
) {
237 trace_name
= "STDIN";
239 basename
= g_path_get_basename(dmesg_comp
->params
.path
->str
);
242 if (strcmp(basename
, G_DIR_SEPARATOR_S
) != 0 &&
243 strcmp(basename
, ".") != 0) {
244 trace_name
= basename
;
249 ret
= bt_trace_set_name(dmesg_comp
->trace
, trace_name
);
251 BT_LOGE("Cannot set trace's name: name=\"%s\"", trace_name
);
256 dmesg_comp
->stream_class
= bt_stream_class_create(NULL
);
257 if (!dmesg_comp
->stream_class
) {
258 BT_LOGE_STR("Cannot create an empty stream class object.");
263 dmesg_comp
->clock_class
= create_clock_class();
264 if (!dmesg_comp
->clock_class
) {
265 BT_LOGE_STR("Cannot create clock class.");
269 ret
= bt_trace_add_clock_class(dmesg_comp
->trace
,
270 dmesg_comp
->clock_class
);
272 BT_LOGE_STR("Cannot add clock class to trace.");
277 ft
= create_event_header_ft(dmesg_comp
->clock_class
);
279 BT_LOGE_STR("Cannot create event header field type.");
283 ret
= bt_stream_class_set_event_header_field_type(
284 dmesg_comp
->stream_class
, ft
);
286 BT_LOGE_STR("Cannot set stream class's event header field type.");
291 dmesg_comp
->event_class
= bt_event_class_create("string");
292 if (!dmesg_comp
->event_class
) {
293 BT_LOGE_STR("Cannot create an empty event class object.");
298 ft
= create_event_payload_ft();
300 BT_LOGE_STR("Cannot create event payload field type.");
304 ret
= bt_event_class_set_payload_field_type(dmesg_comp
->event_class
, ft
);
306 BT_LOGE_STR("Cannot set event class's event payload field type.");
310 ret
= bt_stream_class_add_event_class(dmesg_comp
->stream_class
,
311 dmesg_comp
->event_class
);
313 BT_LOGE("Cannot add event class to stream class: ret=%d", ret
);
317 ret
= bt_trace_add_stream_class(dmesg_comp
->trace
,
318 dmesg_comp
->stream_class
);
320 BT_LOGE("Cannot add event class to stream class: ret=%d", ret
);
340 int handle_params(struct dmesg_component
*dmesg_comp
, struct bt_value
*params
)
342 struct bt_value
*read_from_stdin
= NULL
;
343 struct bt_value
*no_timestamp
= NULL
;
344 struct bt_value
*path
= NULL
;
345 const char *path_str
;
348 no_timestamp
= bt_value_map_get(params
, "no-extract-timestamp");
350 if (!bt_value_is_bool(no_timestamp
)) {
351 BT_LOGE("Expecting a boolean value for the `no-extract-timestamp` parameter: "
353 bt_value_type_string(
354 bt_value_get_type(no_timestamp
)));
358 ret
= bt_value_bool_get(no_timestamp
,
359 &dmesg_comp
->params
.no_timestamp
);
363 path
= bt_value_map_get(params
, "path");
365 if (dmesg_comp
->params
.read_from_stdin
) {
366 BT_LOGE_STR("Cannot specify both `read-from-stdin` and `path` parameters.");
370 if (!bt_value_is_string(path
)) {
371 BT_LOGE("Expecting a string value for the `path` parameter: "
373 bt_value_type_string(
374 bt_value_get_type(path
)));
378 ret
= bt_value_string_get(path
, &path_str
);
380 g_string_assign(dmesg_comp
->params
.path
, path_str
);
382 dmesg_comp
->params
.read_from_stdin
= true;
391 bt_put(read_from_stdin
);
393 bt_put(no_timestamp
);
398 int fill_packet_header_field(struct bt_packet
*packet
)
400 struct bt_field
*ph
= NULL
;
401 struct bt_field
*magic
= NULL
;
404 ph
= bt_packet_borrow_header(packet
);
406 magic
= bt_field_structure_borrow_field_by_name(ph
, "magic");
408 BT_LOGE_STR("Cannot borrow `magic` field from structure field.");
412 ret
= bt_field_integer_unsigned_set_value(magic
, 0xc1fc1fc1);
424 int create_packet_and_stream(struct dmesg_component
*dmesg_comp
)
428 dmesg_comp
->stream
= bt_stream_create(dmesg_comp
->stream_class
,
430 if (!dmesg_comp
->stream
) {
431 BT_LOGE_STR("Cannot create stream object.");
435 dmesg_comp
->packet
= bt_packet_create(dmesg_comp
->stream
,
436 BT_PACKET_PREVIOUS_PACKET_AVAILABILITY_NONE
, NULL
);
437 if (!dmesg_comp
->packet
) {
438 BT_LOGE_STR("Cannot create packet object.");
442 ret
= fill_packet_header_field(dmesg_comp
->packet
);
444 BT_LOGE_STR("Cannot fill packet header field.");
448 ret
= bt_trace_set_is_static(dmesg_comp
->trace
);
450 BT_LOGE_STR("Cannot make trace static.");
464 int try_create_meta_stream_packet(struct dmesg_component
*dmesg_comp
,
469 if (dmesg_comp
->trace
) {
470 /* Already created */
474 ret
= create_meta(dmesg_comp
, has_ts
);
476 BT_LOGE("Cannot create metadata objects: dmesg-comp-addr=%p",
481 ret
= create_packet_and_stream(dmesg_comp
);
483 BT_LOGE("Cannot create packet and stream objects: "
484 "dmesg-comp-addr=%p", dmesg_comp
);
498 void destroy_dmesg_component(struct dmesg_component
*dmesg_comp
)
504 if (dmesg_comp
->params
.path
) {
505 g_string_free(dmesg_comp
->params
.path
, TRUE
);
508 bt_put(dmesg_comp
->packet
);
509 bt_put(dmesg_comp
->trace
);
510 bt_put(dmesg_comp
->stream_class
);
511 bt_put(dmesg_comp
->event_class
);
512 bt_put(dmesg_comp
->stream
);
513 bt_put(dmesg_comp
->clock_class
);
514 bt_put(dmesg_comp
->cc_prio_map
);
519 enum bt_component_status
create_port(struct bt_private_component
*priv_comp
)
521 return bt_private_component_source_add_output_private_port(priv_comp
,
526 enum bt_component_status
dmesg_init(struct bt_private_component
*priv_comp
,
527 struct bt_value
*params
, void *init_method_data
)
530 struct dmesg_component
*dmesg_comp
= g_new0(struct dmesg_component
, 1);
531 enum bt_component_status status
= BT_COMPONENT_STATUS_OK
;
534 BT_LOGE_STR("Failed to allocate one dmesg component structure.");
538 dmesg_comp
->params
.path
= g_string_new(NULL
);
539 if (!dmesg_comp
->params
.path
) {
540 BT_LOGE_STR("Failed to allocate a GString.");
544 ret
= handle_params(dmesg_comp
, params
);
546 BT_LOGE("Invalid parameters: comp-addr=%p", priv_comp
);
550 if (!dmesg_comp
->params
.read_from_stdin
&&
551 !g_file_test(dmesg_comp
->params
.path
->str
,
552 G_FILE_TEST_IS_REGULAR
)) {
553 BT_LOGE("Input path is not a regular file: "
554 "comp-addr=%p, path=\"%s\"", priv_comp
,
555 dmesg_comp
->params
.path
->str
);
559 status
= create_port(priv_comp
);
560 if (status
!= BT_COMPONENT_STATUS_OK
) {
564 (void) bt_private_component_set_user_data(priv_comp
, dmesg_comp
);
568 destroy_dmesg_component(dmesg_comp
);
569 (void) bt_private_component_set_user_data(priv_comp
, NULL
);
572 status
= BT_COMPONENT_STATUS_ERROR
;
580 void dmesg_finalize(struct bt_private_component
*priv_comp
)
582 void *data
= bt_private_component_get_user_data(priv_comp
);
584 destroy_dmesg_component(data
);
588 struct bt_notification
*create_init_event_notif_from_line(
589 struct dmesg_notif_iter
*notif_iter
,
590 const char *line
, const char **new_start
)
592 struct bt_event
*event
;
593 struct bt_notification
*notif
= NULL
;
594 bool has_timestamp
= false;
595 unsigned long sec
, usec
, msec
;
596 unsigned int year
, mon
, mday
, hour
, min
;
598 struct bt_field
*eh_field
= NULL
;
599 struct bt_field
*ts_field
= NULL
;
601 struct dmesg_component
*dmesg_comp
= notif_iter
->dmesg_comp
;
605 if (dmesg_comp
->params
.no_timestamp
) {
609 /* Extract time from input line */
610 if (sscanf(line
, "[%lu.%lu] ", &sec
, &usec
) == 2) {
611 ts
= (uint64_t) sec
* USEC_PER_SEC
+ (uint64_t) usec
;
614 * The clock class we use has a 1 GHz frequency: convert
618 has_timestamp
= true;
619 } else if (sscanf(line
, "[%u-%u-%u %u:%u:%lu.%lu] ",
620 &year
, &mon
, &mday
, &hour
, &min
,
625 memset(&ti
, 0, sizeof(ti
));
626 ti
.tm_year
= year
- 1900; /* From 1900 */
627 ti
.tm_mon
= mon
- 1; /* 0 to 11 */
633 ep_sec
= bt_timegm(&ti
);
634 if (ep_sec
!= (time_t) -1) {
635 ts
= (uint64_t) ep_sec
* NSEC_PER_SEC
636 + (uint64_t) msec
* NSEC_PER_MSEC
;
639 has_timestamp
= true;
643 /* Set new start for the message portion of the line */
644 *new_start
= strchr(line
, ']');
645 BT_ASSERT(*new_start
);
648 if ((*new_start
)[0] == ' ') {
655 * At this point, we know if the stream class's event header
656 * field type should have a timestamp or not, so we can lazily
657 * create the metadata, stream, and packet objects.
659 ret
= try_create_meta_stream_packet(dmesg_comp
, has_timestamp
);
661 /* try_create_meta_stream_packet() logs errors */
665 notif
= bt_notification_event_create(notif_iter
->pc_notif_iter
,
666 dmesg_comp
->event_class
, dmesg_comp
->packet
);
668 BT_LOGE_STR("Cannot create event notification.");
672 event
= bt_notification_event_borrow_event(notif
);
675 if (dmesg_comp
->clock_class
) {
676 ret
= bt_event_set_clock_value(event
,
677 dmesg_comp
->clock_class
, ts
, BT_TRUE
);
679 eh_field
= bt_event_borrow_header(event
);
681 ts_field
= bt_field_structure_borrow_field_by_name(eh_field
,
684 BT_LOGE_STR("Cannot borrow `timestamp` field from event header structure field.");
688 ret
= bt_field_integer_unsigned_set_value(ts_field
, ts
);
702 int fill_event_payload_from_line(const char *line
, struct bt_event
*event
)
704 struct bt_field
*ep_field
= NULL
;
705 struct bt_field
*str_field
= NULL
;
709 ep_field
= bt_event_borrow_payload(event
);
711 str_field
= bt_field_structure_borrow_field_by_name(ep_field
, "str");
713 BT_LOGE_STR("Cannot borrow `timestamp` field from event payload structure field.");
718 if (line
[len
- 1] == '\n') {
719 /* Do not include the newline character in the payload */
723 ret
= bt_field_string_clear(str_field
);
725 BT_LOGE_STR("Cannot clear string field object.");
729 ret
= bt_field_string_append_len(str_field
, line
, len
);
731 BT_LOGE("Cannot append value to string field object: "
746 struct bt_notification
*create_notif_from_line(
747 struct dmesg_notif_iter
*dmesg_notif_iter
, const char *line
)
749 struct bt_event
*event
= NULL
;
750 struct bt_notification
*notif
= NULL
;
751 const char *new_start
;
754 notif
= create_init_event_notif_from_line(dmesg_notif_iter
,
757 BT_LOGE_STR("Cannot create and initialize event notification from line.");
761 event
= bt_notification_event_borrow_event(notif
);
763 ret
= fill_event_payload_from_line(new_start
, event
);
765 BT_LOGE("Cannot fill event payload field from line: "
780 void destroy_dmesg_notif_iter(struct dmesg_notif_iter
*dmesg_notif_iter
)
782 if (!dmesg_notif_iter
) {
786 if (dmesg_notif_iter
->fp
&& dmesg_notif_iter
->fp
!= stdin
) {
787 if (fclose(dmesg_notif_iter
->fp
)) {
788 BT_LOGE_ERRNO("Cannot close input file", ".");
792 bt_put(dmesg_notif_iter
->tmp_event_notif
);
793 free(dmesg_notif_iter
->linebuf
);
794 g_free(dmesg_notif_iter
);
798 enum bt_notification_iterator_status
dmesg_notif_iter_init(
799 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
,
800 struct bt_private_port
*priv_port
)
802 struct bt_private_component
*priv_comp
= NULL
;
803 struct dmesg_component
*dmesg_comp
;
804 struct dmesg_notif_iter
*dmesg_notif_iter
=
805 g_new0(struct dmesg_notif_iter
, 1);
806 enum bt_notification_iterator_status status
=
807 BT_NOTIFICATION_ITERATOR_STATUS_OK
;
809 if (!dmesg_notif_iter
) {
810 BT_LOGE_STR("Failed to allocate on dmesg notification iterator structure.");
814 priv_comp
= bt_private_connection_private_notification_iterator_get_private_component(
816 BT_ASSERT(priv_comp
);
817 dmesg_comp
= bt_private_component_get_user_data(priv_comp
);
818 BT_ASSERT(dmesg_comp
);
819 dmesg_notif_iter
->dmesg_comp
= dmesg_comp
;
820 dmesg_notif_iter
->pc_notif_iter
= priv_notif_iter
;
822 if (dmesg_comp
->params
.read_from_stdin
) {
823 dmesg_notif_iter
->fp
= stdin
;
825 dmesg_notif_iter
->fp
= fopen(dmesg_comp
->params
.path
->str
, "r");
826 if (!dmesg_notif_iter
->fp
) {
827 BT_LOGE_ERRNO("Cannot open input file in read mode", ": path=\"%s\"",
828 dmesg_comp
->params
.path
->str
);
833 (void) bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter
,
838 destroy_dmesg_notif_iter(dmesg_notif_iter
);
839 (void) bt_private_connection_private_notification_iterator_set_user_data(priv_notif_iter
,
842 status
= BT_NOTIFICATION_ITERATOR_STATUS_ERROR
;
851 void dmesg_notif_iter_finalize(
852 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
)
854 destroy_dmesg_notif_iter(bt_private_connection_private_notification_iterator_get_user_data(
859 enum bt_notification_iterator_status
dmesg_notif_iter_next_one(
860 struct dmesg_notif_iter
*dmesg_notif_iter
,
861 struct bt_notification
**notif
)
864 struct dmesg_component
*dmesg_comp
;
865 enum bt_notification_iterator_status status
=
866 BT_NOTIFICATION_ITERATOR_STATUS_OK
;
868 BT_ASSERT(dmesg_notif_iter
);
869 dmesg_comp
= dmesg_notif_iter
->dmesg_comp
;
870 BT_ASSERT(dmesg_comp
);
872 if (dmesg_notif_iter
->state
== STATE_DONE
) {
873 status
= BT_NOTIFICATION_ITERATOR_STATUS_END
;
877 if (dmesg_notif_iter
->tmp_event_notif
||
878 dmesg_notif_iter
->state
== STATE_EMIT_PACKET_END
||
879 dmesg_notif_iter
->state
== STATE_EMIT_STREAM_END
) {
885 bool only_spaces
= true;
887 len
= bt_getline(&dmesg_notif_iter
->linebuf
,
888 &dmesg_notif_iter
->linebuf_len
, dmesg_notif_iter
->fp
);
890 if (errno
== EINVAL
) {
891 status
= BT_NOTIFICATION_ITERATOR_STATUS_ERROR
;
892 } else if (errno
== ENOMEM
) {
894 BT_NOTIFICATION_ITERATOR_STATUS_NOMEM
;
896 if (dmesg_notif_iter
->state
== STATE_EMIT_STREAM_BEGINNING
) {
897 /* Stream did not even begin */
898 status
= BT_NOTIFICATION_ITERATOR_STATUS_END
;
901 /* End current packet now */
902 dmesg_notif_iter
->state
=
903 STATE_EMIT_PACKET_END
;
911 BT_ASSERT(dmesg_notif_iter
->linebuf
);
913 /* Ignore empty lines, once trimmed */
914 for (ch
= dmesg_notif_iter
->linebuf
; *ch
!= '\0'; ch
++) {
926 dmesg_notif_iter
->tmp_event_notif
= create_notif_from_line(
927 dmesg_notif_iter
, dmesg_notif_iter
->linebuf
);
928 if (!dmesg_notif_iter
->tmp_event_notif
) {
929 BT_LOGE("Cannot create event notification from line: "
930 "dmesg-comp-addr=%p, line=\"%s\"", dmesg_comp
,
931 dmesg_notif_iter
->linebuf
);
936 BT_ASSERT(dmesg_comp
->trace
);
938 switch (dmesg_notif_iter
->state
) {
939 case STATE_EMIT_STREAM_BEGINNING
:
940 BT_ASSERT(dmesg_notif_iter
->tmp_event_notif
);
941 *notif
= bt_notification_stream_begin_create(
942 dmesg_notif_iter
->pc_notif_iter
, dmesg_comp
->stream
);
943 dmesg_notif_iter
->state
= STATE_EMIT_PACKET_BEGINNING
;
945 case STATE_EMIT_PACKET_BEGINNING
:
946 BT_ASSERT(dmesg_notif_iter
->tmp_event_notif
);
947 *notif
= bt_notification_packet_begin_create(
948 dmesg_notif_iter
->pc_notif_iter
, dmesg_comp
->packet
);
949 dmesg_notif_iter
->state
= STATE_EMIT_EVENT
;
951 case STATE_EMIT_EVENT
:
952 BT_ASSERT(dmesg_notif_iter
->tmp_event_notif
);
953 *notif
= dmesg_notif_iter
->tmp_event_notif
;
954 dmesg_notif_iter
->tmp_event_notif
= NULL
;
956 case STATE_EMIT_PACKET_END
:
957 *notif
= bt_notification_packet_end_create(
958 dmesg_notif_iter
->pc_notif_iter
, dmesg_comp
->packet
);
959 dmesg_notif_iter
->state
= STATE_EMIT_STREAM_END
;
961 case STATE_EMIT_STREAM_END
:
962 *notif
= bt_notification_stream_end_create(
963 dmesg_notif_iter
->pc_notif_iter
, dmesg_comp
->stream
);
964 dmesg_notif_iter
->state
= STATE_DONE
;
971 BT_LOGE("Cannot create notification: dmesg-comp-addr=%p",
973 status
= BT_NOTIFICATION_ITERATOR_STATUS_ERROR
;
981 enum bt_notification_iterator_status
dmesg_notif_iter_next(
982 struct bt_private_connection_private_notification_iterator
*priv_notif_iter
,
983 bt_notification_array notifs
, uint64_t capacity
,
986 struct dmesg_notif_iter
*dmesg_notif_iter
=
987 bt_private_connection_private_notification_iterator_get_user_data(
989 enum bt_notification_iterator_status status
=
990 BT_NOTIFICATION_ITERATOR_STATUS_OK
;
993 while (i
< capacity
&& status
== BT_NOTIFICATION_ITERATOR_STATUS_OK
) {
994 status
= dmesg_notif_iter_next_one(dmesg_notif_iter
, ¬ifs
[i
]);
995 if (status
== BT_NOTIFICATION_ITERATOR_STATUS_OK
) {
1002 * Even if dmesg_notif_iter_next_one() returned
1003 * something else than
1004 * BT_NOTIFICATION_ITERATOR_STATUS_OK, we accumulated
1005 * notification objects in the output notification
1006 * array, so we need to return
1007 * BT_NOTIFICATION_ITERATOR_STATUS_OK so that they are
1008 * transfered to downstream. This other status occurs
1009 * again the next time muxer_notif_iter_do_next() is
1010 * called, possibly without any accumulated
1011 * notification, in which case we'll return it.
1014 status
= BT_NOTIFICATION_ITERATOR_STATUS_OK
;