Cleanup: remove superfluous empty line
[lttng-tools.git] / src / common / runas.c
index 3916d6754314eadd4947b576dbcb4d98273ad861..4bd356a0499f2119a227a69b324ab5248d7ba8a0 100644 (file)
@@ -402,11 +402,14 @@ int send_fd_to_master(struct run_as_worker *worker, enum run_as_cmd cmd, int fd)
                ret = -1;
        }
 
+       if (fd < 0) {
+               goto end;
+       }
        ret_close = close(fd);
        if (ret_close < 0) {
                PERROR("close");
        }
-
+end:
        return ret;
 }
 
@@ -466,6 +469,9 @@ int cleanup_received_fd(enum run_as_cmd cmd, int fd)
                return 0;
        }
 
+       if (fd < 0) {
+               return 0;
+       }
        ret = close(fd);
        if (ret < 0) {
                PERROR("close error");
@@ -488,6 +494,9 @@ int handle_one_cmd(struct run_as_worker *worker)
        run_as_fct cmd;
        uid_t prev_euid;
 
+       memset(&sendret, 0, sizeof(sendret));
+       sendret.fd = -1;
+
        /*
         * Stage 1: Receive run_as_data struct from the master.
         * The structure contains the command type and all the parameters needed for
@@ -528,6 +537,8 @@ int handle_one_cmd(struct run_as_worker *worker)
        if (data.gid != getegid()) {
                ret = setegid(data.gid);
                if (ret < 0) {
+                       sendret._error = true;
+                       sendret._errno = errno;
                        PERROR("setegid");
                        goto write_return;
                }
@@ -535,6 +546,8 @@ int handle_one_cmd(struct run_as_worker *worker)
        if (data.uid != prev_euid) {
                ret = seteuid(data.uid);
                if (ret < 0) {
+                       sendret._error = true;
+                       sendret._errno = errno;
                        PERROR("seteuid");
                        goto write_return;
                }
@@ -710,6 +723,7 @@ int run_as_cmd(struct run_as_worker *worker,
                PERROR("Error reading response from run_as");
                ret = -1;
                ret_value->_errno = errno;
+               goto end;
        }
 
        /*
@@ -798,7 +812,6 @@ int run_as(enum run_as_cmd cmd, struct run_as_data *data,
                        DBG("Socket closed unexpectedly... "
                                        "Restarting the worker process");
                        ret = run_as_restart_worker(global_worker);
-
                        if (ret == -1) {
                                ERR("Failed to restart worker process.");
                                goto err;
@@ -914,6 +927,9 @@ int run_as_extract_elf_symbol_offset(int fd, const char* function,
        struct run_as_data data;
        struct run_as_ret ret;
 
+       memset(&data, 0, sizeof(data));
+       memset(&ret, 0, sizeof(ret));
+
        DBG3("extract_elf_symbol_offset() on fd=%d and function=%s "
                "with for uid %d and gid %d", fd, function, (int) uid, (int) gid);
 
@@ -943,6 +959,9 @@ int run_as_extract_sdt_probe_offsets(int fd, const char* provider_name,
        struct run_as_data data;
        struct run_as_ret ret;
 
+       memset(&data, 0, sizeof(data));
+       memset(&ret, 0, sizeof(ret));
+
        DBG3("extract_sdt_probe_offsets() on fd=%d, probe_name=%s and "
                "provider_name=%s with for uid %d and gid %d", fd, probe_name,
                provider_name, (int) uid, (int) gid);
This page took 0.024109 seconds and 4 git commands to generate.