Skip to content

Add extra compilation flags #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2024
Merged
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
2 changes: 2 additions & 0 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ function(add_umf_target_compile_options name)
-Wunused-parameter
-Wformat
-Wformat-security
-Wcast-qual
-Wunused-result
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=auto>)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(${name} PRIVATE -D_FORTIFY_SOURCE=2)
Expand Down
9 changes: 8 additions & 1 deletion src/provider/provider_os_memory_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ int os_purge(void *addr, size_t length, int advice) {
}

void os_strerror(int errnum, char *buf, size_t buflen) {
strerror_r(errnum, buf, buflen);
// 'strerror_r' implementation is XSI-compliant (returns 0 on success)
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE
if (strerror_r(errnum, buf, buflen)) {
#else // 'strerror_r' implementation is GNU-specific (returns pointer on success)
if (!strerror_r(errnum, buf, buflen)) {
#endif
LOG_PERR("Retrieving error code description failed");
}
}

umf_result_t os_duplicate_fd(int pid, int fd_in, int *fd_out) {
Expand Down
5 changes: 3 additions & 2 deletions src/provider/provider_tracking.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,9 @@ static size_t getDataSizeFromIpcHandle(const void *providerIpcData) {
// by umf_ipc_data_t. We use this trick to get pointer to
// umf_ipc_data_t data because the providerIpcData is
// the Flexible Array Member of umf_ipc_data_t.
umf_ipc_data_t *ipcUmfData =
(umf_ipc_data_t *)((uint8_t *)providerIpcData - sizeof(umf_ipc_data_t));
const umf_ipc_data_t *ipcUmfData =
(const umf_ipc_data_t *)((const uint8_t *)providerIpcData -
sizeof(umf_ipc_data_t));
return ipcUmfData->baseSize;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void util_log_internal(util_log_level_t level, int perror,
char err_buff[1024]; // max size according to manpage.
int saveno = errno;
errno = 0;
char *err = strerror_r(saveno, err_buff, sizeof(err_buff));
const char *err = strerror_r(saveno, err_buff, sizeof(err_buff));
if (errno == ERANGE) {
postfix = "[truncated...]";
}
Expand Down
7 changes: 7 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ function(build_umf_test)
SRCS ${ARG_SRCS}
LIBS ${TEST_LIBS})

if(NOT MSVC)
# Suppress 'cast discards const qualifier' warnings. Parametrized GTEST
# tests retrieve arguments using 'GetParam()', which applies a 'const'
# qualifier often discarded in the test scenarios.
target_compile_options(${TEST_TARGET_NAME} PRIVATE -Wno-cast-qual)
endif()

target_link_directories(${TEST_TARGET_NAME} PRIVATE ${LIB_DIRS})

target_include_directories(
Expand Down