summaryrefslogtreecommitdiff
path: root/src/console/logstorage/dlt-logstorage-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/console/logstorage/dlt-logstorage-common.c')
-rw-r--r--src/console/logstorage/dlt-logstorage-common.c54
1 files changed, 17 insertions, 37 deletions
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;
}