-
Notifications
You must be signed in to change notification settings - Fork 19
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
Platform Abstraction Layer #208
base: master
Are you sure you want to change the base?
Changes from all commits
d0f2bd5
b748e0e
fff075a
3a6c6cb
d51b02b
7c4e66c
051cdd9
824b3da
1d41810
1a41210
d3f91d4
95659d6
d6e832d
cee19d0
5ad7ac3
3a9391e
e2c00cd
6b20b45
bda4d52
f201f8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
add_subdirectory(binaries_op) | ||
add_subdirectory(bzip2_op) | ||
add_subdirectory(config) | ||
add_subdirectory(data_provider) | ||
add_subdirectory(dbsync) | ||
add_subdirectory(error_messages) | ||
add_subdirectory(file_op) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is file_op no longer needed? can we remove the code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is needed, but it is not needed in Windows. Efforts were made to completely remove it but several other libraries use it. |
||
add_subdirectory(filesystem_wrapper) | ||
add_subdirectory(hashHelper) | ||
add_subdirectory(logger) | ||
add_subdirectory(mem_op) | ||
add_subdirectory(logger) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this was sorted alphabetically before, this should go before mem_op There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
add_subdirectory(networkHelper) | ||
add_subdirectory(pal) | ||
add_subdirectory(privsep_op) | ||
add_subdirectory(pthreads_op) | ||
add_subdirectory(randombytes) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
add_library(binaries_op STATIC src/binaries_op.c) | ||
|
||
get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE) | ||
target_include_directories(binaries_op PUBLIC include) | ||
include_directories(${COMMON_FOLDER}/pal/include) | ||
include_directories(${COMMON_FOLDER}/error_messages/include) | ||
include_directories(${COMMON_FOLDER}/utils/include) | ||
include_directories(${COMMON_FOLDER}/file_op/include) | ||
Comment on lines
+3
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many places in this PR use the old cmake style of |
||
|
||
target_link_libraries(binaries_op | ||
utils | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,17 @@ | |
* License (version 2) as published by the FSF - Free Software | ||
* Foundation | ||
*/ | ||
#include <string.h> | ||
#include <stdlib.h> | ||
#include "error_messages.h" | ||
#include "os_err.h" | ||
#include "pal.h" | ||
#include "logger.hpp" | ||
#include "os_macros.h" | ||
|
||
#include "shared.h" | ||
|
||
#ifndef WIN32 | ||
#include "file_op.h" | ||
#endif | ||
Comment on lines
+9
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Were these headers missing before? I don't see from the changes in the code that they are all necessary (ie: logger.hpp) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those headers were placed in shared.h which is a mess and created include loops and other problems in MSVC. So shared.h was removed and only those necessary headers were included. |
||
|
||
#ifdef WAZUH_UNIT_TESTING | ||
#ifdef WIN32 | ||
|
@@ -23,7 +31,7 @@ int get_binary_path(const char *binary, char **validated_comm) { | |
const char sep[2] = ":"; | ||
#endif | ||
char *path; | ||
char *full_path; | ||
char *full_path = NULL; | ||
char *validated = NULL; | ||
char *env_path = NULL; | ||
char *env_path_copy = NULL; | ||
|
@@ -57,9 +65,10 @@ int get_binary_path(const char *binary, char **validated_comm) { | |
#ifdef WIN32 | ||
snprintf(full_path, strlen(path) + strlen(binary) + 2, "%s\\%s", path, binary); | ||
#else | ||
snprintf(full_path, strlen(path) + strlen(binary) + 2, "%s/%s", path, binary); | ||
if(full_path) | ||
snprintf(full_path, strlen(path) + strlen(binary) + 2, "%s/%s", path, binary); | ||
#endif | ||
if (IsFile(full_path) == 0) { | ||
if (full_path && IsFile(full_path) == 0) { | ||
validated = strdup(full_path); | ||
os_free(full_path); | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,15 @@ | |
|
||
#include <string> | ||
|
||
#ifdef __GNUC__ | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wunused-function" | ||
#endif | ||
Comment on lines
+17
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these warnings handled on clang too? This question applies for all of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As long as I understand, if -fgnuc-version=0 is not passed as a parameter to ClangApple, it will continue defining GNUC, which was its normal behaviour. https://clang.llvm.org/docs/UsersManual.html#cmdoption-fgnuc-version If you still think it is necessary, it could be changed in every place with clang, but the only advantage would be more clarity when reading it, not the behaviour. |
||
|
||
#ifdef _MSC_VER | ||
#pragma warning(push) | ||
#pragma warning(disable: 4505) | ||
#endif | ||
|
||
namespace Utils | ||
{ | ||
|
@@ -36,6 +43,12 @@ namespace Utils | |
} | ||
} | ||
|
||
#ifdef __GNUC__ | ||
#pragma GCC diagnostic pop | ||
#endif | ||
|
||
#ifdef _MSC_VER | ||
#pragma warning(pop) | ||
#endif | ||
|
||
#endif // _BYTE_ARRAY_HELPER_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
add_library(bzip2_op STATIC src/bzip2_op.c) | ||
|
||
get_filename_component(COMMON_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/../ ABSOLUTE) | ||
target_include_directories(bzip2_op PUBLIC include) | ||
include_directories(${COMMON_FOLDER}/pal/include) | ||
include_directories(${COMMON_FOLDER}/error_messages/include) | ||
Comment on lines
+5
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it better to include the directories like this than to link against the targets that normally bring them? I mean, instead of adding the directories just using target_link_libraries with pal and error_messages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error_messages are almost always included for definitions, and pal also solves incompatibilities in the header but not in any linkable file. |
||
|
||
target_link_libraries(bzip2_op | ||
utils | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,11 @@ | |
* License (version 2) as published by the FSF - Free Software | ||
* Foundation. | ||
*/ | ||
|
||
#include "shared.h" | ||
#include <stdio.h> | ||
#include <errno.h> | ||
#include "bzip2_op.h" | ||
#include "error_messages.h" | ||
#include "os_err.h" | ||
Comment on lines
+10
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like <logger.hpp> was also missing here. |
||
|
||
|
||
int bzip2_compress(const char *file, const char *filebz2) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about macos?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done