Skip to content

Commit 56644f9

Browse files
Remove build warning (#10) (#12)
* Avoid not used warnings * Update (cherry picked from commit a76caed) Co-authored-by: Pablo Garrido <[email protected]>
1 parent 03e1d66 commit 56644f9

File tree

2 files changed

+55
-13
lines changed

2 files changed

+55
-13
lines changed

src/filesystem.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ bool
7575
rcutils_get_cwd(char * buffer, size_t max_length)
7676
{
7777
#ifdef RCUTILS_NO_FILESYSTEM
78+
(void) buffer;
79+
(void) max_length;
7880
RCUTILS_SET_ERROR_MSG("not available filesystem");
7981
return false;
8082
#else
@@ -98,6 +100,7 @@ bool
98100
rcutils_is_directory(const char * abs_path)
99101
{
100102
#ifdef RCUTILS_NO_FILESYSTEM
103+
(void) abs_path;
101104
RCUTILS_SET_ERROR_MSG("not available filesystem");
102105
return false;
103106
#else
@@ -117,6 +120,7 @@ bool
117120
rcutils_is_file(const char * abs_path)
118121
{
119122
#ifdef RCUTILS_NO_FILESYSTEM
123+
(void) abs_path;
120124
RCUTILS_SET_ERROR_MSG("not available filesystem");
121125
return false;
122126
#else
@@ -136,6 +140,7 @@ bool
136140
rcutils_exists(const char * abs_path)
137141
{
138142
#ifdef RCUTILS_NO_FILESYSTEM
143+
(void) abs_path;
139144
RCUTILS_SET_ERROR_MSG("not available filesystem");
140145
return false;
141146
#else
@@ -151,6 +156,7 @@ bool
151156
rcutils_is_readable(const char * abs_path)
152157
{
153158
#ifdef RCUTILS_NO_FILESYSTEM
159+
(void) abs_path;
154160
RCUTILS_SET_ERROR_MSG("not available filesystem");
155161
return false;
156162
#else
@@ -173,6 +179,7 @@ bool
173179
rcutils_is_writable(const char * abs_path)
174180
{
175181
#ifdef RCUTILS_NO_FILESYSTEM
182+
(void) abs_path;
176183
RCUTILS_SET_ERROR_MSG("not available filesystem");
177184
return false;
178185
#else
@@ -195,6 +202,7 @@ bool
195202
rcutils_is_readable_and_writable(const char * abs_path)
196203
{
197204
#ifdef RCUTILS_NO_FILESYSTEM
205+
(void) abs_path;
198206
RCUTILS_SET_ERROR_MSG("not available filesystem");
199207
return false;
200208
#else
@@ -222,6 +230,9 @@ rcutils_join_path(
222230
rcutils_allocator_t allocator)
223231
{
224232
#ifdef RCUTILS_NO_FILESYSTEM
233+
(void) left_hand_path;
234+
(void) right_hand_path;
235+
(void) allocator;
225236
RCUTILS_SET_ERROR_MSG("not available filesystem");
226237
return NULL;
227238
#else
@@ -245,6 +256,8 @@ rcutils_to_native_path(
245256
rcutils_allocator_t allocator)
246257
{
247258
#ifdef RCUTILS_NO_FILESYSTEM
259+
(void) path;
260+
(void) allocator;
248261
RCUTILS_SET_ERROR_MSG("not available filesystem");
249262
return NULL;
250263
#else
@@ -260,6 +273,8 @@ char *
260273
rcutils_expand_user(const char * path, rcutils_allocator_t allocator)
261274
{
262275
#ifdef RCUTILS_NO_FILESYSTEM
276+
(void) path;
277+
(void) allocator;
263278
RCUTILS_SET_ERROR_MSG("not available filesystem");
264279
return NULL;
265280
#else
@@ -288,6 +303,7 @@ bool
288303
rcutils_mkdir(const char * abs_path)
289304
{
290305
#ifdef RCUTILS_NO_FILESYSTEM
306+
(void) abs_path;
291307
RCUTILS_SET_ERROR_MSG("not available filesystem");
292308
return false;
293309
#else
@@ -337,31 +353,24 @@ typedef struct dir_list_t
337353
struct dir_list_t * next;
338354
} dir_list_t;
339355

356+
#ifndef RCUTILS_NO_FILESYSTEM
340357
static void free_dir_list(dir_list_t * dir_list, rcutils_allocator_t allocator)
341358
{
342-
#ifdef RCUTILS_NO_FILESYSTEM
343-
RCUTILS_SET_ERROR_MSG("not available filesystem");
344-
#else
345359
dir_list_t * next_dir;
346360
do {
347361
next_dir = dir_list->next;
348362
allocator.deallocate(dir_list->path, allocator.state);
349363
allocator.deallocate(dir_list, allocator.state);
350364
dir_list = next_dir;
351365
} while (dir_list);
352-
#endif // _RCUTILS_NO_FILESYSTEM
353366
}
354367

355368
static void remove_first_dir_from_list(dir_list_t ** dir_list, rcutils_allocator_t allocator)
356369
{
357-
#ifdef RCUTILS_NO_FILESYSTEM
358-
RCUTILS_SET_ERROR_MSG("not available filesystem");
359-
#else
360370
dir_list_t * next_dir = (*dir_list)->next;
361371
allocator.deallocate((*dir_list)->path, allocator.state);
362372
allocator.deallocate(*dir_list, allocator.state);
363373
*dir_list = next_dir;
364-
#endif // _RCUTILS_NO_FILESYSTEM
365374
}
366375

367376
static rcutils_ret_t check_and_calculate_size(
@@ -371,10 +380,6 @@ static rcutils_ret_t check_and_calculate_size(
371380
dir_list_t * dir_list,
372381
rcutils_allocator_t allocator)
373382
{
374-
#ifdef RCUTILS_NO_FILESYSTEM
375-
RCUTILS_SET_ERROR_MSG("not available filesystem");
376-
return RCUTILS_RET_ERROR;
377-
#else
378383
// Skip over local folder handle (`.`) and parent folder (`..`)
379384
if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0) {
380385
return RCUTILS_RET_OK;
@@ -410,8 +415,8 @@ static rcutils_ret_t check_and_calculate_size(
410415
allocator.deallocate(file_path, allocator.state);
411416

412417
return RCUTILS_RET_OK;
413-
#endif // _RCUTILS_NO_FILESYSTEM
414418
}
419+
#endif // _RCUTILS_NO_FILESYSTEM
415420

416421
rcutils_ret_t
417422
rcutils_calculate_directory_size_with_recursion(
@@ -421,6 +426,10 @@ rcutils_calculate_directory_size_with_recursion(
421426
rcutils_allocator_t allocator)
422427
{
423428
#ifdef RCUTILS_NO_FILESYSTEM
429+
(void) directory_path;
430+
(void) max_depth;
431+
(void) size;
432+
(void) allocator;
424433
RCUTILS_SET_ERROR_MSG("not available filesystem");
425434
return RCUTILS_RET_ERROR;
426435
#else
@@ -495,6 +504,8 @@ rcutils_dir_iter_t *
495504
rcutils_dir_iter_start(const char * directory_path, const rcutils_allocator_t allocator)
496505
{
497506
#ifdef RCUTILS_NO_FILESYSTEM
507+
(void) directory_path;
508+
(void) allocator;
498509
RCUTILS_SET_ERROR_MSG("not available filesystem");
499510
return NULL;
500511
#else
@@ -566,6 +577,7 @@ bool
566577
rcutils_dir_iter_next(rcutils_dir_iter_t * iter)
567578
{
568579
#ifdef RCUTILS_NO_FILESYSTEM
580+
(void) iter;
569581
RCUTILS_SET_ERROR_MSG("not available filesystem");
570582
return false;
571583
#else
@@ -596,6 +608,7 @@ void
596608
rcutils_dir_iter_end(rcutils_dir_iter_t * iter)
597609
{
598610
#ifdef RCUTILS_NO_FILESYSTEM
611+
(void) iter;
599612
RCUTILS_SET_ERROR_MSG("not available filesystem");
600613
#else
601614
if (NULL == iter) {
@@ -625,6 +638,7 @@ rcutils_get_file_size(const char * file_path)
625638
{
626639

627640
#ifdef RCUTILS_NO_FILESYSTEM
641+
(void) file_path;
628642
RCUTILS_SET_ERROR_MSG("not available filesystem");
629643
return 0;
630644
#else

src/shared_library.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ rcutils_load_shared_library(
204204
#endif // _WIN32
205205

206206
#else
207+
(void) lib;
208+
(void) library_path;
209+
(void) allocator;
207210
return RCUTILS_RET_ERROR;
208211
#endif //RCUTILS_NO_FILESYSTEM
209212

@@ -212,6 +215,7 @@ rcutils_load_shared_library(
212215
void *
213216
rcutils_get_symbol(const rcutils_shared_library_t * lib, const char * symbol_name)
214217
{
218+
#ifndef RCUTILS_NO_FILESYSTEM
215219
if (!lib || !lib->lib_pointer || (symbol_name == NULL)) {
216220
RCUTILS_SET_ERROR_MSG("invalid inputs arguments");
217221
return NULL;
@@ -242,11 +246,17 @@ rcutils_get_symbol(const rcutils_shared_library_t * lib, const char * symbol_nam
242246
return NULL;
243247
}
244248
return lib_symbol;
249+
#else
250+
(void) lib;
251+
(void) symbol_name;
252+
return NULL;
253+
#endif //RCUTILS_NO_FILESYSTEM
245254
}
246255

247256
bool
248257
rcutils_has_symbol(const rcutils_shared_library_t * lib, const char * symbol_name)
249258
{
259+
#ifndef RCUTILS_NO_FILESYSTEM
250260
if (!lib || !lib->lib_pointer || symbol_name == NULL) {
251261
return false;
252262
}
@@ -262,11 +272,17 @@ rcutils_has_symbol(const rcutils_shared_library_t * lib, const char * symbol_nam
262272
void * lib_symbol = GetProcAddress((HINSTANCE)(lib->lib_pointer), symbol_name);
263273
return lib_symbol != NULL;
264274
#endif // _WIN32
275+
#else
276+
(void) lib;
277+
(void) symbol_name;
278+
return false;
279+
#endif //RCUTILS_NO_FILESYSTEM
265280
}
266281

267282
rcutils_ret_t
268283
rcutils_unload_shared_library(rcutils_shared_library_t * lib)
269284
{
285+
#ifndef RCUTILS_NO_FILESYSTEM
270286
RCUTILS_CHECK_ARGUMENT_FOR_NULL(lib, RCUTILS_RET_INVALID_ARGUMENT);
271287
RCUTILS_CHECK_ARGUMENT_FOR_NULL(lib->lib_pointer, RCUTILS_RET_INVALID_ARGUMENT);
272288
RCUTILS_CHECK_ARGUMENT_FOR_NULL(lib->library_path, RCUTILS_RET_INVALID_ARGUMENT);
@@ -292,6 +308,10 @@ rcutils_unload_shared_library(rcutils_shared_library_t * lib)
292308
lib->lib_pointer = NULL;
293309
lib->allocator = rcutils_get_zero_initialized_allocator();
294310
return ret;
311+
#else
312+
(void) lib;
313+
return RCUTILS_RET_ERROR;
314+
#endif //RCUTILS_NO_FILESYSTEM
295315
}
296316

297317
rcutils_ret_t
@@ -301,6 +321,7 @@ rcutils_get_platform_library_name(
301321
unsigned int buffer_size,
302322
bool debug)
303323
{
324+
#ifndef RCUTILS_NO_FILESYSTEM
304325
RCUTILS_CHECK_ARGUMENT_FOR_NULL(library_name, RCUTILS_RET_INVALID_ARGUMENT);
305326
RCUTILS_CHECK_ARGUMENT_FOR_NULL(library_name_platform, RCUTILS_RET_INVALID_ARGUMENT);
306327

@@ -350,6 +371,13 @@ rcutils_get_platform_library_name(
350371
return RCUTILS_RET_ERROR;
351372
}
352373
return RCUTILS_RET_OK;
374+
#else
375+
(void) library_name;
376+
(void) library_name_platform;
377+
(void) buffer_size;
378+
(void) debug;
379+
return RCUTILS_RET_ERROR;
380+
#endif //RCUTILS_NO_FILESYSTEM
353381
}
354382

355383
bool

0 commit comments

Comments
 (0)