X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=lttng%2Futils.c;h=ee0e297b16c80414c8d9a9a954f82aff8637036c;hb=d063d7094016bcc1f2405651f59530f502bc83e6;hp=2cb77568e339433062408f8c69a8f3fac072fd98;hpb=58a97671d5fa65f93126798ded9e5306e3555186;p=lttng-tools.git diff --git a/lttng/utils.c b/lttng/utils.c index 2cb77568e..ee0e297b1 100644 --- a/lttng/utils.c +++ b/lttng/utils.c @@ -1,10 +1,10 @@ /* * Copyright (c) 2011 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; only version 2 + * of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -58,18 +58,19 @@ int set_session_name(char *name) int ret; char *session_name; - if (name != NULL) { - session_name = name; - } else { + if (!name) { session_name = get_session_name(); if (session_name == NULL) { ret = -1; goto error; } + } else { + session_name = name; } lttng_set_session_name(session_name); - free(session_name); + if (!name) + free(session_name); ret = 0;