Skip to content

Commit ae9655b

Browse files
authored
Merge pull request #782 from COVESA/dlt_devel_fix_cmake
cmake: Fix build errors and warnings
2 parents b651af1 + bd8d9fd commit ae9655b

File tree

71 files changed

+1991
-1729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1991
-1729
lines changed

.github/workflows/cmake-ctest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
-DBUILD_GMOCK=${{env.BUILD_GMOCK}}
3131
3232
- name: Build
33-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
33+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j$(nproc)
3434

3535
- name: Test
3636
working-directory: ${{github.workspace}}/build

CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,20 @@ if(WITH_DLT_COVERAGE)
231231
endif()
232232

233233
add_compile_options(
234-
$<$<COMPILE_LANGUAGE:C>:-std=gnu99>
234+
$<$<COMPILE_LANGUAGE:C>:-std=gnu11>
235235
$<$<COMPILE_LANGUAGE:CXX>:-std=gnu++14>
236236
-Wall
237237
-Wextra
238-
# -pedantic
238+
-pedantic
239239
-Wno-variadic-macros
240240
-Wno-strict-aliasing
241+
-Werror
242+
-Wconversion
243+
-Wshadow
244+
-Wundef
245+
-Wcast-qual
246+
-Wno-system-headers
247+
-Wno-unused-function
241248
)
242249

243250
if(WITH_DOC STREQUAL "OFF")

include/dlt/dlt_client.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ typedef enum
8888

8989
typedef struct
9090
{
91-
DltReceiver receiver; /**< receiver pointer to dlt receiver structure */
92-
int sock; /**< sock Connection handle/socket */
93-
char *servIP; /**< servIP IP adress/Hostname of interface */
94-
char *hostip; /**< hostip IP address of UDP host receiver interface */
95-
int port; /**< Port for TCP connections (optional) */
96-
char *serialDevice; /**< serialDevice Devicename of serial device */
97-
char *socketPath; /**< socketPath Unix socket path */
98-
char ecuid[4]; /**< ECUiD */
99-
speed_t baudrate; /**< baudrate Baudrate of serial interface, as speed_t */
100-
DltClientMode mode; /**< mode DltClientMode */
91+
DltReceiver receiver; /**< receiver pointer to dlt receiver structure */
92+
int sock; /**< sock Connection handle/socket */
93+
char *servIP; /**< servIP IP adress/Hostname of interface */
94+
char *hostip; /**< hostip IP address of UDP host receiver interface */
95+
uint16_t port; /**< Port for TCP connections (optional) */
96+
char *serialDevice; /**< serialDevice Devicename of serial device */
97+
char *socketPath; /**< socketPath Unix socket path */
98+
char ecuid[4]; /**< ECUiD */
99+
speed_t baudrate; /**< baudrate Baudrate of serial interface, as speed_t */
100+
DltClientMode mode; /**< mode DltClientMode */
101101
int send_serial_header; /**< (Boolean) Send DLT messages with serial header */
102102
int resync_serial_header; /**< (Boolean) Resync to serial header on all connection */
103103
} DltClient;
@@ -116,7 +116,7 @@ void dlt_client_register_fetch_next_message_callback(bool (*registerd_callback)(
116116
* @param verbose if set to true verbose information is printed out.
117117
* @return negative value if there was an error
118118
*/
119-
int dlt_client_init_port(DltClient *client, int port, int verbose);
119+
DltReturnValue dlt_client_init_port(DltClient *client, int port, int verbose);
120120

121121
/**
122122
* Initialising dlt client structure
@@ -196,7 +196,7 @@ DltReturnValue dlt_client_send_log_level(DltClient *client, char *apid, char *ct
196196
* @param client pointer to dlt client structure
197197
* @return negative value if there was an error
198198
*/
199-
int dlt_client_get_log_info(DltClient *client);
199+
DltReturnValue dlt_client_get_log_info(DltClient *client);
200200
/**
201201
* Send an request to get default log level to the dlt daemon
202202
* @param client pointer to dlt client structure
@@ -208,7 +208,7 @@ DltReturnValue dlt_client_get_default_log_level(DltClient *client);
208208
* @param client pointer to dlt client structure
209209
* @return negative value if there was an error
210210
*/
211-
int dlt_client_get_software_version(DltClient *client);
211+
DltReturnValue dlt_client_get_software_version(DltClient *client);
212212
/**
213213
* Initialise get log info structure
214214
* @return void

include/dlt/dlt_common.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@
7373
\{
7474
*/
7575

76-
# include <netinet/in.h>
76+
#pragma GCC diagnostic push
77+
#pragma GCC diagnostic ignored "-Wconversion"
78+
#include <netinet/in.h>
79+
#pragma GCC diagnostic pop
80+
7781
# include <stdio.h>
7882
# include <stdbool.h>
7983
# ifdef __linux__
@@ -116,8 +120,7 @@
116120
* Macros to swap the byte order.
117121
*/
118122
# define DLT_SWAP_64(value) ((((uint64_t)DLT_SWAP_32((value) & 0xffffffffull)) << 32) | (DLT_SWAP_32((value) >> 32)))
119-
120-
# define DLT_SWAP_16(value) ((((value) >> 8) & 0xff) | (((value) << 8) & 0xff00))
123+
# define DLT_SWAP_16(value) ((uint16_t)((((value) >> 8) & 0xff) | (((value) << 8) & 0xff00)))
121124
# define DLT_SWAP_32(value) ((((value) >> 24) & 0xff) | (((value) << 8) & 0xff0000) | (((value) >> 8) & 0xff00) | \
122125
(((value) << 24) & 0xff000000))
123126

@@ -174,9 +177,9 @@
174177
# define DLT_LETOH_64(x) ((x))
175178
# endif
176179

177-
# define DLT_ENDIAN_GET_16(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_16(x) : DLT_LETOH_16(x))
178-
# define DLT_ENDIAN_GET_32(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_32(x) : DLT_LETOH_32(x))
179-
# define DLT_ENDIAN_GET_64(htyp, x) ((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_64(x) : DLT_LETOH_64(x))
180+
# define DLT_ENDIAN_GET_16(htyp, x) ((uint16_t)((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_16(x) : DLT_LETOH_16(x)))
181+
# define DLT_ENDIAN_GET_32(htyp, x) ((uint32_t)((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_32(x) : DLT_LETOH_32(x)))
182+
# define DLT_ENDIAN_GET_64(htyp, x) ((uint64_t)((((htyp) & DLT_HTYP_MSBF) > 0) ? DLT_BETOH_64(x) : DLT_LETOH_64(x)))
180183

181184
# if defined (__WIN32__) || defined (_MSC_VER)
182185
# define LOG_EMERG 0
@@ -233,7 +236,7 @@
233236

234237

235238
# if defined (__MSDOS__) || defined (_MSC_VER)
236-
# define __func__ __FUNCTION__
239+
# define __func__ __func__
237240
# endif
238241

239242
# define PRINT_FUNCTION_VERBOSE(_verbose) \
@@ -293,7 +296,7 @@
293296
if ((length < 0) || ((length) < ((int32_t)sizeof(type)))) \
294297
{ length = -1; } \
295298
else \
296-
{ dst = *((type *)src); src += sizeof(type); length -= sizeof(type); } \
299+
{ dst = *((type *)src); src += sizeof(type); length -= (int32_t)sizeof(type); } \
297300
} while(false)
298301

299302
# define DLT_MSG_READ_ID(dst, src, length) \
@@ -1688,7 +1691,7 @@ int dlt_set_loginfo_parse_service_id(char *resp_text, uint32_t *service_id, uint
16881691
* @param rp_count int
16891692
* @return length
16901693
*/
1691-
int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count);
1694+
uint16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count);
16921695

16931696
/**
16941697
* Convert get log info from ASCII to int16

include/dlt/dlt_log.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ DltReturnValue dlt_log_init_multiple_logfiles_support(DltLoggingMode mode, bool
8585
/**
8686
* Initialize (external) logging facility for single logfile.
8787
*/
88-
DltReturnValue dlt_log_init_single_logfile();
88+
DltReturnValue dlt_log_init_single_logfile(void);
8989

9090
/**
9191
* Initialize (external) logging facility for multiple files logging.
@@ -136,14 +136,14 @@ void dlt_log_multiple_files_write(const char* format, ...);
136136
*/
137137
void dlt_log_free(void);
138138

139-
void dlt_log_free_single_logfile();
139+
void dlt_log_free_single_logfile(void);
140140

141-
void dlt_log_free_multiple_logfiles();
141+
void dlt_log_free_multiple_logfiles(void);
142142

143143
/**
144144
* Checks whether (internal) logging in multiple files is active.
145145
*/
146-
bool dlt_is_log_in_multiple_files_active();
146+
bool dlt_is_log_in_multiple_files_active(void);
147147

148148
# ifdef __cplusplus
149149
}

include/dlt/dlt_multiple_files.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,9 @@ unsigned int multiple_files_buffer_storage_dir_info(const char *path, const char
139139
/**
140140
* Creates filename with index.
141141
* @param files_buffer pointer to MultipleFilesRingBuffer struct.
142-
* @param length the maximum length of the log_file_name.
143142
* @param idx index to be used for file name creation.
144143
*/
145-
void multiple_files_buffer_file_name(MultipleFilesRingBuffer *files_buffer, size_t length, unsigned int idx);
144+
void multiple_files_buffer_file_name(MultipleFilesRingBuffer *files_buffer, unsigned int idx);
146145

147146
/**
148147
* Generates index for log file name.

include/dlt/dlt_user.h.in

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ typedef struct
271271
typedef int (*dlt_injection_callback_id)(uint32_t, void *, uint32_t, void *);
272272
typedef int (*dlt_injection_callback)(uint32_t, void *, uint32_t);
273273

274+
typedef union {
275+
int (*with_id)(uint32_t, void *, uint32_t, void *);
276+
int (*without_id)(uint32_t, void *, uint32_t);
277+
} dlt_injection_callback_internal;
278+
274279
/**************************************************************************************************
275280
* The following API functions define a low level function interface for DLT
276281
**************************************************************************************************/
@@ -851,7 +856,7 @@ DltReturnValue dlt_user_trace_network_segmented(DltContext *handle,
851856
* This function has to be called first, before using any DLT user lib functions.
852857
* @return Value from DltReturnValue enum
853858
*/
854-
DltReturnValue dlt_init();
859+
DltReturnValue dlt_init(void);
855860

856861
/**
857862
* Initialize the user lib writing only to file.
@@ -874,7 +879,7 @@ DltReturnValue dlt_set_filesize_max(unsigned int filesize);
874879
* This function has to be called when finishing using the DLT user lib.
875880
* @return Value from DltReturnValue enum
876881
*/
877-
DltReturnValue dlt_free();
882+
DltReturnValue dlt_free(void);
878883

879884
/**
880885
* Check the library version of DLT library.
@@ -989,7 +994,7 @@ DltReturnValue dlt_set_log_mode(DltUserLogMode mode);
989994
* Until then the state is "unknown state".
990995
* @return -1 = unknown state, 0 = client not connected, 1 = client connected
991996
*/
992-
int dlt_get_log_state();
997+
int dlt_get_log_state(void);
993998

994999
/**
9951000
* Register callback function called when injection message was received
@@ -1207,7 +1212,7 @@ DltReturnValue dlt_log_raw(DltContext *handle, DltLogLevelType loglevel, void *d
12071212
* Write marker message to DLT.
12081213
* @return Value from DltReturnValue enum
12091214
*/
1210-
DltReturnValue dlt_log_marker();
1215+
DltReturnValue dlt_log_marker(void);
12111216

12121217
/**
12131218
* Get the total size and available size of the shared memory buffer between daemon and applications.
@@ -1241,7 +1246,7 @@ DltReturnValue dlt_user_log_resend_buffer(void);
12411246
* @param loglevel this is the current log level of the log message to be sent
12421247
* @return Value from DltReturnValue enum, DLT_RETURN_TRUE if log level is enabled
12431248
*/
1244-
inline DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle, DltLogLevelType loglevel);
1249+
DltReturnValue dlt_user_is_logLevel_enabled(DltContext *handle, DltLogLevelType loglevel);
12451250

12461251

12471252
# ifdef DLT_TEST_ENABLE

src/adaptor/dlt-adaptor-stdin.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ int main(int argc, char *argv[])
187187
DLT_REGISTER_CONTEXT(mycontext, ctid, PS_DLT_CONTEXT_DESC);
188188

189189
if (timeout > -1)
190-
dlt_set_resend_timeout_atexit(timeout);
190+
dlt_set_resend_timeout_atexit((uint32_t)timeout);
191191

192192
while (fgets(str, MAXSTRLEN, stdin))
193193
if (strcmp(str, "") != 0)
@@ -202,4 +202,3 @@ int main(int argc, char *argv[])
202202

203203
return 0;
204204
}
205-

src/adaptor/dlt-adaptor-udp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
#include <sys/socket.h>
7373
#include <netinet/in.h>
7474
#include <errno.h>
75+
#include <getopt.h>
7576

7677
#include "dlt_common.h"
7778
#include "dlt_user.h"
@@ -210,7 +211,7 @@ int main(int argc, char *argv[])
210211
#else
211212
server_addr.sin_family = AF_INET;
212213
#endif
213-
server_addr.sin_port = htons(port);
214+
server_addr.sin_port = htons((uint16_t)port);
214215
server_addr.sin_addr.s_addr = INADDR_ANY;
215216
memset(&(server_addr.sin_zero), 0, 8);
216217
if (bind(sock, (struct sockaddr *)&server_addr,
@@ -227,8 +228,8 @@ int main(int argc, char *argv[])
227228
while (1) {
228229
bytes_read = 0;
229230

230-
bytes_read = recvfrom(sock, recv_data, MAXSTRLEN, 0,
231-
(struct sockaddr *)&client_addr, &addr_len);
231+
bytes_read = (int)recvfrom(sock, recv_data, MAXSTRLEN, 0,
232+
(struct sockaddr *)&client_addr, &addr_len);
232233

233234
if (bytes_read == -1) {
234235
if (errno == EINTR) {

src/console/dlt-control-common.c

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,12 @@ static int prepare_headers(DltMessage *msg, uint8_t *header)
337337
msg->standardheader->mcnt = 0;
338338

339339
/* prepare length information */
340-
msg->headersize = (uint32_t) (sizeof(DltStorageHeader) +
341-
sizeof(DltStandardHeader) +
342-
sizeof(DltExtendedHeader) +
343-
DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
340+
msg->headersize = (int32_t)(sizeof(DltStorageHeader) +
341+
sizeof(DltStandardHeader) +
342+
sizeof(DltExtendedHeader) +
343+
DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
344344

345-
len = (uint32_t) (msg->headersize - sizeof(DltStorageHeader) + msg->datasize);
345+
len = (uint32_t)(msg->headersize - (int32_t)sizeof(DltStorageHeader) + msg->datasize);
346346

347347
if (len > UINT16_MAX) {
348348
pr_error("Message header is too long.\n");
@@ -388,7 +388,7 @@ static DltMessage *dlt_control_prepare_message(DltControlMsgBody *data)
388388
}
389389

390390
/* prepare payload of data */
391-
msg->databuffersize = msg->datasize = (uint32_t) data->size;
391+
msg->databuffersize = msg->datasize = (int32_t)data->size;
392392

393393
/* Allocate memory for Dlt Message's buffer */
394394
msg->databuffer = (uint8_t *)calloc(1, data->size);
@@ -432,7 +432,14 @@ static DltMessage *dlt_control_prepare_message(DltControlMsgBody *data)
432432
*/
433433
static int dlt_control_init_connection(DltClient *client, void *cb)
434434
{
435-
int (*callback)(DltMessage *message, void *data) = cb;
435+
union {
436+
void *ptr;
437+
int (*callback)(DltMessage *message, void *data);
438+
} callback_converter;
439+
int (*callback)(DltMessage *message, void *data);
440+
441+
callback_converter.ptr = cb;
442+
callback = callback_converter.callback;
436443

437444
if (!cb || !client) {
438445
pr_error("%s: Invalid parameters\n", __func__);
@@ -624,11 +631,18 @@ int dlt_control_init(int (*response_analyzer)(char *, void *, int),
624631
return -1;
625632
}
626633

634+
union {
635+
void *ptr;
636+
int (*callback)(DltMessage *message, void *data);
637+
} callback_converter;
638+
627639
response_analyzer_cb = response_analyzer;
628640
set_ecuid(ecuid);
629641
set_verbosity(verbosity);
642+
callback_converter.callback = dlt_control_callback;
630643

631-
if (dlt_control_init_connection(&g_client, dlt_control_callback) != 0) {
644+
/* Initialize DLT connection */
645+
if (dlt_control_init_connection(&g_client, callback_converter.ptr) != 0) {
632646
pr_error("Connection initialization failed\n");
633647
dlt_client_cleanup(&g_client, get_verbosity());
634648
return -1;

0 commit comments

Comments
 (0)