Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ add_compile_options(
# -pedantic
-Wno-variadic-macros
-Wno-strict-aliasing
-Werror
)

if(WITH_DOC STREQUAL "OFF")
Expand Down
6 changes: 3 additions & 3 deletions include/dlt/dlt_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void dlt_client_register_fetch_next_message_callback(bool (*registerd_callback)(
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
int dlt_client_init_port(DltClient *client, int port, int verbose);
DltReturnValue dlt_client_init_port(DltClient *client, int port, int verbose);

/**
* Initialising dlt client structure
Expand Down Expand Up @@ -196,7 +196,7 @@ DltReturnValue dlt_client_send_log_level(DltClient *client, char *apid, char *ct
* @param client pointer to dlt client structure
* @return negative value if there was an error
*/
int dlt_client_get_log_info(DltClient *client);
DltReturnValue dlt_client_get_log_info(DltClient *client);
/**
* Send an request to get default log level to the dlt daemon
* @param client pointer to dlt client structure
Expand All @@ -208,7 +208,7 @@ DltReturnValue dlt_client_get_default_log_level(DltClient *client);
* @param client pointer to dlt client structure
* @return negative value if there was an error
*/
int dlt_client_get_software_version(DltClient *client);
DltReturnValue dlt_client_get_software_version(DltClient *client);
/**
* Initialise get log info structure
* @return void
Expand Down
3 changes: 1 addition & 2 deletions include/dlt/dlt_multiple_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ unsigned int multiple_files_buffer_storage_dir_info(const char *path, const char
/**
* Creates filename with index.
* @param files_buffer pointer to MultipleFilesRingBuffer struct.
* @param length the maximum length of the log_file_name.
* @param idx index to be used for file name creation.
*/
void multiple_files_buffer_file_name(MultipleFilesRingBuffer *files_buffer, size_t length, unsigned int idx);
void multiple_files_buffer_file_name(MultipleFilesRingBuffer *files_buffer, unsigned int idx);

/**
* Generates index for log file name.
Expand Down
2 changes: 1 addition & 1 deletion include/dlt/dlt_user.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ DltReturnValue dlt_user_log_resend_buffer(void);
* @param loglevel this is the current log level of the log message to be sent
* @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is enabled
*/
inline DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle, DltLogLevelType loglevel);
DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle, DltLogLevelType loglevel);


# ifdef DLT_TEST_ENABLE
Expand Down
3 changes: 2 additions & 1 deletion src/console/dlt-passive-node-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ void set_node_id(char *id)
exit(-1);
}
else {
strncpy(g_options.node_id, id, DLT_ID_SIZE);
strncpy(g_options.node_id, id, DLT_ID_SIZE - 1);
g_options.node_id[DLT_ID_SIZE - 1] = '\0';
}
}

Expand Down
46 changes: 29 additions & 17 deletions src/daemon/dlt-daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
# endif
#endif

#include <getopt.h>
#ifndef CONFIGURATION_FILES_DIR
#define CONFIGURATION_FILES_DIR "/etc"
#endif
#ifndef DLT_USER_IPC_PATH
#define DLT_USER_IPC_PATH "/tmp"
#endif

#include "dlt_types.h"
#include "dlt-daemon.h"
#include "dlt-daemon_cfg.h"
Expand Down Expand Up @@ -204,7 +212,7 @@ void usage()
printf("Options:\n");
printf(" -d Daemonize\n");
printf(" -h Usage\n");
printf(" -c filename DLT daemon configuration file (Default: " CONFIGURATION_FILES_DIR "/dlt.conf)\n");
printf(" -c filename DLT daemon configuration file (Default: %s/dlt.conf)\n", CONFIGURATION_FILES_DIR);

#ifdef DLT_DAEMON_USE_FIFO_IPC
printf(" -t directory Directory for local fifo and user-pipes (Default: /tmp)\n");
Expand Down Expand Up @@ -363,10 +371,18 @@ int option_handling(DltDaemonLocal *daemon_local, int argc, char *argv[])
/* switch() */

#ifdef DLT_DAEMON_USE_FIFO_IPC
snprintf(daemon_local->flags.userPipesDir, DLT_PATH_MAX,
"%s/dltpipes", dltFifoBaseDir);
snprintf(daemon_local->flags.daemonFifoName, DLT_PATH_MAX,
"%s/dlt", dltFifoBaseDir);
if (strlen(dltFifoBaseDir) + strlen("/dltpipes") < DLT_PATH_MAX) {
snprintf(daemon_local->flags.userPipesDir, DLT_PATH_MAX,
"%s/dltpipes", dltFifoBaseDir);
} else {
daemon_local->flags.userPipesDir[0] = '\0';
}
if (strlen(dltFifoBaseDir) + strlen("/dlt") < DLT_PATH_MAX) {
snprintf(daemon_local->flags.daemonFifoName, DLT_PATH_MAX,
"%s/dlt", dltFifoBaseDir);
} else {
daemon_local->flags.daemonFifoName[0] = '\0';
}
#endif

#ifdef DLT_SHM_ENABLE
Expand Down Expand Up @@ -407,7 +423,7 @@ int option_file_parser(DltDaemonLocal *daemon_local)
#else /* DLT_DAEMON_USE_FIFO_IPC */
n = snprintf(daemon_local->flags.loggingFilename,
sizeof(daemon_local->flags.loggingFilename),
"%s/dlt.log", dltFifoBaseDir);
"%s/dlt.log", DLT_USER_IPC_PATH);
#endif

if (n < 0 || (size_t)n > sizeof(daemon_local->flags.loggingFilename)) {
Expand Down Expand Up @@ -1309,7 +1325,7 @@ int trace_load_config_file_parser(DltDaemon *daemon, DltDaemonLocal *daemon_loca
}
#endif

static int dlt_mkdir_recursive(const char *dir)
int dlt_mkdir_recursive(const char *dir)
{
int ret = 0;
char tmp[PATH_MAX + 1];
Expand Down Expand Up @@ -1464,21 +1480,17 @@ int main(int argc, char *argv[])
PRINT_FUNCTION_VERBOSE(daemon_local.flags.vflag);

/* Make sure the parent user directory is created */
const char *dir_to_create;
#ifdef DLT_DAEMON_USE_FIFO_IPC

if (dlt_mkdir_recursive(dltFifoBaseDir) != 0) {
dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", dltFifoBaseDir);
return -1;
}

dir_to_create = dltFifoBaseDir;
#else
if (dlt_mkdir_recursive(DLT_USER_IPC_PATH) != 0) {
dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", daemon_local.flags.appSockPath);
dir_to_create = DLT_USER_IPC_PATH;
#endif
if (dlt_mkdir_recursive(dir_to_create) != 0) {
dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", dir_to_create);
return -1;
}

#endif

/* --- Daemon init phase 1 begin --- */
if (dlt_daemon_local_init_p1(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
dlt_log(LOG_CRIT, "Initialization of phase 1 failed!\n");
Expand Down
14 changes: 9 additions & 5 deletions src/daemon/dlt_daemon_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,11 +720,15 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
#endif
#ifdef DLT_DAEMON_USE_FIFO_IPC
if (dlt_user_handle < DLT_FD_MINIMUM) {
snprintf(filename,
DLT_DAEMON_COMMON_TEXTBUFSIZE,
"%s/dltpipes/dlt%d",
dltFifoBaseDir,
pid);
if (strlen(dltFifoBaseDir) + strlen("/dltpipes/dlt") + 11 < DLT_DAEMON_COMMON_TEXTBUFSIZE) { // 11 for max pid digits
snprintf(filename,
DLT_DAEMON_COMMON_TEXTBUFSIZE,
"%s/dltpipes/dlt%d",
dltFifoBaseDir,
pid);
} else {
filename[0] = '\0';
}

dlt_user_handle = open(filename, O_WRONLY | O_NONBLOCK);

Expand Down
2 changes: 1 addition & 1 deletion src/examples/dlt-example-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ int main(int argc, char *argv[])
message = argv[index];
}
else { /* allocate raw buffer */
message = calloc(sizeof(char), rvalue);
message = calloc(rvalue, sizeof(char));
memset(message, 'X', rvalue - 1);
}

Expand Down
4 changes: 2 additions & 2 deletions src/gateway/dlt_gateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -1608,9 +1608,9 @@ int dlt_gateway_forward_control_message(DltGateway *gateway,
return DLT_RETURN_OK;
}

int dlt_gateway_process_on_demand_request(DltGateway *gateway,
DltReturnValue dlt_gateway_process_on_demand_request(DltGateway *gateway,
DltDaemonLocal *daemon_local,
char node_id[DLT_ID_SIZE],
char *node_id,
int connection_status,
int verbose)
{
Expand Down
4 changes: 2 additions & 2 deletions src/gateway/dlt_gateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ DltReceiver *dlt_gateway_get_connection_receiver(DltGateway *g, int fd);
* @param verbose verbose flag
* @return 0 on success, -1 otherwise
*/
int dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
DltReceiver *recv,
int verbose);
Expand Down Expand Up @@ -157,7 +157,7 @@ int dlt_gateway_forward_control_message(DltGateway *g,
* @param verbose verbose flag
* @return 0 on success, -1 otherwise
*/
int dlt_gateway_process_on_demand_request(DltGateway *g,
DltReturnValue dlt_gateway_process_on_demand_request(DltGateway *g,
DltDaemonLocal *daemon_local,
char *node_id,
int connection_status,
Expand Down
34 changes: 24 additions & 10 deletions src/lib/dlt_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
# define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL)
#endif /* DLT_FATAL_LOG_RESET_ENABLE */

/* Extra length for FIFO filename: /dlt + pid */
#define DLT_FIFO_FILENAME_EXTRA_LEN 20

enum InitState {
INIT_UNITIALIZED,
INIT_IN_PROGRESS,
Expand Down Expand Up @@ -402,8 +405,16 @@ static DltReturnValue dlt_initialize_fifo_connection(void)
char filename[DLT_PATH_MAX];
int ret;

snprintf(dlt_user_dir, DLT_PATH_MAX, "%s/dltpipes", dltFifoBaseDir);
snprintf(dlt_daemon_fifo, DLT_PATH_MAX, "%s/dlt", dltFifoBaseDir);
if (strlen(dltFifoBaseDir) + strlen("/dltpipes") < DLT_PATH_MAX) {
snprintf(dlt_user_dir, DLT_PATH_MAX, "%s/dltpipes", dltFifoBaseDir);
} else {
dlt_user_dir[0] = '\0';
}
if (strlen(dltFifoBaseDir) + strlen("/dlt") < DLT_PATH_MAX) {
snprintf(dlt_daemon_fifo, DLT_PATH_MAX, "%s/dlt", dltFifoBaseDir);
} else {
dlt_daemon_fifo[0] = '\0';
}
ret = mkdir(dlt_user_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX);

if ((ret == -1) && (errno != EEXIST)) {
Expand Down Expand Up @@ -911,8 +922,7 @@ DltReturnValue dlt_init_common(void)
}

if (dlt_user.resend_buffer == NULL) {
dlt_user.resend_buffer = calloc(sizeof(unsigned char),
(dlt_user.log_buf_len + header_size));
dlt_user.resend_buffer = calloc((dlt_user.log_buf_len + header_size), sizeof(unsigned char));

if (dlt_user.resend_buffer == NULL) {
dlt_user_init_state = INIT_UNITIALIZED;
Expand Down Expand Up @@ -1083,7 +1093,11 @@ DltReturnValue dlt_free(void)
if (dlt_user.dlt_user_handle != DLT_FD_INIT) {
close(dlt_user.dlt_user_handle);
dlt_user.dlt_user_handle = DLT_FD_INIT;
snprintf(filename, DLT_PATH_MAX, "%s/dlt%d", dlt_user_dir, getpid());
if (strlen(dlt_user_dir) + DLT_FIFO_FILENAME_EXTRA_LEN < DLT_PATH_MAX) {
snprintf(filename, DLT_PATH_MAX, "%s/dlt%d", dlt_user_dir, getpid());
} else {
filename[0] = '\0';
}
unlink(filename);
}

Expand Down Expand Up @@ -1936,7 +1950,7 @@ DltReturnValue dlt_user_log_write_start_internal(DltContext *handle,
}
else
{
log->buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
log->buffer = calloc(dlt_user.log_buf_len, sizeof(unsigned char));
}

if (log->buffer == NULL) {
Expand Down Expand Up @@ -3049,7 +3063,7 @@ DltReturnValue dlt_user_trace_network_segmented_start(uint32_t *id,
return DLT_RETURN_ERROR;

if (log.buffer == NULL) {
log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
log.buffer = calloc(dlt_user.log_buf_len, sizeof(unsigned char));

if (log.buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
Expand Down Expand Up @@ -3151,7 +3165,7 @@ DltReturnValue dlt_user_trace_network_segmented_segment(uint32_t id,

/* initialize values */
if (log.buffer == NULL) {
log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
log.buffer = calloc(dlt_user.log_buf_len, sizeof(unsigned char));

if (log.buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
Expand Down Expand Up @@ -3220,7 +3234,7 @@ DltReturnValue dlt_user_trace_network_segmented_end(uint32_t id, DltContext *han

/* initialize values */
if (log.buffer == NULL) {
log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
log.buffer = calloc(dlt_user.log_buf_len, sizeof(unsigned char));

if (log.buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
Expand Down Expand Up @@ -3486,7 +3500,7 @@ DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,

/* initialize values */
if (log.buffer == NULL) {
log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
log.buffer = calloc(dlt_user.log_buf_len, sizeof(unsigned char));

if (log.buffer == NULL) {
dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
Expand Down
Loading
Loading