tools lib traceevent: Changed return logic of tep_register_event_handler() API
In order to make libtraceevent into a proper library, its API should be straightforward. The tep_register_event_handler() functions returns -1 in case it successfully registers the new event handler. Such return code is used by the other library APIs in case of an error. To unify the return logic of tep_register_event_handler() with the other APIs, this patch introduces enum tep_reg_handler, which is used by this function as return value, to handle all possible successful return cases. Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/20181201040852.628034497@goodmis.org Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
6d2d6fd7e3
commit
f87ce7c43f
|
@ -6632,6 +6632,12 @@ static struct tep_event *search_event(struct tep_handle *pevent, int id,
|
||||||
*
|
*
|
||||||
* If @id is >= 0, then it is used to find the event.
|
* If @id is >= 0, then it is used to find the event.
|
||||||
* else @sys_name and @event_name are used.
|
* else @sys_name and @event_name are used.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* TEP_REGISTER_SUCCESS_OVERWRITE if an existing handler is overwritten
|
||||||
|
* TEP_REGISTER_SUCCESS if a new handler is registered successfully
|
||||||
|
* negative TEP_ERRNO_... in case of an error
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
int tep_register_event_handler(struct tep_handle *pevent, int id,
|
int tep_register_event_handler(struct tep_handle *pevent, int id,
|
||||||
const char *sys_name, const char *event_name,
|
const char *sys_name, const char *event_name,
|
||||||
|
@ -6649,7 +6655,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id,
|
||||||
|
|
||||||
event->handler = func;
|
event->handler = func;
|
||||||
event->context = context;
|
event->context = context;
|
||||||
return 0;
|
return TEP_REGISTER_SUCCESS_OVERWRITE;
|
||||||
|
|
||||||
not_found:
|
not_found:
|
||||||
/* Save for later use. */
|
/* Save for later use. */
|
||||||
|
@ -6679,7 +6685,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id,
|
||||||
pevent->handlers = handle;
|
pevent->handlers = handle;
|
||||||
handle->context = context;
|
handle->context = context;
|
||||||
|
|
||||||
return -1;
|
return TEP_REGISTER_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_matches(struct event_handler *handler, int id,
|
static int handle_matches(struct event_handler *handler, int id,
|
||||||
|
|
|
@ -485,6 +485,11 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt,
|
||||||
struct tep_event *event, const char *name,
|
struct tep_event *event, const char *name,
|
||||||
struct tep_record *record, int err);
|
struct tep_record *record, int err);
|
||||||
|
|
||||||
|
enum tep_reg_handler {
|
||||||
|
TEP_REGISTER_SUCCESS = 0,
|
||||||
|
TEP_REGISTER_SUCCESS_OVERWRITE,
|
||||||
|
};
|
||||||
|
|
||||||
int tep_register_event_handler(struct tep_handle *pevent, int id,
|
int tep_register_event_handler(struct tep_handle *pevent, int id,
|
||||||
const char *sys_name, const char *event_name,
|
const char *sys_name, const char *event_name,
|
||||||
tep_event_handler_func func, void *context);
|
tep_event_handler_func func, void *context);
|
||||||
|
|
Loading…
Reference in New Issue