Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / src / common / runas.cpp
index d253ee0544e5317183b1a01becfc87a11cbd5ed5..07d9e171f0a0cf941c78cec5c928af2da9158469 100644 (file)
@@ -177,30 +177,31 @@ struct run_as_ret {
        bool _error;
 } LTTNG_PACKED;
 
-#define COMMAND_IN_FDS(data_ptr)                                                         \
-       ({                                                                               \
-               int *fds = NULL;                                                         \
-               if (command_properties[data_ptr->cmd].in_fds_offset != -1) {             \
-                       fds = (int *) ((char *) data_ptr +                               \
-                                      command_properties[data_ptr->cmd].in_fds_offset); \
-               }                                                                        \
-               fds;                                                                     \
+#define COMMAND_IN_FDS(data_ptr)                                                           \
+       ({                                                                                 \
+               int *fds = NULL;                                                           \
+               if (command_properties[(data_ptr)->cmd].in_fds_offset != -1) {             \
+                       fds = (int *) ((char *) (data_ptr) +                               \
+                                      command_properties[(data_ptr)->cmd].in_fds_offset); \
+               }                                                                          \
+               fds;                                                                       \
        })
 
-#define COMMAND_OUT_FDS(cmd, ret_ptr)                                                              \
-       ({                                                                                         \
-               int *fds = NULL;                                                                   \
-               if (command_properties[cmd].out_fds_offset != -1) {                                \
-                       fds = (int *) ((char *) ret_ptr + command_properties[cmd].out_fds_offset); \
-               }                                                                                  \
-               fds;                                                                               \
+#define COMMAND_OUT_FDS(cmd, ret_ptr)                                           \
+       ({                                                                      \
+               int *fds = NULL;                                                \
+               if (command_properties[cmd].out_fds_offset != -1) {             \
+                       fds = (int *) ((char *) (ret_ptr) +                     \
+                                      command_properties[cmd].out_fds_offset); \
+               }                                                               \
+               fds;                                                            \
        })
 
-#define COMMAND_IN_FD_COUNT(data_ptr) ({ command_properties[data_ptr->cmd].in_fd_count; })
+#define COMMAND_IN_FD_COUNT(data_ptr) ({ command_properties[(data_ptr)->cmd].in_fd_count; })
 
 #define COMMAND_OUT_FD_COUNT(cmd) ({ command_properties[cmd].out_fd_count; })
 
-#define COMMAND_USE_CWD_FD(data_ptr) command_properties[data_ptr->cmd].use_cwd_fd
+#define COMMAND_USE_CWD_FD(data_ptr) command_properties[(data_ptr)->cmd].use_cwd_fd
 
 struct run_as_command_properties {
        /* Set to -1 when not applicable. */
@@ -379,7 +380,7 @@ static int _mkdirat_recursive(struct run_as_data *data, struct run_as_ret *ret_v
        /* Safe to call as we have transitioned to the requested uid/gid. */
        ret_value->u.ret = lttng_directory_handle_create_subdirectory_recursive(handle, path, mode);
        ret_value->_errno = errno;
-       ret_value->_error = (ret_value->u.ret) ? true : false;
+       ret_value->_error = (ret_value->u.ret) != 0;
        lttng_directory_handle_put(handle);
 end:
        return ret_value->u.ret;
@@ -406,7 +407,7 @@ static int _mkdirat(struct run_as_data *data, struct run_as_ret *ret_value)
        /* Safe to call as we have transitioned to the requested uid/gid. */
        ret_value->u.ret = lttng_directory_handle_create_subdirectory(handle, path, mode);
        ret_value->_errno = errno;
-       ret_value->_error = (ret_value->u.ret) ? true : false;
+       ret_value->_error = (ret_value->u.ret) != 0;
        lttng_directory_handle_put(handle);
 end:
        return ret_value->u.ret;
@@ -461,7 +462,7 @@ static int _unlink(struct run_as_data *data, struct run_as_ret *ret_value)
 
        ret_value->u.ret = lttng_directory_handle_unlink_file(handle, data->u.unlink.path);
        ret_value->_errno = errno;
-       ret_value->_error = (ret_value->u.ret) ? true : false;
+       ret_value->_error = (ret_value->u.ret) != 0;
        lttng_directory_handle_put(handle);
 end:
        return ret_value->u.ret;
@@ -484,7 +485,7 @@ static int _rmdir(struct run_as_data *data, struct run_as_ret *ret_value)
 
        ret_value->u.ret = lttng_directory_handle_remove_subdirectory(handle, data->u.rmdir.path);
        ret_value->_errno = errno;
-       ret_value->_error = (ret_value->u.ret) ? true : false;
+       ret_value->_error = (ret_value->u.ret) != 0;
        lttng_directory_handle_put(handle);
 end:
        return ret_value->u.ret;
@@ -508,7 +509,7 @@ static int _rmdir_recursive(struct run_as_data *data, struct run_as_ret *ret_val
        ret_value->u.ret = lttng_directory_handle_remove_subdirectory_recursive(
                handle, data->u.rmdir.path, data->u.rmdir.flags);
        ret_value->_errno = errno;
-       ret_value->_error = (ret_value->u.ret) ? true : false;
+       ret_value->_error = (ret_value->u.ret) != 0;
        lttng_directory_handle_put(handle);
 end:
        return ret_value->u.ret;
@@ -543,7 +544,7 @@ end:
        lttng_directory_handle_put(old_handle);
        lttng_directory_handle_put(new_handle);
        ret_value->_errno = errno;
-       ret_value->_error = (ret_value->u.ret) ? true : false;
+       ret_value->_error = (ret_value->u.ret) != 0;
        return ret_value->u.ret;
 }
 
This page took 0.026328 seconds and 4 git commands to generate.