projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix memory leak in get random string
[lttng-tools.git]
/
tests
/
test_ust_data_trace.c
diff --git
a/tests/test_ust_data_trace.c
b/tests/test_ust_data_trace.c
index 78a31215f77b1dd14bbb871a71b7a5bd9a83334e..924cfe4b97f1fde75af52f075969280072eab932 100644
(file)
--- a/
tests/test_ust_data_trace.c
+++ b/
tests/test_ust_data_trace.c
@@
-35,6
+35,8
@@
/* This path will NEVER be created in this test */
#define PATH1 "/tmp/.test-junk-lttng"
/* This path will NEVER be created in this test */
#define PATH1 "/tmp/.test-junk-lttng"
+#define RANDOM_STRING_LEN 11
+
/* For lttngerr.h */
int opt_quiet = 1;
int opt_verbose = 0;
/* For lttngerr.h */
int opt_quiet = 1;
int opt_verbose = 0;
@@
-43,25
+45,26
@@
static const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
+static char random_string[RANDOM_STRING_LEN];
static struct ltt_ust_session *usess;
static struct lttng_domain dom;
/*
* Return random string of 10 characters.
static struct ltt_ust_session *usess;
static struct lttng_domain dom;
/*
* Return random string of 10 characters.
+ * Not thread-safe.
*/
static char *get_random_string(void)
{
int i;
*/
static char *get_random_string(void)
{
int i;
- char *str = malloc(11);
- for (i = 0; i <
10
; i++) {
-
str
[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+ for (i = 0; i <
RANDOM_STRING_LEN - 1
; i++) {
+
random_string
[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
}
}
-
str[10
] = '\0';
+
random_string[RANDOM_STRING_LEN - 1
] = '\0';
- return
str
;
+ return
random_string
;
}
static void create_one_ust_session(void)
}
static void create_one_ust_session(void)
@@
-122,6
+125,8
@@
static void create_ust_channel(void)
struct ltt_ust_channel *uchan;
struct lttng_channel attr;
struct ltt_ust_channel *uchan;
struct lttng_channel attr;
+ memset(&attr, 0, sizeof(attr));
+
strncpy(attr.name, "channel0", 8);
printf("Creating UST channel: ");
strncpy(attr.name, "channel0", 8);
printf("Creating UST channel: ");
@@
-147,8
+152,10
@@
static void create_ust_event(void)
struct ltt_ust_event *event;
struct lttng_event ev;
struct ltt_ust_event *event;
struct lttng_event ev;
+ memset(&ev, 0, sizeof(ev));
strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
ev.type = LTTNG_EVENT_TRACEPOINT;
strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
ev.type = LTTNG_EVENT_TRACEPOINT;
+ ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
printf("Creating UST event: ");
event = trace_ust_create_event(&ev);
printf("Creating UST event: ");
event = trace_ust_create_event(&ev);
@@
-168,16
+175,18
@@
static void create_ust_event(void)
static void create_ust_context(void)
{
static void create_ust_context(void)
{
- struct lttng_event_context ctx;
+ struct lttng_event_context
e
ctx;
struct ltt_ust_context *uctx;
struct ltt_ust_context *uctx;
+ ectx.ctx = LTTNG_EVENT_CONTEXT_VTID;
+
printf("Creating UST context: ");
printf("Creating UST context: ");
- uctx = trace_ust_create_context(&ctx);
+ uctx = trace_ust_create_context(&
e
ctx);
assert(uctx != NULL);
PRINT_OK();
printf("Validating UST context: ");
assert(uctx != NULL);
PRINT_OK();
printf("Validating UST context: ");
- assert((int)
ctx.ctx == (int)uctx->ctx.ctx
);
+ assert((int)
uctx->ctx.ctx == LTTNG_UST_CONTEXT_VTID
);
PRINT_OK();
}
PRINT_OK();
}
This page took
0.027759 seconds
and
5
git commands to generate.