Skip to content
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

fix: Update crashpad and suppress C5105 #428

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ if(SENTRY_BUILD_EXAMPLES)
add_executable(sentry_example examples/example.c)
target_link_libraries(sentry_example PRIVATE sentry)

if(MSVC)
target_compile_options(sentry_example PRIVATE $<BUILD_INTERFACE:/wd5105>)
endif()

# set static runtime if enabled
if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC)
set_property(TARGET sentry_example PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Expand Down
8 changes: 7 additions & 1 deletion examples/example.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# define NOMINMAX
# define _CRT_SECURE_NO_WARNINGS
#endif

#include "sentry.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef SENTRY_PLATFORM_WINDOWS
# include <windows.h>
# include <synchapi.h>
# define sleep_s(SECONDS) Sleep((SECONDS)*1000)
#else
# include <unistd.h>
Expand Down
11 changes: 8 additions & 3 deletions src/path/sentry_path_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <errno.h>
#include <fcntl.h>
#include <io.h>
#include <shlwapi.h>
#include <stdlib.h>
#include <sys/locking.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -125,7 +124,13 @@ sentry__path_dir(const sentry_path_t *path)
if (!dir_path) {
return NULL;
}
PathRemoveFileSpecW(dir_path->path);

// find the filename part and truncate just in front of it if possible
sentry_pathchar_t *filename
= (sentry_pathchar_t *)sentry__path_filename(dir_path);
if (filename > dir_path->path) {
*(filename - 1) = L'\0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C is so scary

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha, I constantly facepalming why we have to write all this horrible code over and over again just because C does not have a sufficiently good std lib, such as Rusts Path(Buf) / &str/String 🤦‍♂️

}
return dir_path;
}

Expand Down Expand Up @@ -216,7 +221,7 @@ sentry__path_filename(const sentry_path_t *path)
size_t idx = wcslen(s);

while (true) {
if (s[idx] == L'/' || s[idx] == '\\') {
if (s[idx] == L'/' || s[idx] == L'\\') {
ptr = s + idx + 1;
break;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ if(MINGW)
)
endif()

if(MSVC)
target_compile_options(sentry_test_unit PRIVATE $<BUILD_INTERFACE:/wd5105>)
endif()

# set static runtime if enabled
if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC)
set_property(TARGET sentry_test_unit PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Expand Down