From: Simon Marchi Date: Thu, 13 Feb 2020 15:36:31 +0000 (-0500) Subject: Fix all -Wdiscarded-qualifiers warning instances X-Git-Tag: v2.12.0-rc2~22 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=cea15630e95deb18545e9b52d436dee5367a9e68;p=lttng-tools.git Fix all -Wdiscarded-qualifiers warning instances Change-Id: I85246856d284d5a2dad9609f5fb06d32a89dbb7c Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau --- diff --git a/configure.ac b/configure.ac index e3b23f465..a997ba3b9 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,7 @@ AX_APPEND_COMPILE_FLAGS([ dnl dnl extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) __THROWNL; dnl ^ -Wno-incomplete-setjmp-declaration dnl + -Wdiscarded-qualifiers dnl ], [WARN_CFLAGS], [-Werror]) diff --git a/src/bin/lttng-crash/lttng-crash.c b/src/bin/lttng-crash/lttng-crash.c index c0bf42c5a..98c52c59d 100644 --- a/src/bin/lttng-crash/lttng-crash.c +++ b/src/bin/lttng-crash/lttng-crash.c @@ -180,9 +180,9 @@ struct lttng_crash_layout { }; /* Variables */ -static char *progname, - *opt_viewer_path = NULL, - *opt_output_path = NULL; +static const char *progname; +static char *opt_viewer_path = NULL; +static char *opt_output_path = NULL; static char *input_path; @@ -296,7 +296,7 @@ static int parse_args(int argc, char **argv) } if (!opt_viewer_path) { - opt_viewer_path = DEFAULT_VIEWER; + opt_viewer_path = (char *) DEFAULT_VIEWER; } /* No leftovers, or more than one input path, print usage and quit */ diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c index ae0e02092..473491f37 100644 --- a/src/bin/lttng-sessiond/client.c +++ b/src/bin/lttng-sessiond/client.c @@ -182,7 +182,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) case LTTNG_CONSUMER64_UST: { if (config.consumerd64_lib_dir.value) { - char *tmp; + const char *tmp; size_t tmplen; char *tmpnew; @@ -219,7 +219,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) case LTTNG_CONSUMER32_UST: { if (config.consumerd32_lib_dir.value) { - char *tmp; + const char *tmp; size_t tmplen; char *tmpnew; diff --git a/src/bin/lttng-sessiond/modprobe.c b/src/bin/lttng-sessiond/modprobe.c index 66e80e75b..cf9c12b3c 100644 --- a/src/bin/lttng-sessiond/modprobe.c +++ b/src/bin/lttng-sessiond/modprobe.c @@ -31,58 +31,58 @@ /* LTTng kernel tracer mandatory core modules list */ struct kern_modules_param kern_modules_control_core[] = { - { "lttng-ring-buffer-client-discard" }, - { "lttng-ring-buffer-client-overwrite" }, - { "lttng-ring-buffer-metadata-client" }, - { "lttng-ring-buffer-client-mmap-discard" }, - { "lttng-ring-buffer-client-mmap-overwrite" }, - { "lttng-ring-buffer-metadata-mmap-client" }, + { (char *) "lttng-ring-buffer-client-discard" }, + { (char *) "lttng-ring-buffer-client-overwrite" }, + { (char *) "lttng-ring-buffer-metadata-client" }, + { (char *) "lttng-ring-buffer-client-mmap-discard" }, + { (char *) "lttng-ring-buffer-client-mmap-overwrite" }, + { (char *) "lttng-ring-buffer-metadata-mmap-client" }, }; /* LTTng kernel tracer probe modules list */ struct kern_modules_param kern_modules_probes_default[] = { - { "lttng-probe-asoc" }, - { "lttng-probe-block" }, - { "lttng-probe-btrfs" }, - { "lttng-probe-compaction" }, - { "lttng-probe-ext3" }, - { "lttng-probe-ext4" }, - { "lttng-probe-gpio" }, - { "lttng-probe-i2c" }, - { "lttng-probe-irq" }, - { "lttng-probe-jbd" }, - { "lttng-probe-jbd2" }, - { "lttng-probe-kmem" }, - { "lttng-probe-kvm" }, - { "lttng-probe-kvm-x86" }, - { "lttng-probe-kvm-x86-mmu" }, - { "lttng-probe-lock" }, - { "lttng-probe-module" }, - { "lttng-probe-napi" }, - { "lttng-probe-net" }, - { "lttng-probe-power" }, - { "lttng-probe-preemptirq" }, - { "lttng-probe-printk" }, - { "lttng-probe-random" }, - { "lttng-probe-rcu" }, - { "lttng-probe-regmap" }, - { "lttng-probe-regulator" }, - { "lttng-probe-rpm" }, - { "lttng-probe-sched" }, - { "lttng-probe-scsi" }, - { "lttng-probe-signal" }, - { "lttng-probe-skb" }, - { "lttng-probe-sock" }, - { "lttng-probe-statedump" }, - { "lttng-probe-sunrpc" }, - { "lttng-probe-timer" }, - { "lttng-probe-udp" }, - { "lttng-probe-vmscan" }, - { "lttng-probe-v4l2" }, - { "lttng-probe-workqueue" }, - { "lttng-probe-writeback" }, - { "lttng-probe-x86-irq-vectors" }, - { "lttng-probe-x86-exceptions" }, + { (char *) "lttng-probe-asoc" }, + { (char *) "lttng-probe-block" }, + { (char *) "lttng-probe-btrfs" }, + { (char *) "lttng-probe-compaction" }, + { (char *) "lttng-probe-ext3" }, + { (char *) "lttng-probe-ext4" }, + { (char *) "lttng-probe-gpio" }, + { (char *) "lttng-probe-i2c" }, + { (char *) "lttng-probe-irq" }, + { (char *) "lttng-probe-jbd" }, + { (char *) "lttng-probe-jbd2" }, + { (char *) "lttng-probe-kmem" }, + { (char *) "lttng-probe-kvm" }, + { (char *) "lttng-probe-kvm-x86" }, + { (char *) "lttng-probe-kvm-x86-mmu" }, + { (char *) "lttng-probe-lock" }, + { (char *) "lttng-probe-module" }, + { (char *) "lttng-probe-napi" }, + { (char *) "lttng-probe-net" }, + { (char *) "lttng-probe-power" }, + { (char *) "lttng-probe-preemptirq" }, + { (char *) "lttng-probe-printk" }, + { (char *) "lttng-probe-random" }, + { (char *) "lttng-probe-rcu" }, + { (char *) "lttng-probe-regmap" }, + { (char *) "lttng-probe-regulator" }, + { (char *) "lttng-probe-rpm" }, + { (char *) "lttng-probe-sched" }, + { (char *) "lttng-probe-scsi" }, + { (char *) "lttng-probe-signal" }, + { (char *) "lttng-probe-skb" }, + { (char *) "lttng-probe-sock" }, + { (char *) "lttng-probe-statedump" }, + { (char *) "lttng-probe-sunrpc" }, + { (char *) "lttng-probe-timer" }, + { (char *) "lttng-probe-udp" }, + { (char *) "lttng-probe-vmscan" }, + { (char *) "lttng-probe-v4l2" }, + { (char *) "lttng-probe-workqueue" }, + { (char *) "lttng-probe-writeback" }, + { (char *) "lttng-probe-x86-irq-vectors" }, + { (char *) "lttng-probe-x86-exceptions" }, }; /* dynamic probe modules list */ diff --git a/src/bin/lttng-sessiond/sessiond-config.c b/src/bin/lttng-sessiond/sessiond-config.c index d908da972..f0ab4ce04 100644 --- a/src/bin/lttng-sessiond/sessiond-config.c +++ b/src/bin/lttng-sessiond/sessiond-config.c @@ -31,7 +31,7 @@ struct sessiond_config sessiond_config_build_defaults = { .daemonize = false, .sig_parent = false, - .tracing_group_name.value = DEFAULT_TRACING_GROUP, + .tracing_group_name.value = (char *) DEFAULT_TRACING_GROUP, .kmod_probes_list.value = NULL, .kmod_extra_probes_list.value = NULL, diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index cf74703c3..ba63922cb 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -1019,7 +1019,7 @@ error_free: * Alloc new UST app channel. */ static -struct ust_app_channel *alloc_ust_app_channel(char *name, +struct ust_app_channel *alloc_ust_app_channel(const char *name, struct ust_app_session *ua_sess, struct lttng_ust_channel_attr *attr) { diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c index 412202572..994cd49eb 100644 --- a/src/bin/lttng/commands/add_context.c +++ b/src/bin/lttng/commands/add_context.c @@ -184,19 +184,19 @@ static struct poptOption long_options[] = { */ #define PERF_HW(optstr, name, type, hide) \ { \ - optstr, type, hide, \ + (char *) optstr, type, hide, \ .u.perf = { PERF_TYPE_HARDWARE, PERF_COUNT_HW_##name, },\ } #define PERF_SW(optstr, name, type, hide) \ { \ - optstr, type, hide, \ + (char *) optstr, type, hide, \ .u.perf = { PERF_TYPE_SOFTWARE, PERF_COUNT_SW_##name, },\ } #define _PERF_HW_CACHE(optstr, name, type, op, result, hide) \ { \ - optstr, type, hide, \ + (char *) optstr, type, hide, \ .u.perf = { \ PERF_TYPE_HW_CACHE, \ (uint64_t) PERF_COUNT_HW_CACHE_##name \ @@ -235,45 +235,49 @@ const struct ctx_opts { } app_ctx; } u; } ctx_opts[] = { - { "pid", CONTEXT_PID }, - { "procname", CONTEXT_PROCNAME }, - { "prio", CONTEXT_PRIO }, - { "nice", CONTEXT_NICE }, - { "vpid", CONTEXT_VPID }, - { "tid", CONTEXT_TID }, - { "pthread_id", CONTEXT_PTHREAD_ID }, - { "vtid", CONTEXT_VTID }, - { "ppid", CONTEXT_PPID }, - { "vppid", CONTEXT_VPPID }, - { "hostname", CONTEXT_HOSTNAME }, - { "ip", CONTEXT_IP }, - { "interruptible", CONTEXT_INTERRUPTIBLE }, - { "preemptible", CONTEXT_PREEMPTIBLE }, - { "need_reschedule", CONTEXT_NEED_RESCHEDULE }, - { "migratable", CONTEXT_MIGRATABLE }, - { "callstack-kernel", CONTEXT_CALLSTACK_KERNEL }, + /* + * These (char *) casts (as well as those in the PERF_* macros) are + * safe because we never free these instances of `struct ctx_opts`. + */ + { (char *) "pid", CONTEXT_PID }, + { (char *) "procname", CONTEXT_PROCNAME }, + { (char *) "prio", CONTEXT_PRIO }, + { (char *) "nice", CONTEXT_NICE }, + { (char *) "vpid", CONTEXT_VPID }, + { (char *) "tid", CONTEXT_TID }, + { (char *) "pthread_id", CONTEXT_PTHREAD_ID }, + { (char *) "vtid", CONTEXT_VTID }, + { (char *) "ppid", CONTEXT_PPID }, + { (char *) "vppid", CONTEXT_VPPID }, + { (char *) "hostname", CONTEXT_HOSTNAME }, + { (char *) "ip", CONTEXT_IP }, + { (char *) "interruptible", CONTEXT_INTERRUPTIBLE }, + { (char *) "preemptible", CONTEXT_PREEMPTIBLE }, + { (char *) "need_reschedule", CONTEXT_NEED_RESCHEDULE }, + { (char *) "migratable", CONTEXT_MIGRATABLE }, + { (char *) "callstack-kernel", CONTEXT_CALLSTACK_KERNEL }, #if HAVE_MODULES_USERSPACE_CALLSTACK_CONTEXT - { "callstack-user", CONTEXT_CALLSTACK_USER }, + { (char *) "callstack-user", CONTEXT_CALLSTACK_USER }, #endif - { "cgroup_ns", CONTEXT_CGROUP_NS }, - { "ipc_ns", CONTEXT_IPC_NS }, - { "mnt_ns", CONTEXT_MNT_NS }, - { "net_ns", CONTEXT_NET_NS }, - { "pid_ns", CONTEXT_PID_NS }, - { "user_ns", CONTEXT_USER_NS }, - { "uts_ns", CONTEXT_UTS_NS }, - { "uid", CONTEXT_UID }, - { "euid", CONTEXT_EUID }, - { "suid", CONTEXT_SUID }, - { "gid", CONTEXT_GID }, - { "egid", CONTEXT_EGID }, - { "sgid", CONTEXT_SGID }, - { "vuid", CONTEXT_VUID }, - { "veuid", CONTEXT_VEUID }, - { "vsuid", CONTEXT_VSUID }, - { "vgid", CONTEXT_VGID }, - { "vegid", CONTEXT_VEGID }, - { "vsgid", CONTEXT_VSGID }, + { (char *) "cgroup_ns", CONTEXT_CGROUP_NS }, + { (char *) "ipc_ns", CONTEXT_IPC_NS }, + { (char *) "mnt_ns", CONTEXT_MNT_NS }, + { (char *) "net_ns", CONTEXT_NET_NS }, + { (char *) "pid_ns", CONTEXT_PID_NS }, + { (char *) "user_ns", CONTEXT_USER_NS }, + { (char *) "uts_ns", CONTEXT_UTS_NS }, + { (char *) "uid", CONTEXT_UID }, + { (char *) "euid", CONTEXT_EUID }, + { (char *) "suid", CONTEXT_SUID }, + { (char *) "gid", CONTEXT_GID }, + { (char *) "egid", CONTEXT_EGID }, + { (char *) "sgid", CONTEXT_SGID }, + { (char *) "vuid", CONTEXT_VUID }, + { (char *) "veuid", CONTEXT_VEUID }, + { (char *) "vsuid", CONTEXT_VSUID }, + { (char *) "vgid", CONTEXT_VGID }, + { (char *) "vegid", CONTEXT_VEGID }, + { (char *) "vsgid", CONTEXT_VSGID }, /* Perf options */ diff --git a/src/bin/lttng/commands/create.c b/src/bin/lttng/commands/create.c index 406bfb62a..379ca0a66 100644 --- a/src/bin/lttng/commands/create.c +++ b/src/bin/lttng/commands/create.c @@ -501,7 +501,7 @@ error: * * Spawn a session daemon by forking and execv. */ -static int spawn_sessiond(char *pathname) +static int spawn_sessiond(const char *pathname) { int ret = 0; pid_t pid; @@ -580,7 +580,7 @@ end: static int launch_sessiond(void) { int ret; - char *pathname = NULL; + const char *pathname = NULL; ret = lttng_session_daemon_alive(); if (ret) { diff --git a/src/bin/lttng/commands/disable_events.c b/src/bin/lttng/commands/disable_events.c index 9909fec39..501c3cf3a 100644 --- a/src/bin/lttng/commands/disable_events.c +++ b/src/bin/lttng/commands/disable_events.c @@ -106,7 +106,7 @@ const char *print_event_type(const enum lttng_event_type ev_type) * enabled is 0 or 1 * success is 0 or 1 */ -static int mi_print_event(char *event_name, int enabled, int success) +static int mi_print_event(const char *event_name, int enabled, int success) { int ret; diff --git a/src/bin/lttng/commands/track-untrack.c b/src/bin/lttng/commands/track-untrack.c index 06fd528ab..c674faefa 100644 --- a/src/bin/lttng/commands/track-untrack.c +++ b/src/bin/lttng/commands/track-untrack.c @@ -451,7 +451,7 @@ static enum cmd_error_code track_untrack_id(enum cmd_type cmd_type, ret = cmd_func(handle, tracker_type, item); if (ret) { - char *msg = NULL; + const char *msg = NULL; switch (-ret) { case LTTNG_ERR_ID_TRACKED: diff --git a/src/bin/lttng/commands/view.c b/src/bin/lttng/commands/view.c index 0dd1623ea..b9f3553b3 100644 --- a/src/bin/lttng/commands/view.c +++ b/src/bin/lttng/commands/view.c @@ -180,8 +180,8 @@ static char **alloc_argv_from_local_opts(const char **opts, size_t opts_len, memcpy(argv, opts, sizeof(char *) * opts_len); if (session_live_mode) { - argv[opts_len] = "-i"; - argv[opts_len + 1] = "lttng-live"; + argv[opts_len] = (char *) "-i"; + argv[opts_len + 1] = (char *) "lttng-live"; argv[opts_len + 2] = (char *) trace_path; argv[opts_len + 3] = NULL; } else { diff --git a/src/bin/lttng/conf.c b/src/bin/lttng/conf.c index 9e1773bb4..8e703b058 100644 --- a/src/bin/lttng/conf.c +++ b/src/bin/lttng/conf.c @@ -266,7 +266,7 @@ char *config_read_session_name_quiet(const char *path) int config_add_session_name(const char *path, const char *name) { int ret; - char *attr = "session="; + const char *attr = "session="; /* Max name len accepted plus attribute's len and the NULL byte. */ char session_name[NAME_MAX + strlen(attr) + 1]; diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 84dc3a748..4907a43ba 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -33,7 +33,7 @@ NULL ; /* Variables */ -static char *progname; +static const char *progname; int opt_no_sessiond; char *opt_sessiond_path; diff --git a/src/common/lttng-elf.c b/src/common/lttng-elf.c index 816dd0d76..bef20ffd4 100644 --- a/src/common/lttng-elf.c +++ b/src/common/lttng-elf.c @@ -750,7 +750,7 @@ int lttng_elf_get_symbol_offset(int fd, char *symbol, uint64_t *offset) char *curr_sym_str = NULL; char *symbol_table_data = NULL; char *string_table_data = NULL; - char *string_table_name = NULL; + const char *string_table_name = NULL; struct lttng_elf_shdr symtab_hdr; struct lttng_elf_shdr strtab_hdr; struct lttng_elf *elf = NULL; diff --git a/src/common/relayd/relayd.c b/src/common/relayd/relayd.c index 7b11c81f6..dfcb337a0 100644 --- a/src/common/relayd/relayd.c +++ b/src/common/relayd/relayd.c @@ -499,7 +499,7 @@ int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_nam int ret; struct lttcomm_relayd_status_stream reply; char pathname[RELAYD_COMM_LTTNG_PATH_MAX]; - char *separator; + const char *separator; /* Code flow error. Safety net. */ assert(rsock); diff --git a/src/lib/lttng-ctl/filter/filter-ast.h b/src/lib/lttng-ctl/filter/filter-ast.h index fd322df3f..926d8dd64 100644 --- a/src/lib/lttng-ctl/filter/filter-ast.h +++ b/src/lib/lttng-ctl/filter/filter-ast.h @@ -115,10 +115,10 @@ struct filter_node { enum ast_link_type post_op; /* reverse */ enum ast_link_type pre_op; /* forward */ union { - char *string; + const char *string; uint64_t constant; double float_constant; - char *identifier; + const char *identifier; /* * child can be nested. */ diff --git a/src/lib/lttng-ctl/filter/filter-visitor-generate-ir.c b/src/lib/lttng-ctl/filter/filter-visitor-generate-ir.c index 024aac639..11c6b610c 100644 --- a/src/lib/lttng-ctl/filter/filter-visitor-generate-ir.c +++ b/src/lib/lttng-ctl/filter/filter-visitor-generate-ir.c @@ -77,7 +77,7 @@ enum ir_load_string_type get_literal_string_type(const char *string) } static -struct ir_op *make_op_load_string(char *string, enum ir_side side) +struct ir_op *make_op_load_string(const char *string, enum ir_side side) { struct ir_op *op; @@ -187,7 +187,7 @@ struct ir_load_expression *create_load_expression(struct filter_node *node) { struct ir_load_expression *load_exp; struct ir_load_expression_op *load_exp_op, *prev_op; - char *str; + const char *str; /* Get forward chain. */ node = load_expression_get_forward_chain(node); diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 4e4912073..32ca4b267 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -896,7 +896,7 @@ static char *set_agent_filter(const char *filter, struct lttng_event *ev) /* Add loglevel filtering if any for the JUL domain. */ if (ev->loglevel_type != LTTNG_EVENT_LOGLEVEL_ALL) { - char *op; + const char *op; if (ev->loglevel_type == LTTNG_EVENT_LOGLEVEL_RANGE) { op = ">="; diff --git a/tests/regression/tools/live/live_test.c b/tests/regression/tools/live/live_test.c index d5da03e4d..bfbd842c0 100644 --- a/tests/regression/tools/live/live_test.c +++ b/tests/regression/tools/live/live_test.c @@ -97,7 +97,7 @@ ssize_t lttng_live_send(int fd, const void *buf, size_t len) } static -int connect_viewer(char *hostname) +int connect_viewer(const char *hostname) { struct hostent *host; struct sockaddr_in server_addr; diff --git a/tests/regression/ust/fork/fork.c b/tests/regression/ust/fork/fork.c index 55c9d49bc..7030a293d 100644 --- a/tests/regression/ust/fork/fork.c +++ b/tests/regression/ust/fork/fork.c @@ -34,7 +34,7 @@ int main(int argc, char **argv, char *env[]) return 1; } if (result == 0) { - char *args[] = { "fork2", NULL }; + char *args[] = { (char *) "fork2", NULL }; tracepoint(ust_tests_fork, after_fork_child, getpid()); diff --git a/tests/regression/ust/low-throughput/tp.h b/tests/regression/ust/low-throughput/tp.h index 3fa8c9a2d..3ec3c40c1 100644 --- a/tests/regression/ust/low-throughput/tp.h +++ b/tests/regression/ust/low-throughput/tp.h @@ -14,7 +14,7 @@ #include TRACEPOINT_EVENT(tp, slow, - TP_ARGS(unsigned int, c, char *, thread_name), + TP_ARGS(unsigned int, c, const char *, thread_name), TP_FIELDS( ctf_integer(unsigned int, counter, c) ctf_string(th_name, thread_name) diff --git a/tests/unit/test_relayd_backward_compat_group_by_session.c b/tests/unit/test_relayd_backward_compat_group_by_session.c index c5c9f1b98..d068372fa 100644 --- a/tests/unit/test_relayd_backward_compat_group_by_session.c +++ b/tests/unit/test_relayd_backward_compat_group_by_session.c @@ -18,12 +18,12 @@ #define NUM_TESTS_PER_TEST 1 struct test { - char *stream_path; - char *session_name; - char *hostname; - char *creation_time; - char *extra_path; - char *leftover; + const char *stream_path; + const char *session_name; + const char *hostname; + const char *creation_time; + const char *extra_path; + const char *leftover; bool is_valid; }; diff --git a/tests/unit/test_session.c b/tests/unit/test_session.c index 94e93cd80..2103a8f46 100644 --- a/tests/unit/test_session.c +++ b/tests/unit/test_session.c @@ -66,7 +66,7 @@ static char *get_random_string(void) /* * Return 0 if session name is found, else -1 */ -static int find_session_name(char *name) +static int find_session_name(const char *name) { struct ltt_session *iter; @@ -110,7 +110,7 @@ static void empty_session_list(void) /* * Test creation of 1 session */ -static int create_one_session(char *name) +static int create_one_session(const char *name) { int ret; enum lttng_error_code ret_code; diff --git a/tests/unit/test_utils_expand_path.c b/tests/unit/test_utils_expand_path.c index e6f5e0c8b..d7e7f2b05 100644 --- a/tests/unit/test_utils_expand_path.c +++ b/tests/unit/test_utils_expand_path.c @@ -25,19 +25,19 @@ int lttng_opt_verbose = 3; int lttng_opt_mi; struct valid_test_input { - char *input; - char *relative_part; - char *absolute_part; + const char *input; + const char *relative_part; + const char *absolute_part; }; struct tree_symlink { - char *orig; - char *dest; + const char *orig; + const char *dest; }; struct symlink_test_input { - char *input; - char *expected_result; + const char *input; + const char *expected_result; }; /* Valid test cases */ diff --git a/tests/unit/test_utils_parse_size_suffix.c b/tests/unit/test_utils_parse_size_suffix.c index 27dbf2c9a..4340a69ec 100644 --- a/tests/unit/test_utils_parse_size_suffix.c +++ b/tests/unit/test_utils_parse_size_suffix.c @@ -19,7 +19,7 @@ int lttng_opt_verbose = 3; int lttng_opt_mi; struct valid_test_input { - char *input; + const char *input; uint64_t expected_result; }; @@ -69,7 +69,7 @@ static struct valid_test_input valid_tests_inputs[] = { static const int num_valid_tests = sizeof(valid_tests_inputs) / sizeof(valid_tests_inputs[0]); /* Invalid test cases */ -static char *invalid_tests_inputs[] = { +static const char *invalid_tests_inputs[] = { "", " ", "-1", diff --git a/tests/unit/test_utils_parse_time_suffix.c b/tests/unit/test_utils_parse_time_suffix.c index 09708edd0..6a1c3280b 100644 --- a/tests/unit/test_utils_parse_time_suffix.c +++ b/tests/unit/test_utils_parse_time_suffix.c @@ -20,7 +20,7 @@ int lttng_opt_verbose = 3; int lttng_opt_mi; struct valid_test_input { - char *input; + const char *input; uint64_t expected_result; }; @@ -56,7 +56,7 @@ static struct valid_test_input valid_tests_inputs[] = { static const int num_valid_tests = sizeof(valid_tests_inputs) / sizeof(valid_tests_inputs[0]); /* Invalid test cases */ -static char *invalid_tests_inputs[] = { +static const char *invalid_tests_inputs[] = { "", " ", "-1", diff --git a/tests/utils/tap/tap.c b/tests/utils/tap/tap.c index 9c967f82d..7395f6fc5 100644 --- a/tests/utils/tap/tap.c +++ b/tests/utils/tap/tap.c @@ -40,7 +40,7 @@ static unsigned int test_count = 0; /* Number of tests that have been run */ static unsigned int e_tests = 0; /* Expected number of tests to run */ static unsigned int failures = 0; /* Number of tests that failed */ static char *todo_msg = NULL; -static char *todo_msg_fixed = "libtap malloc issue"; +static const char *todo_msg_fixed = "libtap malloc issue"; static int todo = 0; static int test_died = 0; @@ -68,8 +68,8 @@ static void _cleanup(void); * test_comment -- a comment to print afterwards, may be NULL */ unsigned int -_gen_result(int ok, const char *func, char *file, unsigned int line, - char *test_name, ...) +_gen_result(int ok, const char *func, const char *file, unsigned int line, + const char *test_name, ...) { va_list ap; char *local_test_name = NULL; @@ -270,7 +270,7 @@ plan_tests(unsigned int tests) } unsigned int -diag(char *fmt, ...) +diag(const char *fmt, ...) { va_list ap; @@ -294,7 +294,7 @@ _expected_tests(unsigned int tests) } int -skip(unsigned int n, char *fmt, ...) +skip(unsigned int n, const char *fmt, ...) { va_list ap; char *skip_msg = NULL; diff --git a/tests/utils/tap/tap.h b/tests/utils/tap/tap.h index 045499a98..ab9aad1aa 100644 --- a/tests/utils/tap/tap.h +++ b/tests/utils/tap/tap.h @@ -75,15 +75,15 @@ #define skip_end() } while(0); -unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...); +unsigned int _gen_result(int, const char *, const char *, unsigned int, const char *, ...); int plan_no_plan(void); int plan_skip_all(char *); int plan_tests(unsigned int); -unsigned int diag(char *, ...); +unsigned int diag(const char *, ...); -int skip(unsigned int, char *, ...); +int skip(unsigned int, const char *, ...); void todo_start(char *, ...); void todo_end(void);