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

Remove build warning #10

Merged
merged 2 commits into from
Sep 6, 2021
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
40 changes: 27 additions & 13 deletions src/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ bool
rcutils_get_cwd(char * buffer, size_t max_length)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) buffer;
(void) max_length;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand All @@ -98,6 +100,7 @@ bool
rcutils_is_directory(const char * abs_path)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) abs_path;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand All @@ -117,6 +120,7 @@ bool
rcutils_is_file(const char * abs_path)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) abs_path;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand All @@ -136,6 +140,7 @@ bool
rcutils_exists(const char * abs_path)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) abs_path;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand All @@ -151,6 +156,7 @@ bool
rcutils_is_readable(const char * abs_path)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) abs_path;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand All @@ -173,6 +179,7 @@ bool
rcutils_is_writable(const char * abs_path)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) abs_path;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand All @@ -195,6 +202,7 @@ bool
rcutils_is_readable_and_writable(const char * abs_path)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) abs_path;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand Down Expand Up @@ -222,6 +230,9 @@ rcutils_join_path(
rcutils_allocator_t allocator)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) left_hand_path;
(void) right_hand_path;
(void) allocator;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return NULL;
#else
Expand All @@ -245,6 +256,8 @@ rcutils_to_native_path(
rcutils_allocator_t allocator)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) path;
(void) allocator;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return NULL;
#else
Expand All @@ -260,6 +273,8 @@ char *
rcutils_expand_user(const char * path, rcutils_allocator_t allocator)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) path;
(void) allocator;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return NULL;
#else
Expand Down Expand Up @@ -288,6 +303,7 @@ bool
rcutils_mkdir(const char * abs_path)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) abs_path;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand Down Expand Up @@ -337,31 +353,24 @@ typedef struct dir_list_t
struct dir_list_t * next;
} dir_list_t;

#ifndef RCUTILS_NO_FILESYSTEM
static void free_dir_list(dir_list_t * dir_list, rcutils_allocator_t allocator)
{
#ifdef RCUTILS_NO_FILESYSTEM
RCUTILS_SET_ERROR_MSG("not available filesystem");
#else
dir_list_t * next_dir;
do {
next_dir = dir_list->next;
allocator.deallocate(dir_list->path, allocator.state);
allocator.deallocate(dir_list, allocator.state);
dir_list = next_dir;
} while (dir_list);
#endif // _RCUTILS_NO_FILESYSTEM
}

static void remove_first_dir_from_list(dir_list_t ** dir_list, rcutils_allocator_t allocator)
{
#ifdef RCUTILS_NO_FILESYSTEM
RCUTILS_SET_ERROR_MSG("not available filesystem");
#else
dir_list_t * next_dir = (*dir_list)->next;
allocator.deallocate((*dir_list)->path, allocator.state);
allocator.deallocate(*dir_list, allocator.state);
*dir_list = next_dir;
#endif // _RCUTILS_NO_FILESYSTEM
}

static rcutils_ret_t check_and_calculate_size(
Expand All @@ -371,10 +380,6 @@ static rcutils_ret_t check_and_calculate_size(
dir_list_t * dir_list,
rcutils_allocator_t allocator)
{
#ifdef RCUTILS_NO_FILESYSTEM
RCUTILS_SET_ERROR_MSG("not available filesystem");
return RCUTILS_RET_ERROR;
#else
// Skip over local folder handle (`.`) and parent folder (`..`)
if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0) {
return RCUTILS_RET_OK;
Expand Down Expand Up @@ -410,8 +415,8 @@ static rcutils_ret_t check_and_calculate_size(
allocator.deallocate(file_path, allocator.state);

return RCUTILS_RET_OK;
#endif // _RCUTILS_NO_FILESYSTEM
}
#endif // _RCUTILS_NO_FILESYSTEM

rcutils_ret_t
rcutils_calculate_directory_size_with_recursion(
Expand All @@ -421,6 +426,10 @@ rcutils_calculate_directory_size_with_recursion(
rcutils_allocator_t allocator)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) directory_path;
(void) max_depth;
(void) size;
(void) allocator;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return RCUTILS_RET_ERROR;
#else
Expand Down Expand Up @@ -495,6 +504,8 @@ rcutils_dir_iter_t *
rcutils_dir_iter_start(const char * directory_path, const rcutils_allocator_t allocator)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) directory_path;
(void) allocator;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return NULL;
#else
Expand Down Expand Up @@ -566,6 +577,7 @@ bool
rcutils_dir_iter_next(rcutils_dir_iter_t * iter)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) iter;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return false;
#else
Expand Down Expand Up @@ -596,6 +608,7 @@ void
rcutils_dir_iter_end(rcutils_dir_iter_t * iter)
{
#ifdef RCUTILS_NO_FILESYSTEM
(void) iter;
RCUTILS_SET_ERROR_MSG("not available filesystem");
#else
if (NULL == iter) {
Expand Down Expand Up @@ -625,6 +638,7 @@ rcutils_get_file_size(const char * file_path)
{

#ifdef RCUTILS_NO_FILESYSTEM
(void) file_path;
RCUTILS_SET_ERROR_MSG("not available filesystem");
return 0;
#else
Expand Down
28 changes: 28 additions & 0 deletions src/shared_library.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ rcutils_load_shared_library(
#endif // _WIN32

#else
(void) lib;
(void) library_path;
(void) allocator;
return RCUTILS_RET_ERROR;
#endif //RCUTILS_NO_FILESYSTEM

Expand All @@ -212,6 +215,7 @@ rcutils_load_shared_library(
void *
rcutils_get_symbol(const rcutils_shared_library_t * lib, const char * symbol_name)
{
#ifndef RCUTILS_NO_FILESYSTEM
if (!lib || !lib->lib_pointer || (symbol_name == NULL)) {
RCUTILS_SET_ERROR_MSG("invalid inputs arguments");
return NULL;
Expand Down Expand Up @@ -242,11 +246,17 @@ rcutils_get_symbol(const rcutils_shared_library_t * lib, const char * symbol_nam
return NULL;
}
return lib_symbol;
#else
(void) lib;
(void) symbol_name;
return NULL;
#endif //RCUTILS_NO_FILESYSTEM
}

bool
rcutils_has_symbol(const rcutils_shared_library_t * lib, const char * symbol_name)
{
#ifndef RCUTILS_NO_FILESYSTEM
if (!lib || !lib->lib_pointer || symbol_name == NULL) {
return false;
}
Expand All @@ -262,11 +272,17 @@ rcutils_has_symbol(const rcutils_shared_library_t * lib, const char * symbol_nam
void * lib_symbol = GetProcAddress((HINSTANCE)(lib->lib_pointer), symbol_name);
return lib_symbol != NULL;
#endif // _WIN32
#else
(void) lib;
(void) symbol_name;
return false;
#endif //RCUTILS_NO_FILESYSTEM
}

rcutils_ret_t
rcutils_unload_shared_library(rcutils_shared_library_t * lib)
{
#ifndef RCUTILS_NO_FILESYSTEM
RCUTILS_CHECK_ARGUMENT_FOR_NULL(lib, RCUTILS_RET_INVALID_ARGUMENT);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(lib->lib_pointer, RCUTILS_RET_INVALID_ARGUMENT);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(lib->library_path, RCUTILS_RET_INVALID_ARGUMENT);
Expand All @@ -292,6 +308,10 @@ rcutils_unload_shared_library(rcutils_shared_library_t * lib)
lib->lib_pointer = NULL;
lib->allocator = rcutils_get_zero_initialized_allocator();
return ret;
#else
(void) lib;
return RCUTILS_RET_ERROR;
#endif //RCUTILS_NO_FILESYSTEM
}

rcutils_ret_t
Expand All @@ -301,6 +321,7 @@ rcutils_get_platform_library_name(
unsigned int buffer_size,
bool debug)
{
#ifndef RCUTILS_NO_FILESYSTEM
RCUTILS_CHECK_ARGUMENT_FOR_NULL(library_name, RCUTILS_RET_INVALID_ARGUMENT);
RCUTILS_CHECK_ARGUMENT_FOR_NULL(library_name_platform, RCUTILS_RET_INVALID_ARGUMENT);

Expand Down Expand Up @@ -350,6 +371,13 @@ rcutils_get_platform_library_name(
return RCUTILS_RET_ERROR;
}
return RCUTILS_RET_OK;
#else
(void) library_name;
(void) library_name_platform;
(void) buffer_size;
(void) debug;
return RCUTILS_RET_ERROR;
#endif //RCUTILS_NO_FILESYSTEM
}

bool
Expand Down