Skip to content

Commit 9b1a7ab

Browse files
committed
Reduce compiler warnings for -Wall -Wpedantic -Wextra
1 parent 8f38789 commit 9b1a7ab

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

CMakeLists.txt

+5-7
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,28 @@ target_sources(${PROJECT_NAME} PUBLIC
2323

2424
# win32 port
2525
${CMAKE_CURRENT_LIST_DIR}/lwmem/src/system/lwmem_sys_win32.c
26-
)
26+
)
2727

2828
# Add key include paths
2929
target_include_directories(${PROJECT_NAME} PUBLIC
3030
${CMAKE_CURRENT_LIST_DIR}
3131
${CMAKE_CURRENT_LIST_DIR}/dev
32-
)
32+
)
3333

3434
# Compilation definition information
3535
target_compile_definitions(${PROJECT_NAME} PUBLIC
3636
WIN32
3737
_DEBUG
3838
CONSOLE
3939
LWMEM_DEV
40-
)
40+
)
4141

42-
# Compiler and linker options
42+
# Compiler options
4343
target_compile_options(${PROJECT_NAME} PRIVATE
44-
${CPU_PARAMETERS}
4544
-Wall
4645
-Wextra
4746
-Wpedantic
48-
-Wno-unused-parameter
49-
)
47+
)
5048

5149
# Add subdir with lwmem and link to the project
5250
add_subdirectory("lwmem")

lwmem/src/lwmem/lwmem.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ prv_insert_free_block(lwmem_t* const lw, lwmem_block_t* nb) {
245245
* By doing this, we protect data left by app
246246
* and we make sure new allocations cannot see old information
247247
*/
248-
LWMEM_MEMSET(LWMEM_GET_PTR_FROM_BLOCK(nb), 0x00, nb->size - LWMEM_BLOCK_META_SIZE);
248+
if (nb != NULL) {
249+
void* p = LWMEM_GET_PTR_FROM_BLOCK(nb);
250+
if (p != NULL) {
251+
LWMEM_MEMSET(p, 0x00, nb->size - LWMEM_BLOCK_META_SIZE);
252+
}
253+
}
249254
#endif /* LWMEM_CFG_RESET_MEMORY */
250255

251256
/*
@@ -1102,6 +1107,9 @@ lwmem_debug_print(uint8_t print_alloc, uint8_t print_free) {
11021107
size_t block_size;
11031108
lwmem_block_t* block;
11041109

1110+
(void)print_alloc;
1111+
(void)print_free;
1112+
11051113
printf("|-------|------------------|--------|------|------------------|-----------------|\r\n");
11061114
printf("| Block | Address | IsFree | Size | MaxUserAllocSize | Meta |\r\n");
11071115
printf("|-------|------------------|--------|------|------------------|-----------------|\r\n");

tests/lwmem_test.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ lw_c_regions[] = {
5454

5555
void
5656
lwmem_test_run(void) {
57-
void* ptr_1, * ptr_2, * ptr_3, * ptr_4;
58-
void* ptr_c_1, * ptr_c_2, * ptr_c_3, * ptr_c_4;
57+
void* ptr_1, * ptr_2, * ptr_3;
58+
void* ptr_c_1, * ptr_c_2, * ptr_c_3;
5959

6060
/* Initialize default lwmem instance */
6161
/* Use one of 2 possible function calls: */

0 commit comments

Comments
 (0)