#define PROC_MEMINFO_MEMAVAILABLE_LINE "MemAvailable:"
#define PROC_MEMINFO_MEMTOTAL_LINE "MemTotal:"
-/* The length of the longest field of `/proc/meminfo`. */
+/* The lnullptrh of the longest field of `/proc/meminfo`. */
#define PROC_MEMINFO_FIELD_MAX_NAME_LEN 20
#if (PROC_MEMINFO_FIELD_MAX_NAME_LEN == 20)
{
int ret;
- if (dst == NULL) {
+ if (dst == nullptr) {
return -1;
}
{
int ret, i;
- if (dst == NULL) {
+ if (dst == nullptr) {
return -1;
}
{
int ret, i;
- if (dst == NULL) {
+ if (dst == nullptr) {
return -1;
}
{
int i, ret;
- if (src == NULL) {
+ if (src == nullptr) {
return;
}
{
char *str = zmalloc<char>(end - begin + 1);
- if (str == NULL) {
+ if (str == nullptr) {
PERROR("zmalloc strdupdelim");
goto error;
}
int utils_create_pid_file(pid_t pid, const char *filepath)
{
int ret, fd = -1;
- FILE *fp = NULL;
+ FILE *fp = nullptr;
LTTNG_ASSERT(filepath);
}
fp = fdopen(fd, "w");
- if (fp == NULL) {
+ if (fp == nullptr) {
PERROR("fdopen file %s", filepath);
ret = -1;
if (close(fd)) {
.gid = LTTNG_OPTIONAL_INIT_VALUE((gid_t) gid),
};
- handle = lttng_directory_handle_create(NULL);
+ handle = lttng_directory_handle_create(nullptr);
if (!handle) {
ret = -1;
goto end;
}
ret = lttng_directory_handle_create_subdirectory_as_user(
- handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : NULL);
+ handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : nullptr);
end:
lttng_directory_handle_put(handle);
return ret;
.gid = LTTNG_OPTIONAL_INIT_VALUE((gid_t) gid),
};
- handle = lttng_directory_handle_create(NULL);
+ handle = lttng_directory_handle_create(nullptr);
if (!handle) {
ret = -1;
goto end;
}
ret = lttng_directory_handle_create_subdirectory_recursive_as_user(
- handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : NULL);
+ handle, path, mode, (uid >= 0 || gid >= 0) ? &creds : nullptr);
end:
lttng_directory_handle_put(handle);
return ret;
}
/* strtoull will accept a negative number, but we don't want to. */
- if (strchr(str, '-') != NULL) {
+ if (strchr(str, '-') != nullptr) {
DBG("utils_parse_size_suffix: invalid size string, should not contain '-'.");
ret = -1;
goto end;
}
/* strtoull will accept a negative number, but we don't want to. */
- if (strchr(str, '-') != NULL) {
+ if (strchr(str, '-') != nullptr) {
DBG("utils_parse_time_suffix: invalid time string, should not contain '-'.");
ret = -1;
goto end;
* Obtain the value of LTTNG_HOME environment variable, if exists.
* Otherwise returns the value of HOME.
*/
-const char *utils_get_home_dir(void)
+const char *utils_get_home_dir()
{
- char *val = NULL;
+ char *val = nullptr;
struct passwd *pwd;
val = lttng_secure_getenv(DEFAULT_LTTNG_HOME_ENV_VAR);
- if (val != NULL) {
+ if (val != nullptr) {
goto end;
}
val = lttng_secure_getenv(DEFAULT_LTTNG_FALLBACK_HOME_ENV_VAR);
- if (val != NULL) {
+ if (val != nullptr) {
goto end;
}
{
struct passwd pwd;
struct passwd *result;
- char *home_dir = NULL;
- char *buf = NULL;
+ char *home_dir = nullptr;
+ char *buf = nullptr;
long buflen;
int ret;
int ret;
struct lttng_directory_handle *handle;
- handle = lttng_directory_handle_create(NULL);
+ handle = lttng_directory_handle_create(nullptr);
if (!handle) {
ret = -1;
goto end;
return ret;
}
-static const char *get_man_bin_path(void)
+static const char *get_man_bin_path()
{
char *env_man_path = lttng_secure_getenv(DEFAULT_MAN_BIN_PATH_ENV);
}
/* Section integer -> section string */
- ret = sprintf(section_string, "%d", section);
+ ret = snprintf(section_string, sizeof(section_string), "%d", section);
LTTNG_ASSERT(ret > 0 && ret < 8);
/*
struct passwd p, *pres;
int ret;
enum lttng_error_code ret_val = LTTNG_OK;
- char *buf = NULL;
+ char *buf = nullptr;
ssize_t buflen;
buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
switch (ret) {
case 0:
- if (pres == NULL) {
+ if (pres == nullptr) {
ret_val = LTTNG_ERR_USER_NOT_FOUND;
} else {
*uid = p.pw_uid;
struct group g, *gres;
int ret;
enum lttng_error_code ret_val = LTTNG_OK;
- char *buf = NULL;
+ char *buf = nullptr;
ssize_t buflen;
buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
switch (ret) {
case 0:
- if (gres == NULL) {
+ if (gres == nullptr) {
ret_val = LTTNG_ERR_GROUP_NOT_FOUND;
} else {
*gid = g.gr_gid;