From dca8ab254aa0a687c32009079d85e4d8f960b213 Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Thu, 20 Dec 2018 14:58:19 +0100 Subject: Code beautification using uncrustify Signed-off-by: Christoph Lipka --- src/console/logstorage/dlt-logstorage-common.c | 54 ++++------ src/console/logstorage/dlt-logstorage-ctrl.c | 132 +++++++++---------------- src/console/logstorage/dlt-logstorage-list.c | 43 +++----- src/console/logstorage/dlt-logstorage-prop.h | 9 +- src/console/logstorage/dlt-logstorage-udev.c | 93 +++++------------ 5 files changed, 105 insertions(+), 226 deletions(-) (limited to 'src/console/logstorage') diff --git a/src/console/logstorage/dlt-logstorage-common.c b/src/console/logstorage/dlt-logstorage-common.c index ae67c9a..0655d66 100644 --- a/src/console/logstorage/dlt-logstorage-common.c +++ b/src/console/logstorage/dlt-logstorage-common.c @@ -71,7 +71,7 @@ #include "dlt-logstorage-common.h" #ifdef DLT_LOGSTORAGE_CTRL_UDEV_ENABLE -#include "dlt-logstorage-udev.h" +# include "dlt-logstorage-udev.h" #endif #include "dlt-logstorage-prop.h" @@ -96,9 +96,7 @@ void set_handler_type(char *type) g_options.handler_type = CTRL_UDEV; if (type && check_proprietary_handling(type)) - { g_options.handler_type = CTRL_PROPRIETARY; - } } int get_default_event_type(void) @@ -121,9 +119,7 @@ void set_default_path(char *path) memset(g_options.device_path, 0, DLT_MOUNT_PATH_MAX); if (path != NULL) - { strncpy(g_options.device_path, path, DLT_MOUNT_PATH_MAX - 1); - } } /* Used by the handlers */ @@ -150,8 +146,7 @@ int dlt_logstorage_get_handler_fd(void) */ int dlt_logstorage_init_handler(void) { - switch (get_handler_type()) - { + switch (get_handler_type()) { case CTRL_PROPRIETARY: return dlt_logstorage_prop_init(); case CTRL_UDEV: @@ -170,8 +165,7 @@ int dlt_logstorage_init_handler(void) */ int dlt_logstorage_deinit_handler(void) { - switch (get_handler_type()) - { + switch (get_handler_type()) { case CTRL_PROPRIETARY: return dlt_logstorage_prop_deinit(); case CTRL_UDEV: @@ -179,7 +173,7 @@ int dlt_logstorage_deinit_handler(void) #ifdef DLT_LOGSTORAGE_CTRL_UDEV_ENABLE return dlt_logstorage_udev_deinit(); #else - return -1; + return -1; #endif } } @@ -200,8 +194,7 @@ int dlt_logstorage_check_config_file(char *mnt_point) int i = 0; int ret = 0; - if ((mnt_point == NULL) || (mnt_point[0] == '\0')) - { + if ((mnt_point == NULL) || (mnt_point[0] == '\0')) { pr_error("Mount point missing.\n"); return ret; } @@ -210,30 +203,24 @@ int dlt_logstorage_check_config_file(char *mnt_point) n = scandir(mnt_point, &files, NULL, alphasort); - if (n <= 0) - { + if (n <= 0) { pr_error("Cannot read mounted directory\n"); return ret; } - do - { + do { pr_verbose("Checking %s.\n", files[i]->d_name); - if (strncmp(files[i]->d_name, CONF_NAME, strlen(CONF_NAME)) == 0) - { + if (strncmp(files[i]->d_name, CONF_NAME, strlen(CONF_NAME)) == 0) { /* We found it ! */ pr_verbose("File found.\n"); ret = 1; break; } - } - while (++i < n); + } while (++i < n); - for (i = 0 ; i < n ; i++) - { + for (i = 0; i < n; i++) free(files[i]); - } free(files); return ret; @@ -247,16 +234,13 @@ int dlt_logstorage_check_config_file(char *mnt_point) */ int dlt_logstorage_check_directory_permission(char *mnt_point) { - if (mnt_point == NULL) - { + if (mnt_point == NULL) { pr_error("Given mount point is NULL\n"); return 0; } if (access(mnt_point, W_OK) == 0) - { return 1; - } return 0; } @@ -275,8 +259,7 @@ static DltControlMsgBody *prepare_message_body(DltControlMsgBody **body, { DltServiceOfflineLogstorage *serv = NULL; - if (path == NULL) - { + if (path == NULL) { pr_error("Mount path is uninitialized: %s\n", path); return NULL; } @@ -285,16 +268,14 @@ static DltControlMsgBody *prepare_message_body(DltControlMsgBody **body, *body = calloc(1, sizeof(DltControlMsgBody)); - if (!*body) - { + if (!*body) { pr_error("Not able to allocate memory for body.\n"); return *body; } (*body)->data = calloc(1, sizeof(DltServiceOfflineLogstorage)); - if (!(*body)->data) - { + if (!(*body)->data) { free(*body); *body = NULL; pr_error("Not able to allocate memory for body data.\n"); @@ -303,14 +284,14 @@ static DltControlMsgBody *prepare_message_body(DltControlMsgBody **body, (*body)->size = sizeof(DltServiceOfflineLogstorage); - serv = (DltServiceOfflineLogstorage *) (*body)->data; + serv = (DltServiceOfflineLogstorage *)(*body)->data; serv->service_id = DLT_SERVICE_ID_OFFLINE_LOGSTORAGE; serv->connection_type = conn_type; /* mount_point is DLT_MOUNT_PATH_MAX + 1 long, * and the memory is already zeroed. */ - strncpy(serv->mount_point, path, DLT_MOUNT_PATH_MAX-1); + strncpy(serv->mount_point, path, DLT_MOUNT_PATH_MAX - 1); pr_verbose("Body is now ready.\n"); @@ -330,8 +311,7 @@ int dlt_logstorage_send_event(int type, char *mount_point) DltControlMsgBody *msg_body = NULL; /* mount_point is checked against NULL in the preparation */ - if (!prepare_message_body(&msg_body, type, mount_point)) - { + if (!prepare_message_body(&msg_body, type, mount_point)) { pr_error("Data for Dlt Message body is NULL\n"); return -1; } diff --git a/src/console/logstorage/dlt-logstorage-ctrl.c b/src/console/logstorage/dlt-logstorage-ctrl.c index 87e303b..af014eb 100644 --- a/src/console/logstorage/dlt-logstorage-ctrl.c +++ b/src/console/logstorage/dlt-logstorage-ctrl.c @@ -66,7 +66,7 @@ #include #if defined(__linux__) -#include "sd-daemon.h" +# include "sd-daemon.h" #endif #include "dlt_protocol.h" @@ -111,8 +111,7 @@ int dlt_logstorage_must_exit(void) */ static void catch_signal(int signo) { - if (signo) - { + if (signo) { pr_error("Signal %d received, exiting.", signo); dlt_logstorage_exit(); } @@ -132,16 +131,13 @@ static void install_signal_handler(void) pr_verbose("Installing signal handler.\n"); /* install a signal handler for the above listed signals */ - for (i = 0 ; signals[i] ; i++) - { + for (i = 0; signals[i]; i++) { memset(&sa, 0, sizeof(sa)); sa.sa_handler = catch_signal; if (sigaction(signals[i], &sa, NULL) < 0) - { pr_error("Failed to install signal %u handler. Error: %s\n", signals[i], strerror(errno)); - } } } @@ -163,10 +159,8 @@ static int analyze_response(char *data, void *payload, int len) char resp_warning[MAX_RESPONSE_LENGTH] = { 0 }; char resp_perm_denied[MAX_RESPONSE_LENGTH] = { 0 }; - if (data == NULL || payload == NULL) - { + if ((data == NULL) || (payload == NULL)) return -1; - } /* satisfy compiler */ payload = payload; @@ -188,16 +182,14 @@ static int analyze_response(char *data, void *payload, int len) DLT_SERVICE_ID_OFFLINE_LOGSTORAGE); if (strncmp(data, resp_ok, strlen(resp_ok)) == 0) - { ret = 0; - } - if (strncmp(data, resp_warning, strlen(resp_warning)) == 0) - { + + if (strncmp(data, resp_warning, strlen(resp_warning)) == 0) { pr_error("Warning:Some filter configurations are ignored due to configuration issues \n"); ret = 0; } - if (strncmp(data, resp_perm_denied, strlen(resp_perm_denied)) == 0) - { + + if (strncmp(data, resp_perm_denied, strlen(resp_perm_denied)) == 0) { pr_error("Warning: Permission denied.\n"); ret = 0; } @@ -223,8 +215,7 @@ static int dlt_logstorage_ctrl_add_event(struct dlt_event *ev_hdl, int fd, void *cb) { - if ((fd < 0) || !cb || !ev_hdl) - { + if ((fd < 0) || !cb || !ev_hdl) { pr_error("Wrong parameter to add event (%d %p)\n", fd, cb); return -1; } @@ -251,28 +242,20 @@ static int dlt_logstorage_ctrl_execute_event_loop(struct dlt_event *ev) ret = poll(&ev->pfd, 1, POLL_TIME_OUT); - if (ret <= 0) - { + if (ret <= 0) { if (errno == EINTR) - { ret = 0; - } if (ret < 0) - { pr_error("poll error: %s\n", strerror(errno)); - } return ret; } if (ev->pfd.revents == 0) - { return 0; - } - if (ev->pfd.events & EV_MASK_REJECTED) - { + if (ev->pfd.events & EV_MASK_REJECTED) { pr_error("Error while polling. Event received: 0x%x\n", ev->pfd.events); /* We only support one event producer. * Error means that this producer died. @@ -284,8 +267,7 @@ static int dlt_logstorage_ctrl_execute_event_loop(struct dlt_event *ev) return -1; } - if (!callback) - { + if (!callback) { pr_error("Callback not found, exiting.\n"); dlt_logstorage_exit(); return -1; @@ -293,8 +275,7 @@ static int dlt_logstorage_ctrl_execute_event_loop(struct dlt_event *ev) pr_verbose("Got new event, calling %p.\n", callback); - if (callback() < 0) - { + if (callback() < 0) { pr_error("Error while calling the callback, exiting.\n"); dlt_logstorage_exit(); return -1; @@ -327,23 +308,20 @@ static int dlt_logstorage_ctrl_setup_event_loop(void) /* Initializing the communication with the daemon */ while (dlt_control_init(analyze_response, get_ecuid(), get_verbosity()) && - !dlt_logstorage_must_exit()) - { + !dlt_logstorage_must_exit()) { pr_error("Failed to initialize connection with the daemon.\n"); pr_error("Retrying to connect in %lds.\n", get_timeout()); sleep(get_timeout()); } - if (dlt_logstorage_must_exit()) - { + if (dlt_logstorage_must_exit()) { pr_verbose("Exiting.\n"); return 0; } pr_verbose("Initializing event generator.\n"); - if (dlt_logstorage_init_handler() < 0) - { + if (dlt_logstorage_init_handler() < 0) { pr_error("Failed to initialize handler.\n"); dlt_control_deinit(); return -1; @@ -351,16 +329,13 @@ static int dlt_logstorage_ctrl_setup_event_loop(void) if (dlt_logstorage_ctrl_add_event(&ev_hdl, dlt_logstorage_get_handler_fd(), - dlt_logstorage_get_handler_cb()) < 0) - { + dlt_logstorage_get_handler_cb()) < 0) { pr_error("add_event error: %s\n", strerror(errno)); dlt_logstorage_exit(); } while (!dlt_logstorage_must_exit() && (ret == 0)) - { ret = dlt_logstorage_ctrl_execute_event_loop(&ev_hdl); - } /* Clean up */ dlt_logstorage_deinit_handler(); @@ -378,19 +353,16 @@ static int dlt_logstorage_ctrl_single_request() int ret = 0; /* in case sync all caches, an empty path is given */ - if (get_default_event_type() != EVENT_SYNC_CACHE) - { + if (get_default_event_type() != EVENT_SYNC_CACHE) { /* Check if a 'CONF_NAME' file is present at the given path */ - if (!dlt_logstorage_check_config_file(get_default_path())) - { + if (!dlt_logstorage_check_config_file(get_default_path())) { pr_error("No '%s' file available at: %s\n", CONF_NAME, get_default_path()); return -1; } - if (!dlt_logstorage_check_directory_permission(get_default_path())) - { + if (!dlt_logstorage_check_directory_permission(get_default_path())) { pr_error("'%s' is not writable\n", get_default_path()); return -1; } @@ -398,8 +370,7 @@ static int dlt_logstorage_ctrl_single_request() /* Initializing the communication with the daemon */ while (dlt_control_init(analyze_response, get_ecuid(), get_verbosity()) && - !dlt_logstorage_must_exit()) - { + !dlt_logstorage_must_exit()) { pr_error("Failed to initialize connection with the daemon.\n"); pr_error("Retrying to connect in %lds.\n", get_timeout()); sleep(get_timeout()); @@ -441,15 +412,15 @@ static void usage(void) } static struct option long_options[] = { - {"command", required_argument, 0, 'c'}, - {"daemonize", optional_argument, 0, 'd'}, - {"ecuid", required_argument, 0, 'e'}, - {"help", no_argument, 0, 'h'}, - {"path", required_argument, 0, 'p'}, - {"snapshot", optional_argument, 0, 's'}, - {"timeout", required_argument, 0, 't'}, - {"verbose", no_argument, 0, 'v'}, - {0, 0, 0, 0} + { "command", required_argument, 0, 'c' }, + { "daemonize", optional_argument, 0, 'd' }, + { "ecuid", required_argument, 0, 'e' }, + { "help", no_argument, 0, 'h' }, + { "path", required_argument, 0, 'p' }, + { "snapshot", optional_argument, 0, 's' }, + { "timeout", required_argument, 0, 't' }, + { "verbose", no_argument, 0, 'v' }, + { 0, 0, 0, 0 } }; /** @brief Parses the application arguments @@ -471,14 +442,11 @@ static int parse_args(int argc, char *argv[]) ":s::t:he:p:d::c:v", long_options, &long_index)) != -1) - { - switch (c) - { + switch (c) { case 's': set_default_event_type(EVENT_SYNC_CACHE); - if (optarg != NULL && strlen(optarg) >= DLT_MOUNT_PATH_MAX) - { + if ((optarg != NULL) && (strlen(optarg) >= DLT_MOUNT_PATH_MAX)) { pr_error("Mount path '%s' too long\n", optarg); return -1; } @@ -501,8 +469,7 @@ static int parse_args(int argc, char *argv[]) break; case 'p': - if (strlen(optarg) >= DLT_MOUNT_PATH_MAX) - { + if (strlen(optarg) >= DLT_MOUNT_PATH_MAX) { pr_error("Mount path '%s' too long\n", optarg); return -1; } @@ -523,13 +490,9 @@ static int parse_args(int argc, char *argv[]) case '?': if (isprint(optopt)) - { pr_error("Unknown option -%c.\n", optopt); - } else - { pr_error("Unknown option character \\x%x.\n", optopt); - } usage(); return -1; @@ -537,11 +500,11 @@ static int parse_args(int argc, char *argv[]) pr_error("Try %s -h for more information.\n", argv[0]); return -1; } - } - if (get_default_event_type() == EVENT_SYNC_CACHE && - get_handler_type() != CTRL_NOHANDLER) - { + + + if ((get_default_event_type() == EVENT_SYNC_CACHE) && + (get_handler_type() != CTRL_NOHANDLER)) { pr_error("Sync caches not available in daemon mode\n"); return -1; } @@ -553,8 +516,8 @@ static int parse_args(int argc, char *argv[]) int sd_notify(int unset_environment, const char *state) { /* Satisfy Compiler for warnings */ - (void) unset_environment; - (void) state; + (void)unset_environment; + (void)state; return 0; } #endif @@ -577,36 +540,29 @@ int main(int argc, char *argv[]) /* Get command line arguments */ if (parse_args(argc, argv) != 0) - { return -1; - } /* all parameter valid, start communication with daemon or setup * communication with control daemon */ - if (get_handler_type() == CTRL_NOHANDLER) - { + if (get_handler_type() == CTRL_NOHANDLER) { pr_verbose("One shot.\n"); ret = dlt_logstorage_ctrl_single_request(); + if (ret < 0) - { pr_error("Message failed to be send. Please check DLT config.\n"); - } } - else - { + else { pr_verbose("Entering in daemon mode.\n"); /* Let's daemonize */ - if (sd_notify(0, "READY=1") <= 0) - { + if (sd_notify(0, "READY=1") <= 0) { pr_verbose("SD notify failed, manually daemonizing.\n"); /* No message can be sent or Systemd is not available. * Daemonizing manually. */ - if (daemon(1, 1)) - { + if (daemon(1, 1)) { pr_error("Failed to daemonize: %s\n", strerror(errno)); return EXIT_FAILURE; } diff --git a/src/console/logstorage/dlt-logstorage-list.c b/src/console/logstorage/dlt-logstorage-list.c index a18fca6..9adda9a 100644 --- a/src/console/logstorage/dlt-logstorage-list.c +++ b/src/console/logstorage/dlt-logstorage-list.c @@ -83,8 +83,7 @@ void print_list() struct LogstorageDeviceInfo *ptr = g_info; pr_verbose(" -------Device list-------\n"); - while (ptr != NULL) - { + while (ptr != NULL) { pr_verbose("%p:\t[%s][%s] \n", ptr, ptr->dev_node, ptr->mnt_point); ptr = ptr->next; } @@ -108,21 +107,16 @@ static struct LogstorageDeviceInfo *logstorage_find_dev_info(const char *node) struct LogstorageDeviceInfo *ptr = g_info; if (!node) - { return NULL; - } pr_verbose("Looking for %s.\n", node); - while (ptr != NULL) - { - if (strncmp(ptr->dev_node, node, DLT_MOUNT_PATH_MAX) == 0) - { + while (ptr != NULL) { + if (strncmp(ptr->dev_node, node, DLT_MOUNT_PATH_MAX) == 0) { pr_verbose("%s found in %p.\n", node, ptr); break; } - else - { + else { ptr = ptr->next; } } @@ -145,14 +139,12 @@ int logstorage_store_dev_info(const char *node, const char *path) struct LogstorageDeviceInfo *ptr = NULL; size_t path_len = 0; - if ((node == NULL) || (path == NULL)) - { + if ((node == NULL) || (path == NULL)) { pr_error("Invalid input\n"); return -1; } - if (logstorage_find_dev_info(node)) - { + if (logstorage_find_dev_info(node)) { pr_verbose("%s already in list.\n", node); print_list(); return 0; @@ -160,22 +152,20 @@ int logstorage_store_dev_info(const char *node, const char *path) ptr = calloc(1, sizeof(struct LogstorageDeviceInfo)); - if (ptr == NULL) - { + if (ptr == NULL) { pr_error("Node creation failed\n"); return -1; } ptr->dev_node = strdup(node); path_len = strlen(path); - if (path_len >DLT_MOUNT_PATH_MAX) - { + + if (path_len > DLT_MOUNT_PATH_MAX) path_len = (size_t)DLT_MOUNT_PATH_MAX; - } + ptr->mnt_point = (char *)calloc(1, path_len + 1); - if (ptr->mnt_point == NULL) - { + if (ptr->mnt_point == NULL) { pr_error("memory allocation failed for mnt_point\n"); return -1; } @@ -187,9 +177,7 @@ int logstorage_store_dev_info(const char *node, const char *path) ptr->next = g_info; if (g_info) - { g_info->prev = ptr; - } g_info = ptr; @@ -216,8 +204,7 @@ char *logstorage_delete_dev_info(const char *node) del = logstorage_find_dev_info(node); - if (del == NULL) - { + if (del == NULL) { pr_verbose("%s not found in list.\n", node); print_list(); return ret; @@ -227,19 +214,13 @@ char *logstorage_delete_dev_info(const char *node) ret = del->mnt_point; if (del->prev) - { del->prev->next = del->next; - } if (del->next) - { del->next->prev = del->prev; - } if (del == g_info) - { g_info = g_info->next; - } free(del->dev_node); free(del); diff --git a/src/console/logstorage/dlt-logstorage-prop.h b/src/console/logstorage/dlt-logstorage-prop.h index 836dc99..13eb57c 100644 --- a/src/console/logstorage/dlt-logstorage-prop.h +++ b/src/console/logstorage/dlt-logstorage-prop.h @@ -27,7 +27,8 @@ * * @return 0 */ -static inline int dlt_logstorage_prop_init(void) { +static inline int dlt_logstorage_prop_init(void) +{ return 0; } @@ -35,7 +36,8 @@ static inline int dlt_logstorage_prop_init(void) { * * @return 0 */ -static inline int dlt_logstorage_prop_deinit(void) { +static inline int dlt_logstorage_prop_deinit(void) +{ return 0; } @@ -43,7 +45,8 @@ static inline int dlt_logstorage_prop_deinit(void) { * * @return 0 */ -static inline int check_proprietary_handling(char *type) { +static inline int check_proprietary_handling(char *type) +{ (void)type; return 0; } #else diff --git a/src/console/logstorage/dlt-logstorage-udev.c b/src/console/logstorage/dlt-logstorage-udev.c index e3584d7..578f1fa 100644 --- a/src/console/logstorage/dlt-logstorage-udev.c +++ b/src/console/logstorage/dlt-logstorage-udev.c @@ -90,42 +90,33 @@ static char *dlt_logstorage_udev_get_mount_point(char *dev_node) char *mnt_point = NULL; if (dev_node == NULL) - { return NULL; - } f = setmntent("/proc/mounts", "r"); - if (f == NULL) - { + if (f == NULL) { pr_error("Cannot read /proc/mounts\n"); return NULL; } while (NULL != (ent = getmntent(f))) - { - if (strncmp(ent->mnt_fsname, dev_node, strlen(ent->mnt_fsname)) == 0) - { + if (strncmp(ent->mnt_fsname, dev_node, strlen(ent->mnt_fsname)) == 0) { mnt_point = strdup(ent->mnt_dir); - if (mnt_point == NULL) - { + if (mnt_point == NULL) { pr_error("Cannot duplicate string.\n"); return NULL; } /* Remounting rw */ if (strlen(mnt_point)) - { /* capabilities needed. Thus we don't really car on failure. * Therefor we can ignore the return value. */ - (void) mount(NULL, mnt_point, NULL, MS_REMOUNT, ent->mnt_opts); - } + (void)mount(NULL, mnt_point, NULL, MS_REMOUNT, ent->mnt_opts); break; } - } endmntent(f); @@ -153,56 +144,47 @@ static int check_mountpoint_from_partition(int event, struct udev_device *part) char *dev_node = NULL; int ret = 0; - if (!part) - { + if (!part) { pr_verbose("No partition structure given.\n"); return -1; } pr_verbose("Checking mount point.\n"); - if (!udev_device_get_devnode(part)) - { + if (!udev_device_get_devnode(part)) { pr_verbose("Skipping as no devnode.\n"); return 0; } dev_node = strdup(udev_device_get_devnode(part)); - if (dev_node == NULL) - { + + if (dev_node == NULL) { pr_error("Cannot allocate memory for to store string\n"); return -1; } - if (event == EVENT_MOUNTED) - { + if (event == EVENT_MOUNTED) { mnt_point = dlt_logstorage_udev_get_mount_point(dev_node); logstorage_dev = dlt_logstorage_check_config_file(mnt_point); - if (logstorage_dev) /* Configuration file available, add node to internal list */ - { + if (logstorage_dev) { /* Configuration file available, add node to internal list */ logstorage_store_dev_info(dev_node, mnt_point); } - else - { + else { free(mnt_point); mnt_point = NULL; } } - else - { + else { /* remove device information */ mnt_point = logstorage_delete_dev_info(dev_node); } - if (mnt_point) - { + if (mnt_point) { ret = dlt_logstorage_send_event(event, mnt_point); if (ret) - { pr_error("Can't send event for %s to DLT.\n", mnt_point); - } } free(dev_node); @@ -226,32 +208,28 @@ static int logstorage_udev_udevd_callback(void) LogstorageCtrlUdev *prvt = NULL; struct udev_device *partition = NULL; - if (!lctrl) - { + if (!lctrl) { pr_error("Not able to get logstorage control instance.\n"); return -1; } prvt = (LogstorageCtrlUdev *)lctrl->prvt; - if ((!prvt) || (!prvt->mon)) - { + if ((!prvt) || (!prvt->mon)) { pr_error("Not able to get private data.\n"); return -1; } partition = udev_monitor_receive_device(prvt->mon); - if (!partition) - { + if (!partition) { pr_error("Not able to get partition.\n"); return -1; } action = udev_device_get_action(partition); - if (!action) - { + if (!action) { pr_error("Not able to get action.\n"); udev_device_unref(partition); return -1; @@ -261,8 +239,7 @@ static int logstorage_udev_udevd_callback(void) action, udev_device_get_devnode(partition)); - if (strncmp(action, "add", sizeof("add")) == 0) - { + if (strncmp(action, "add", sizeof("add")) == 0) { /*TODO: This can be replaced by polling on /proc/mount. * we could get event on modification, and keep track on a list * of mounted devices. New devices could be check that way. @@ -294,8 +271,7 @@ static int logstorage_udev_udevd_callback(void) */ static int dlt_logstorage_udev_check_mounted(struct udev *udev) { - if (udev == NULL) - { + if (udev == NULL) { pr_error("%s: udev structure is NULL\n", __func__); return -1; } @@ -305,8 +281,7 @@ static int dlt_logstorage_udev_check_mounted(struct udev *udev) struct udev_list_entry *devices = NULL; struct udev_list_entry *dev_list_entry = NULL; - if (!enumerate) - { + if (!enumerate) { pr_error("Can't enumerate devices.\n"); return -1; } @@ -330,9 +305,7 @@ static int dlt_logstorage_udev_check_mounted(struct udev *udev) partition = udev_device_new_from_syspath(udev, path); if (!partition) - { continue; - } pr_verbose("Found device %s %s %s.\n", path, @@ -362,26 +335,18 @@ int dlt_logstorage_udev_deinit(void) LogstorageCtrlUdev *prvt = NULL; if (!lctrl) - { return -1; - } prvt = (LogstorageCtrlUdev *)lctrl->prvt; if (prvt == NULL) - { return -1; - } if (prvt->mon) - { udev_monitor_unref(prvt->mon); - } if (prvt->udev) - { udev_unref(prvt->udev); - } free(prvt); lctrl->prvt = NULL; @@ -404,16 +369,14 @@ int dlt_logstorage_udev_init(void) pr_verbose("Initializing.\n"); - if (!lctrl) - { + if (!lctrl) { pr_error("Not able to get logstorage control instance.\n"); return -1; } lctrl->prvt = calloc(1, sizeof(LogstorageCtrlUdev)); - if (!lctrl->prvt) - { + if (!lctrl->prvt) { pr_error("No memory to allocate private data.\n"); return -1; } @@ -423,8 +386,7 @@ int dlt_logstorage_udev_init(void) /* Initialize udev object */ prvt->udev = udev_new(); - if (!prvt->udev) - { + if (!prvt->udev) { pr_error("Cannot initialize udev object\n"); dlt_logstorage_udev_deinit(); return -1; @@ -435,8 +397,7 @@ int dlt_logstorage_udev_init(void) * "add", "remove", "change", etc */ prvt->mon = udev_monitor_new_from_netlink(prvt->udev, "udev"); - if (!prvt->mon) - { + if (!prvt->mon) { pr_error("Cannot initialize udev monitor\n"); dlt_logstorage_udev_deinit(); return -1; @@ -446,8 +407,7 @@ int dlt_logstorage_udev_init(void) "block", NULL); - if (ret) - { + if (ret) { pr_error("Cannot attach filter to monitor: %s.\n", strerror(-ret)); dlt_logstorage_udev_deinit(); return -1; @@ -455,8 +415,7 @@ int dlt_logstorage_udev_init(void) ret = udev_monitor_enable_receiving(prvt->mon); - if (ret < 0) - { + if (ret < 0) { pr_error("Cannot start receiving: %s.\n", strerror(-ret)); dlt_logstorage_udev_deinit(); return -1; -- cgit v1.2.1