namespace {
struct run_as_data;
struct run_as_ret;
-typedef int (*run_as_fct)(struct run_as_data *data, struct run_as_ret *ret_value);
+using run_as_fct = int (*)(struct run_as_data *, struct run_as_ret *);
struct run_as_mkdir_data {
int dirfd;
return 0;
}
#else
-static int use_clone(void)
+static int use_clone()
{
return !lttng_secure_getenv("LTTNG_DEBUG_NOCLONE");
}
static int _rename(struct run_as_data *data, struct run_as_ret *ret_value)
{
const char *old_path, *new_path;
- struct lttng_directory_handle *old_handle = NULL, *new_handle = NULL;
+ struct lttng_directory_handle *old_handle = nullptr, *new_handle = nullptr;
old_path = data->u.rename.old_path;
new_path = data->u.rename.new_path;
static int _extract_sdt_probe_offsets(struct run_as_data *data, struct run_as_ret *ret_value)
{
int ret = 0;
- uint64_t *offsets = NULL;
+ uint64_t *offsets = nullptr;
uint32_t num_offset;
ret_value->_error = false;
static int _generate_filter_bytecode(struct run_as_data *data, struct run_as_ret *ret_value)
{
int ret = 0;
- const char *filter_expression = NULL;
- struct filter_parser_ctx *ctx = NULL;
+ const char *filter_expression = nullptr;
+ struct filter_parser_ctx *ctx = nullptr;
ret_value->_error = false;
return _generate_filter_bytecode;
default:
ERR("Unknown command %d", (int) cmd);
- return NULL;
+ return nullptr;
}
}
static int get_user_infos_from_uid(uid_t uid, char **username, gid_t *primary_gid)
{
int ret;
- char *buf = NULL;
+ char *buf = nullptr;
long raw_get_pw_buf_size;
size_t get_pw_buf_size;
struct passwd pwd;
- struct passwd *result = NULL;
+ struct passwd *result = nullptr;
/* Fetch the max size for the temporary buffer. */
errno = 0;
get_pw_buf_size = (size_t) raw_get_pw_buf_size;
buf = calloc<char>(get_pw_buf_size);
- if (buf == NULL) {
+ if (buf == nullptr) {
PERROR("Failed to allocate buffer to get password file entries");
goto error;
}
goto error;
}
- if (result == NULL) {
+ if (result == nullptr) {
ERR("Failed to find user information in password entries: uid = %d", (int) uid);
ret = -1;
goto error;
}
*username = strdup(result->pw_name);
- if (*username == NULL) {
+ if (*username == nullptr) {
PERROR("Failed to copy user name");
goto error;
}
free(buf);
return ret;
error:
- *username = NULL;
+ *username = nullptr;
*primary_gid = -1;
ret = -1;
goto end;
{
int ret = 0;
gid_t primary_gid;
- char *username = NULL;
+ char *username = nullptr;
/* Change the group id. */
if (prev_gid != new_gid) {
{
int ret = 0;
gid_t primary_gid;
- char *username = NULL;
+ char *username = nullptr;
/* Change the group id. */
if (prev_gid != new_gid) {
return ret;
}
-static int reset_sighandler(void)
+static int reset_sighandler()
{
int sig;
signame = "SIGTERM";
break;
default:
- signame = NULL;
+ signame = nullptr;
}
if (signame) {
}
}
-static int set_worker_sighandlers(void)
+static int set_worker_sighandlers()
{
int ret = 0;
sigset_t sigset;
sa.sa_handler = worker_sighandler;
sa.sa_mask = sigset;
sa.sa_flags = 0;
- if ((ret = sigaction(SIGINT, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGINT, &sa, nullptr)) < 0) {
PERROR("sigaction SIGINT");
goto end;
}
- if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGTERM, &sa, nullptr)) < 0) {
PERROR("sigaction SIGTERM");
goto end;
}
return ret;
}
-static void run_as_destroy_worker_no_lock(void)
+static void run_as_destroy_worker_no_lock()
{
run_as_worker_data *worker = global_worker;
}
free(worker->procname);
free(worker);
- global_worker = NULL;
+ global_worker = nullptr;
}
static int run_as_restart_worker(run_as_worker_data *worker)
{
int ret = 0;
- char *procname = NULL;
+ char *procname = nullptr;
procname = worker->procname;
run_as_destroy_worker_no_lock();
/* Create a new run_as worker process*/
- ret = run_as_create_worker_no_lock(procname, NULL, NULL);
+ ret = run_as_create_worker_no_lock(procname, nullptr, nullptr);
if (ret < 0) {
ERR("Restarting the worker process failed");
ret = -1;
int ret;
struct run_as_data data = {};
struct run_as_ret run_as_ret = {};
- const struct lttng_bytecode *view_bytecode = NULL;
- struct lttng_bytecode *local_bytecode = NULL;
+ const struct lttng_bytecode *view_bytecode = nullptr;
+ struct lttng_bytecode *local_bytecode = nullptr;
const uid_t uid = lttng_credentials_get_uid(creds);
const gid_t gid = lttng_credentials_get_gid(creds);
return ret;
}
-void run_as_destroy_worker(void)
+void run_as_destroy_worker()
{
pthread_mutex_lock(&worker_lock);
run_as_destroy_worker_no_lock();