X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Ftest_sessions.c;h=3e876c88990c15cc1dbb14a9a98be1bfea202ceb;hb=f973f94b67543ecb538591ee791c9183c739ef40;hp=5b17e63911eeb8c45fdd05723978d79eae209313;hpb=bcf480b0bf3570a23ed61207c7d8987e0c9f64cb;p=lttng-tools.git diff --git a/tests/test_sessions.c b/tests/test_sessions.c index 5b17e6391..3e876c889 100644 --- a/tests/test_sessions.c +++ b/tests/test_sessions.c @@ -26,9 +26,9 @@ #include #include -#include +#include +#include -#include #include "utils.h" #define SESSION1 "test1" @@ -37,6 +37,7 @@ #define PATH1 "/tmp/.test-junk-lttng" #define MAX_SESSIONS 10000 +#define RANDOM_STRING_LEN 11 /* * String of 263 caracters. NAME_MAX + "OVERFLOW". If OVERFLOW appears in the @@ -61,22 +62,23 @@ static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; +static char random_string[RANDOM_STRING_LEN]; /* * Return random string of 10 characters. + * Not thread-safe. */ 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; } /*