diff --git a/platforms/posix/include/windows_shim/dirent.h b/platforms/posix/include/windows_shim/dirent.h index e2b0fa6b45..2a37858086 100644 --- a/platforms/posix/include/windows_shim/dirent.h +++ b/platforms/posix/include/windows_shim/dirent.h @@ -108,10 +108,10 @@ typedef struct px4_dir_shim { */ static inline DIR *opendir(const char *name) { - if (!name) { errno = EINVAL; return NULL; } + if (!name) { errno = EINVAL; return nullptr; } DIR *d = (DIR *)calloc(1, sizeof(DIR)); - if (!d) { errno = ENOMEM; return NULL; } + if (!d) { errno = ENOMEM; return nullptr; } /* Translate "foo" -> "foo\*" so FindFirstFile enumerates the * directory's contents rather than matching the directory itself. */ @@ -119,14 +119,14 @@ static inline DIR *opendir(const char *name) if (n <= 0 || (size_t)n >= sizeof(d->pattern)) { free(d); errno = ENAMETOOLONG; - return NULL; + return nullptr; } d->handle = FindFirstFileA(d->pattern, &d->find_data); if (d->handle == INVALID_HANDLE_VALUE) { free(d); errno = ENOENT; - return NULL; + return nullptr; } d->first = 1; d->offset = 0; @@ -141,12 +141,12 @@ static inline DIR *opendir(const char *name) */ static inline struct dirent *readdir(DIR *d) { - if (!d) { errno = EBADF; return NULL; } + if (!d) { errno = EBADF; return nullptr; } if (d->first) { d->first = 0; } else if (!FindNextFileA(d->handle, &d->find_data)) { - return NULL; /* end of directory */ + return nullptr; /* end of directory */ } strncpy(d->entry.d_name, d->find_data.cFileName, NAME_MAX); @@ -245,7 +245,7 @@ static inline int scandir(const char *dirp, struct dirent ***namelist, return -1; } - *namelist = NULL; + *namelist = nullptr; DIR *dir = opendir(dirp); @@ -255,17 +255,17 @@ static inline int scandir(const char *dirp, struct dirent ***namelist, size_t count = 0; size_t capacity = 0; - struct dirent **list = NULL; - struct dirent *entry = NULL; + struct dirent **list = nullptr; + struct dirent *entry = nullptr; - while ((entry = readdir(dir)) != NULL) { + while ((entry = readdir(dir)) != nullptr) { if (select && !select(entry)) { continue; } if (count == capacity) { size_t next_capacity = capacity ? capacity * 2 : 16; - struct dirent **next = (struct dirent **)realloc(list, next_capacity * sizeof(*next)); + struct dirent **next = (struct dirent **)realloc(list, next_capacity * sizeof(struct dirent *)); if (!next) { for (size_t i = 0; i < count; ++i) { @@ -302,7 +302,7 @@ static inline int scandir(const char *dirp, struct dirent ***namelist, closedir(dir); if (compar && count > 1) { - qsort(list, count, sizeof(*list), (int (*)(const void *, const void *))compar); + qsort(list, count, sizeof(struct dirent *), (int (*)(const void *, const void *))compar); } *namelist = list; diff --git a/platforms/posix/src/px4/common/lockstep_scheduler/test/src/lockstep_scheduler_test.cpp b/platforms/posix/src/px4/common/lockstep_scheduler/test/src/lockstep_scheduler_test.cpp index be2ddc3b28..c3ac42e3b7 100644 --- a/platforms/posix/src/px4/common/lockstep_scheduler/test/src/lockstep_scheduler_test.cpp +++ b/platforms/posix/src/px4/common/lockstep_scheduler/test/src/lockstep_scheduler_test.cpp @@ -127,10 +127,10 @@ void test_locked_semaphore_getting_unlocked() void test_condition_signal_wakes_without_time_advance() { pthread_cond_t cond; - pthread_cond_init(&cond, NULL); + pthread_cond_init(&cond, nullptr); pthread_mutex_t lock; - pthread_mutex_init(&lock, NULL); + pthread_mutex_init(&lock, nullptr); LockstepScheduler ls; ls.set_absolute_time(some_time_us);