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: make sure that postject-api.h compiles without warnings #54

Merged
5 changes: 2 additions & 3 deletions postject-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct postject_options {
const char* pe_resource_name;
};

static void postject_options_init(struct postject_options* options) {
inline void postject_options_init(struct postject_options* options) {
options->elf_section_name = NULL;
options->macho_framework_name = NULL;
options->macho_section_name = NULL;
Expand Down Expand Up @@ -93,7 +93,6 @@ static const void* postject_find_resource(

return ptr;
#elif defined(__linux__)
void* ptr = NULL;

if (options != NULL && options->elf_section_name != NULL) {
name = options->elf_section_name;
Expand Down Expand Up @@ -151,7 +150,7 @@ static const void* postject_find_resource(
if (resource_name == NULL) {
return NULL;
}
strcpy(resource_name, name);
strcpy_s(resource_name, strlen(name) + 1, name);
CharUpperA(resource_name); // Uppercases inplace
}

Expand Down
8 changes: 8 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ project(postject-tests)

add_executable(c_test test.c)
add_executable(cpp_test test.cpp)

if(WIN32)
target_compile_options(c_test PRIVATE /W4 /WX)
target_compile_options(cpp_test PRIVATE /W4 /WX /EHsc)
else()
target_compile_options(c_test PRIVATE -Wall -Werror)
target_compile_options(cpp_test PRIVATE -Wall -Werror)
endif()
4 changes: 4 additions & 0 deletions test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ int main() {
if (ptr && size > 0) {
char* str = (char*)malloc(size + 1);
memset(str, 0, size + 1);
#if defined(_WIN32)
strncpy_s(str, size + 1, ptr, size);
#else
strncpy(str, ptr, size);
#endif
printf("%s\n", str);
} else {
printf("Hello world\n");
Expand Down