projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: compat poll: add missing empty revents checks
[lttng-tools.git]
/
src
/
common
/
utils.c
diff --git
a/src/common/utils.c
b/src/common/utils.c
index ff6d1c22337200e69e24807b1c871530ce6ea09e..7f91dcb8151ea6ae6083668e78df123f73521758 100644
(file)
--- a/
src/common/utils.c
+++ b/
src/common/utils.c
@@
-18,6
+18,7
@@
*/
#define _GNU_SOURCE
*/
#define _GNU_SOURCE
+#define _LGPL_SOURCE
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
#include <assert.h>
#include <ctype.h>
#include <fcntl.h>
@@
-90,6
+91,10
@@
char *utils_partial_realpath(const char *path, char *resolved_path, size_t size)
/* Cut the part we will be trying to resolve */
cut_path = strndup(path, next - path);
/* Cut the part we will be trying to resolve */
cut_path = strndup(path, next - path);
+ if (cut_path == NULL) {
+ PERROR("strndup");
+ goto error;
+ }
/* Try to resolve this part */
try_path = realpath((char *)cut_path, NULL);
/* Try to resolve this part */
try_path = realpath((char *)cut_path, NULL);
@@
-143,6
+148,10
@@
char *utils_partial_realpath(const char *path, char *resolved_path, size_t size)
* path are pointers for the same memory space
*/
cut_path = strdup(prev);
* path are pointers for the same memory space
*/
cut_path = strdup(prev);
+ if (cut_path == NULL) {
+ PERROR("strdup");
+ goto error;
+ }
/* Concatenate the strings */
snprintf(resolved_path, size, "%s%s", try_path_prev, cut_path);
/* Concatenate the strings */
snprintf(resolved_path, size, "%s%s", try_path_prev, cut_path);
@@
-216,7
+225,10
@@
char *utils_expand_path(const char *path)
/* We prepare the start_path not containing it */
start_path = strndup(absolute_path, next - absolute_path);
/* We prepare the start_path not containing it */
start_path = strndup(absolute_path, next - absolute_path);
-
+ if (!start_path) {
+ PERROR("strndup");
+ goto error;
+ }
/* And we concatenate it with the part after this string */
snprintf(absolute_path, PATH_MAX, "%s%s", start_path, next + 2);
/* And we concatenate it with the part after this string */
snprintf(absolute_path, PATH_MAX, "%s%s", start_path, next + 2);
@@
-233,6
+245,10
@@
char *utils_expand_path(const char *path)
/* Then we prepare the start_path not containing it */
start_path = strndup(absolute_path, previous - absolute_path);
/* Then we prepare the start_path not containing it */
start_path = strndup(absolute_path, previous - absolute_path);
+ if (!start_path) {
+ PERROR("strndup");
+ goto error;
+ }
/* And we concatenate it with the part after the '/../' */
snprintf(absolute_path, PATH_MAX, "%s%s", start_path, next + 4);
/* And we concatenate it with the part after the '/../' */
snprintf(absolute_path, PATH_MAX, "%s%s", start_path, next + 4);
@@
-461,10
+477,14
@@
int utils_create_pid_file(pid_t pid, const char *filepath)
ret = fprintf(fp, "%d\n", pid);
if (ret < 0) {
PERROR("fprintf pid file");
ret = fprintf(fp, "%d\n", pid);
if (ret < 0) {
PERROR("fprintf pid file");
+ goto error;
}
}
- fclose(fp);
+ if (fclose(fp)) {
+ PERROR("fclose");
+ }
DBG("Pid %d written in file %s", pid, filepath);
DBG("Pid %d written in file %s", pid, filepath);
+ ret = 0;
error:
return ret;
}
error:
return ret;
}
@@
-496,9
+516,11
@@
int utils_create_lock_file(const char *filepath)
*/
ret = flock(fd, LOCK_EX | LOCK_NB);
if (ret) {
*/
ret = flock(fd, LOCK_EX | LOCK_NB);
if (ret) {
-
WARN
("Could not get lock file %s, another instance is running.",
+
ERR
("Could not get lock file %s, another instance is running.",
filepath);
filepath);
- close(fd);
+ if (close(fd)) {
+ PERROR("close lock file");
+ }
fd = ret;
goto error;
}
fd = ret;
goto error;
}
@@
-927,7
+949,7
@@
end:
/*
* Obtain the value of LTTNG_KMOD_PROBES environment variable, if exists.
/*
* Obtain the value of LTTNG_KMOD_PROBES environment variable, if exists.
- * Otherwise returns
an empty string
.
+ * Otherwise returns
NULL
.
*/
LTTNG_HIDDEN
char *utils_get_kmod_probes_list(void)
*/
LTTNG_HIDDEN
char *utils_get_kmod_probes_list(void)
@@
-935,6
+957,16
@@
char *utils_get_kmod_probes_list(void)
return getenv(DEFAULT_LTTNG_KMOD_PROBES);
}
return getenv(DEFAULT_LTTNG_KMOD_PROBES);
}
+/*
+ * Obtain the value of LTTNG_EXTRA_KMOD_PROBES environment variable, if
+ * exists. Otherwise returns NULL.
+ */
+LTTNG_HIDDEN
+char *utils_get_extra_kmod_probes_list(void)
+{
+ return getenv(DEFAULT_LTTNG_EXTRA_KMOD_PROBES);
+}
+
/*
* With the given format, fill dst with the time of len maximum siz.
*
/*
* With the given format, fill dst with the time of len maximum siz.
*
This page took
0.026841 seconds
and
4
git commands to generate.