[clang] fix a few warnings

Mostly dealing with comparing a pointer variable that is declared
nonnull, which I find to be a dubious warning but is pretty safe in this
case since the compiler will be more aggressive about the nullness of
the arguments.
This commit is contained in:
Travis Geiselbrecht
2025-10-05 13:33:13 -07:00
parent 64e1ccfe78
commit 48d331f144
4 changed files with 6 additions and 13 deletions

View File

@@ -34,7 +34,7 @@ static mutex_t lock = MUTEX_INITIAL_VALUE(lock);
#define ADDRESS_IN_ARENA(address, arena) \ #define ADDRESS_IN_ARENA(address, arena) \
((address) >= (arena)->base && (address) <= (arena)->base + (arena)->size - 1) ((address) >= (arena)->base && (address) <= (arena)->base + (arena)->size - 1)
struct list_node *get_arena_list() { return &arena_list; } struct list_node *get_arena_list(void) { return &arena_list; }
static inline bool page_is_free(const vm_page_t *page) { static inline bool page_is_free(const vm_page_t *page) {
return !(page->flags & VM_PAGE_FLAG_NONFREE); return !(page->flags & VM_PAGE_FLAG_NONFREE);

View File

@@ -298,8 +298,6 @@ status_t vmm_reserve_space(vmm_aspace_t *aspace, const char *name, size_t size,
if (!name) if (!name)
name = ""; name = "";
if (!aspace)
return ERR_INVALID_ARGS;
if (size == 0) if (size == 0)
return NO_ERROR; return NO_ERROR;
if (!IS_PAGE_ALIGNED(vaddr) || !IS_PAGE_ALIGNED(size)) if (!IS_PAGE_ALIGNED(vaddr) || !IS_PAGE_ALIGNED(size))
@@ -339,8 +337,6 @@ status_t vmm_alloc_physical(vmm_aspace_t *aspace, const char *name, size_t size,
if (!name) if (!name)
name = ""; name = "";
if (!aspace)
return ERR_INVALID_ARGS;
if (size == 0) if (size == 0)
return NO_ERROR; return NO_ERROR;
if (!IS_PAGE_ALIGNED(paddr) || !IS_PAGE_ALIGNED(size)) if (!IS_PAGE_ALIGNED(paddr) || !IS_PAGE_ALIGNED(size))

View File

@@ -276,7 +276,7 @@ status_t fs_open_file(const char *path, filehandle **handle) {
status_t fs_file_ioctl(filehandle *handle, int request, void *argp) { status_t fs_file_ioctl(filehandle *handle, int request, void *argp) {
LTRACEF("filehandle %p, request %d, argp, %p\n", handle, request, argp); LTRACEF("filehandle %p, request %d, argp, %p\n", handle, request, argp);
if (unlikely(!handle || !handle->mount || if (unlikely(!handle->mount ||
!handle->mount->api || !handle->mount->api->file_ioctl)) { !handle->mount->api || !handle->mount->api->file_ioctl)) {
return ERR_INVALID_ARGS; return ERR_INVALID_ARGS;
} }
@@ -322,9 +322,6 @@ status_t fs_create_file(const char *path, filehandle **handle, uint64_t len) {
status_t fs_truncate_file(filehandle *handle, uint64_t len) { status_t fs_truncate_file(filehandle *handle, uint64_t len) {
LTRACEF("filehandle %p, length %llu\n", handle, len); LTRACEF("filehandle %p, length %llu\n", handle, len);
if (unlikely(!handle))
return ERR_INVALID_ARGS;
return handle->mount->api->truncate(handle->cookie, len); return handle->mount->api->truncate(handle->cookie, len);
} }
@@ -461,10 +458,6 @@ status_t fs_close_dir(dirhandle *handle) {
status_t fs_stat_fs(const char *mountpoint, struct fs_stat *stat) { status_t fs_stat_fs(const char *mountpoint, struct fs_stat *stat) {
LTRACEF("mountpoint %s stat %p\n", mountpoint, stat); LTRACEF("mountpoint %s stat %p\n", mountpoint, stat);
if (!stat) {
return ERR_INVALID_ARGS;
}
const char *newpath; const char *newpath;
struct fs_mount *mount = find_mount(mountpoint, &newpath); struct fs_mount *mount = find_mount(mountpoint, &newpath);
if (!mount) { if (!mount) {

View File

@@ -50,6 +50,10 @@ static __inline void swapfunc(char *, char *, int, int);
} while (--i > 0); \ } while (--i > 0); \
} }
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wnull-pointer-subtraction"
#endif
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ #define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;