From fe8ad2b66ceef2211d3802e182ddcec982da35ec Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 6 Apr 2017 14:37:44 -0400 Subject: [PATCH] Use the same values for different status codes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The weird values are based on the Linux error numbers (EAGAIN, EINVAL, etc.). Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- include/babeltrace/graph/component-status.h | 10 +++++----- include/babeltrace/graph/graph.h | 10 ++++------ include/babeltrace/graph/notification-iterator.h | 10 +++++----- lib/graph/iterator.c | 16 +++++++++------- plugins/ctf/fs/fs.c | 4 ++-- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/babeltrace/graph/component-status.h b/include/babeltrace/graph/component-status.h index dca7e8aa..b86db77e 100644 --- a/include/babeltrace/graph/component-status.h +++ b/include/babeltrace/graph/component-status.h @@ -43,19 +43,19 @@ enum bt_component_status { * Component can't process a notification at this time * (e.g. would block), try again later. */ - BT_COMPONENT_STATUS_AGAIN = 2, + BT_COMPONENT_STATUS_AGAIN = 11, /** Refuse port connection. */ - BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 3, + BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION = 111, /** General error. */ BT_COMPONENT_STATUS_ERROR = -1, /** Unsupported component feature. */ BT_COMPONENT_STATUS_UNSUPPORTED = -2, /** Invalid arguments. */ - BT_COMPONENT_STATUS_INVALID = -3, + BT_COMPONENT_STATUS_INVALID = -22, /** Memory allocation failure. */ - BT_COMPONENT_STATUS_NOMEM = -4, + BT_COMPONENT_STATUS_NOMEM = -12, /** Element not found. */ - BT_COMPONENT_STATUS_NOT_FOUND = -5, + BT_COMPONENT_STATUS_NOT_FOUND = -19, }; #ifdef __cplusplus diff --git a/include/babeltrace/graph/graph.h b/include/babeltrace/graph/graph.h index 884ba5f1..07ff3939 100644 --- a/include/babeltrace/graph/graph.h +++ b/include/babeltrace/graph/graph.h @@ -38,20 +38,18 @@ struct bt_connection; enum bt_graph_status { /** No sink can consume at the moment. */ - BT_GRAPH_STATUS_AGAIN = 2, + BT_GRAPH_STATUS_AGAIN = 11, /** Downstream component does not support multiple inputs. */ BT_GRAPH_STATUS_END = 1, BT_GRAPH_STATUS_OK = 0, - /** Downstream component does not support multiple inputs. */ - BT_GRAPH_STATUS_MULTIPLE_INPUTS_UNSUPPORTED = -1, /** Component is already part of another graph. */ BT_GRAPH_STATUS_ALREADY_IN_A_GRAPH = -2, /** Invalid arguments. */ - BT_GRAPH_STATUS_INVALID = -3, + BT_GRAPH_STATUS_INVALID = -22, /** No sink in graph. */ - BT_GRAPH_STATUS_NO_SINK = -4, + BT_GRAPH_STATUS_NO_SINK = -6, /** General error. */ - BT_GRAPH_STATUS_ERROR = -5, + BT_GRAPH_STATUS_ERROR = -1, }; typedef void (*bt_graph_port_added_listener)(struct bt_port *port, diff --git a/include/babeltrace/graph/notification-iterator.h b/include/babeltrace/graph/notification-iterator.h index 56a2e0e0..d8554316 100644 --- a/include/babeltrace/graph/notification-iterator.h +++ b/include/babeltrace/graph/notification-iterator.h @@ -41,19 +41,19 @@ struct bt_notification_iterator; */ enum bt_notification_iterator_status { /** Try again. */ - BT_NOTIFICATION_ITERATOR_STATUS_AGAIN = 2, + BT_NOTIFICATION_ITERATOR_STATUS_AGAIN = 11, /** No more notifications to be delivered. */ BT_NOTIFICATION_ITERATOR_STATUS_END = 1, /** No error, okay. */ BT_NOTIFICATION_ITERATOR_STATUS_OK = 0, /** Invalid arguments. */ - BT_NOTIFICATION_ITERATOR_STATUS_INVAL = -1, + BT_NOTIFICATION_ITERATOR_STATUS_INVALID = -22, /** General error. */ - BT_NOTIFICATION_ITERATOR_STATUS_ERROR = -2, + BT_NOTIFICATION_ITERATOR_STATUS_ERROR = -1, /** Out of memory. */ - BT_NOTIFICATION_ITERATOR_STATUS_NOMEM = -3, + BT_NOTIFICATION_ITERATOR_STATUS_NOMEM = -12, /** Unsupported iterator feature. */ - BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED = -4, + BT_NOTIFICATION_ITERATOR_STATUS_UNSUPPORTED = -2, }; diff --git a/lib/graph/iterator.c b/lib/graph/iterator.c index 29562955..491dddf3 100644 --- a/lib/graph/iterator.c +++ b/lib/graph/iterator.c @@ -122,7 +122,7 @@ enum bt_notification_iterator_status bt_notification_iterator_validate( BT_NOTIFICATION_ITERATOR_STATUS_OK; if (!iterator) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL; + ret = BT_NOTIFICATION_ITERATOR_STATUS_INVALID; goto end; } end: @@ -149,7 +149,7 @@ bt_private_notification_iterator_set_user_data( bt_notification_iterator_from_private(private_iterator); if (!iterator) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL; + ret = BT_NOTIFICATION_ITERATOR_STATUS_INVALID; goto end; } @@ -179,12 +179,13 @@ bt_notification_iterator_next(struct bt_notification_iterator *iterator) struct bt_private_notification_iterator *priv_iterator = bt_private_notification_iterator_from_notification_iterator(iterator); bt_component_class_notification_iterator_next_method next_method = NULL; - struct bt_notification_iterator_next_return next_return; - enum bt_notification_iterator_status status = - BT_NOTIFICATION_ITERATOR_STATUS_OK; + struct bt_notification_iterator_next_return next_return = { + .status = BT_NOTIFICATION_ITERATOR_STATUS_OK, + .notification = NULL, + }; if (!iterator) { - status = BT_NOTIFICATION_ITERATOR_STATUS_INVAL; + next_return.status = BT_NOTIFICATION_ITERATOR_STATUS_INVALID; goto end; } @@ -221,7 +222,8 @@ bt_notification_iterator_next(struct bt_notification_iterator *iterator) next_return = next_method(priv_iterator); if (next_return.status == BT_NOTIFICATION_ITERATOR_STATUS_OK) { if (!next_return.notification) { - status = BT_NOTIFICATION_ITERATOR_STATUS_ERROR; + next_return.status = + BT_NOTIFICATION_ITERATOR_STATUS_ERROR; goto end; } diff --git a/plugins/ctf/fs/fs.c b/plugins/ctf/fs/fs.c index 6ea15530..808f9ccf 100644 --- a/plugins/ctf/fs/fs.c +++ b/plugins/ctf/fs/fs.c @@ -86,13 +86,13 @@ enum bt_notification_iterator_status ctf_fs_iterator_init( ctf_fs = bt_private_component_get_user_data(priv_comp); if (!ctf_fs) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL; + ret = BT_NOTIFICATION_ITERATOR_STATUS_INVALID; goto error; } port_data = bt_private_port_get_user_data(port); if (!port_data) { - ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL; + ret = BT_NOTIFICATION_ITERATOR_STATUS_INVALID; goto error; } -- 2.34.1