sink.text.details: replace switch to convert status with cast
authorSimon Marchi <simon.marchi@efficios.com>
Sat, 11 Apr 2020 17:08:54 +0000 (13:08 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 11 Apr 2020 23:13:48 +0000 (19:13 -0400)
Replace the switch currently used in details_consume, to convert the
status of bt_message_iterator_next, with a simple cast, as per standard
procedure.

Change-Id: Iea35bd26f4af983d7cca37fc01b2b2f903cc73da
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3394
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/plugins/text/details/details.c

index a5fa2c527c561d42fc44fa774d4ac7d2bbfa9584..ae389b25562778fd148c8ae55736c34559020b92 100644 (file)
@@ -425,8 +425,7 @@ BT_HIDDEN
 bt_component_class_sink_consume_method_status
 details_consume(bt_self_component_sink *comp)
 {
-       bt_component_class_sink_consume_method_status ret =
-               BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
+       bt_component_class_sink_consume_method_status status;
        bt_message_array_const msgs;
        uint64_t count;
        struct details_comp *details_comp;
@@ -441,52 +440,38 @@ details_consume(bt_self_component_sink *comp)
        /* Consume messages */
        next_status = bt_message_iterator_next(
                details_comp->msg_iter, &msgs, &count);
-       switch (next_status) {
-       case BT_MESSAGE_ITERATOR_NEXT_STATUS_OK:
-               ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
-
-               for (i = 0; i < count; i++) {
-                       int print_ret = details_write_message(details_comp,
-                               msgs[i]);
-
-                       if (print_ret) {
-                               for (; i < count; i++) {
-                                       /* Put all remaining messages */
-                                       bt_message_put_ref(msgs[i]);
-                               }
+       if (next_status != BT_MESSAGE_ITERATOR_NEXT_STATUS_OK) {
+               status = (int) next_status;
+               goto end;
+       }
 
-                               ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
-                               goto end;
-                       }
+       for (i = 0; i < count; i++) {
+               int print_ret = details_write_message(details_comp,
+                       msgs[i]);
 
-                       /* Print output buffer to standard output and flush */
-                       if (details_comp->str->len > 0) {
-                               printf("%s", details_comp->str->str);
-                               fflush(stdout);
-                               details_comp->printed_something = true;
+               if (print_ret) {
+                       for (; i < count; i++) {
+                               /* Put all remaining messages */
+                               bt_message_put_ref(msgs[i]);
                        }
 
-                       /* Put this message */
-                       bt_message_put_ref(msgs[i]);
+                       status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
+                       goto end;
                }
 
-               break;
-       case BT_MESSAGE_ITERATOR_NEXT_STATUS_AGAIN:
-               ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_AGAIN;
-               goto end;
-       case BT_MESSAGE_ITERATOR_NEXT_STATUS_END:
-               ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_END;
-               goto end;
-       case BT_MESSAGE_ITERATOR_NEXT_STATUS_ERROR:
-               ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_ERROR;
-               goto end;
-       case BT_MESSAGE_ITERATOR_NEXT_STATUS_MEMORY_ERROR:
-               ret = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_MEMORY_ERROR;
-               goto end;
-       default:
-               bt_common_abort();
+               /* Print output buffer to standard output and flush */
+               if (details_comp->str->len > 0) {
+                       printf("%s", details_comp->str->str);
+                       fflush(stdout);
+                       details_comp->printed_something = true;
+               }
+
+               /* Put this message */
+               bt_message_put_ref(msgs[i]);
        }
 
+       status = BT_COMPONENT_CLASS_SINK_CONSUME_METHOD_STATUS_OK;
+
 end:
-       return ret;
+       return status;
 }
This page took 0.027402 seconds and 4 git commands to generate.