Fix: userspace probe accessors are not const-correct
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 20:29:01 +0000 (16:29 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 20:50:34 +0000 (16:50 -0400)
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 <jeremie.galarneau@efficios.com>
include/lttng/event.h
include/lttng/userspace-probe.h
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/save.c
src/bin/lttng-sessiond/trace-kernel.c
src/bin/lttng/commands/list.c
src/common/mi-lttng.c
src/common/userspace-probe.c
src/lib/lttng-ctl/event.c

index 630d6c1188dd0255e71c11f4c487b4160df1a1ca..3f260c0a5d4479534fa86a2f2dac529245e66d9c 100644 (file)
@@ -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.
index c8c1ae43af4850cd4bc9baa72100561d2edc2b53..2d8c6f1257346dc22059d19441532a1ef3b8f962 100644 (file)
@@ -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);
 
index f5979c9b4f2cf26028c8d4f6f120349b9a0eed9c..e7f1d54a02bde7ecb72ec2e16e122982aeae319c 100644 (file)
@@ -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);
index 958aa0d04f0830385b9ad215fb38219489ce0847..ee50db21e38b2c29a400b1ccec0065f72f28900c 100644 (file)
@@ -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;
 
index c0684711ac9c818ea43a13d2945c4f168c1d876b..e57f0e03a6b451b920592a6cb2a08d5f61d1fd29 100644 (file)
@@ -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. */
index dcb1bd647b9a0a622b6cbd39c94979d1e0d30e1a..b9d03a72e002ca0042764a877f0ae556e87f1faa 100644 (file)
@@ -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) {
index be252ab7600c3299e0243df68338b703d19c9fa7..eabeb8132ecd36c6e15fb996cb8bdba96b61249d 100644 (file)
@@ -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);
index 0191cbd0f6d09f7e6c83db096027f209c7f91795..69b3cc041de0d42c44333d7ab8c84d5ff7e52473 100644 (file)
@@ -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);
index ea3c93bcde840242d4871084394f6ebe0d75ec11..89066bf0549a553df0564528d450a7763910ccc0 100644 (file)
@@ -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)
 {
index 046028cd219a46b25866770c1d8c96b8405092a2..44e4864c02cdb0552663b4a57537df2b3dde75fb 100644 (file)
@@ -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;
This page took 0.045544 seconds and 5 git commands to generate.