From: Jérémie Galarneau Date: Fri, 24 Aug 2018 20:29:01 +0000 (-0400) Subject: Fix: userspace probe accessors are not const-correct X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=87597c2c3bbaa1502ad2025cbf16704829f3b464 Fix: userspace probe accessors are not const-correct The accessors of userspace probe locations and lookup methods should be const. This commit marks them as such and modifies the code using those functions to be, in turn, const-correct. Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/event.h b/include/lttng/event.h index 630d6c118..3f260c0a5 100644 --- a/include/lttng/event.h +++ b/include/lttng/event.h @@ -348,8 +348,8 @@ extern int lttng_event_get_exclusion_name(struct lttng_event *event, * If the event has no probe location a NULL pointer is returned. The caller * does not own the returned probe location. */ -extern struct lttng_userspace_probe_location * -lttng_event_get_userspace_probe_location(struct lttng_event *event); +extern const struct lttng_userspace_probe_location * +lttng_event_get_userspace_probe_location(const struct lttng_event *event); /* * Set an LTTng event's userspace probe location. diff --git a/include/lttng/userspace-probe.h b/include/lttng/userspace-probe.h index c8c1ae43a..2d8c6f125 100644 --- a/include/lttng/userspace-probe.h +++ b/include/lttng/userspace-probe.h @@ -126,7 +126,7 @@ extern int lttng_userspace_probe_location_function_get_binary_fd( * * The ownership of the lookup method is NOT transferred to the caller. */ -extern struct lttng_userspace_probe_location_lookup_method * +extern const struct lttng_userspace_probe_location_lookup_method * lttng_userspace_probe_location_get_lookup_method( const struct lttng_userspace_probe_location *location); diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index f5979c9b4..e7f1d54a0 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -203,16 +203,15 @@ error: */ static int extract_userspace_probe_offset_function_elf( - struct lttng_userspace_probe_location *probe_location, + const struct lttng_userspace_probe_location *probe_location, struct ltt_kernel_session *session, uint64_t *offset) { int fd; int ret = 0; const char *symbol = NULL; - struct lttng_userspace_probe_location_lookup_method *lookup = NULL; + const struct lttng_userspace_probe_location_lookup_method *lookup = NULL; enum lttng_userspace_probe_location_lookup_method_type lookup_method_type; - assert(lttng_userspace_probe_location_get_type(probe_location) == LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION); @@ -266,12 +265,12 @@ end: */ static int extract_userspace_probe_offset_tracepoint_sdt( - struct lttng_userspace_probe_location *probe_location, + const struct lttng_userspace_probe_location *probe_location, struct ltt_kernel_session *session, uint64_t **offsets, uint32_t *offsets_count) { enum lttng_userspace_probe_location_lookup_method_type lookup_method_type; - struct lttng_userspace_probe_location_lookup_method *lookup = NULL; + const struct lttng_userspace_probe_location_lookup_method *lookup = NULL; const char *probe_name = NULL, *provider_name = NULL; int ret = 0; int fd, i; @@ -342,9 +341,9 @@ static int userspace_probe_add_callsites(struct lttng_event *ev, struct ltt_kernel_session *session, int fd) { - struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL; + const struct lttng_userspace_probe_location_lookup_method *lookup_method = NULL; enum lttng_userspace_probe_location_lookup_method_type type; - struct lttng_userspace_probe_location *location = NULL; + const struct lttng_userspace_probe_location *location = NULL; int ret; assert(ev); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 958aa0d04..ee50db21e 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2937,7 +2937,7 @@ static int receive_userspace_probe(struct command_ctx *cmd_ctx, int sock, { int fd, ret; struct lttng_userspace_probe_location *probe_location; - struct lttng_userspace_probe_location_lookup_method *lookup = NULL; + const struct lttng_userspace_probe_location_lookup_method *lookup = NULL; struct lttng_dynamic_buffer probe_location_buffer; struct lttng_buffer_view buffer_view; diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index c0684711a..e57f0e03a 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -504,8 +504,8 @@ int save_kernel_userspace_probe_tracepoint_event(struct config_writer *writer, { int ret = 0; const char *probe_name, *provider_name, *binary_path; - struct lttng_userspace_probe_location *userspace_probe_location; - struct lttng_userspace_probe_location_lookup_method *lookup_method; + const struct lttng_userspace_probe_location *userspace_probe_location; + const struct lttng_userspace_probe_location_lookup_method *lookup_method; enum lttng_userspace_probe_location_lookup_method_type lookup_type; /* Get userspace probe location from the event. */ @@ -618,8 +618,8 @@ int save_kernel_userspace_probe_function_event(struct config_writer *writer, { int ret = 0; const char *function_name, *binary_path; - struct lttng_userspace_probe_location *userspace_probe_location; - struct lttng_userspace_probe_location_lookup_method *lookup_method; + const struct lttng_userspace_probe_location *userspace_probe_location; + const struct lttng_userspace_probe_location_lookup_method *lookup_method; enum lttng_userspace_probe_location_lookup_method_type lookup_type; /* Get userspace probe location from the event. */ diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index dcb1bd647..b9d03a72e 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -328,8 +328,8 @@ enum lttng_error_code trace_kernel_create_event( break; case LTTNG_EVENT_USERSPACE_PROBE: { - struct lttng_userspace_probe_location* location = NULL; - struct lttng_userspace_probe_location_lookup_method *lookup = NULL; + const struct lttng_userspace_probe_location* location = NULL; + const struct lttng_userspace_probe_location_lookup_method *lookup = NULL; location = lttng_event_get_userspace_probe_location(ev); if (!location) { diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index be252ab76..eabeb8132 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -251,8 +251,8 @@ end: static void print_userspace_probe_location(struct lttng_event *event) { - struct lttng_userspace_probe_location *location; - struct lttng_userspace_probe_location_lookup_method *lookup_method; + const struct lttng_userspace_probe_location *location; + const struct lttng_userspace_probe_location_lookup_method *lookup_method; enum lttng_userspace_probe_location_lookup_method_type lookup_type; location = lttng_event_get_userspace_probe_location(event); diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c index 0191cbd0f..69b3cc041 100644 --- a/src/common/mi-lttng.c +++ b/src/common/mi-lttng.c @@ -1280,8 +1280,8 @@ int mi_lttng_event_userspace_probe(struct mi_writer *writer, struct lttng_event *event) { int ret; - struct lttng_userspace_probe_location *location; - struct lttng_userspace_probe_location_lookup_method *lookup_method; + const struct lttng_userspace_probe_location *location; + const struct lttng_userspace_probe_location_lookup_method *lookup_method; enum lttng_userspace_probe_location_lookup_method_type lookup_type; location = lttng_event_get_userspace_probe_location(event); diff --git a/src/common/userspace-probe.c b/src/common/userspace-probe.c index ea3c93bcd..89066bf05 100644 --- a/src/common/userspace-probe.c +++ b/src/common/userspace-probe.c @@ -764,7 +764,7 @@ end: return ret; } -struct lttng_userspace_probe_location_lookup_method * +const struct lttng_userspace_probe_location_lookup_method * lttng_userspace_probe_location_get_lookup_method( const struct lttng_userspace_probe_location *location) { diff --git a/src/lib/lttng-ctl/event.c b/src/lib/lttng-ctl/event.c index 046028cd2..44e4864c0 100644 --- a/src/lib/lttng-ctl/event.c +++ b/src/lib/lttng-ctl/event.c @@ -197,8 +197,8 @@ end: return ret; } -struct lttng_userspace_probe_location * -lttng_event_get_userspace_probe_location(struct lttng_event *event) +const struct lttng_userspace_probe_location * +lttng_event_get_userspace_probe_location(const struct lttng_event *event) { struct lttng_userspace_probe_location *probe_location = NULL; struct lttng_event_extended *event_extended;