]> git.proxmox.com Git - mirror_zfs-debian.git/blobdiff - lib/libspl/include/umem.h
Imported Upstream version 0.6.4.2
[mirror_zfs-debian.git] / lib / libspl / include / umem.h
index 68ff9a576c0500105bdfd66b06c361aa837efc38..b3ce6e710548e0b1305489b32b079db6e951403e 100644 (file)
@@ -82,7 +82,7 @@ typedef struct umem_cache {
 static inline void *
 umem_alloc(size_t size, int flags)
 {
-       void *ptr;
+       void *ptr = NULL;
 
        do {
                ptr = malloc(size);
@@ -94,8 +94,8 @@ umem_alloc(size_t size, int flags)
 static inline void *
 umem_alloc_aligned(size_t size, size_t align, int flags)
 {
-       void *ptr;
-       int rc;
+       void *ptr = NULL;
+       int rc = EINVAL;
 
        do {
                rc = posix_memalign(&ptr, align, size);
@@ -109,13 +109,15 @@ umem_alloc_aligned(size_t size, size_t align, int flags)
                return (NULL);
        }
 
+       ASSERT0(P2PHASE_TYPED(ptr, align, uint64_t));
+
        return (ptr);
 }
 
 static inline void *
 umem_zalloc(size_t size, int flags)
 {
-       void *ptr;
+       void *ptr = NULL;
 
        ptr = umem_alloc(size, flags);
        if (ptr)
@@ -168,7 +170,7 @@ umem_cache_destroy(umem_cache_t *cp)
 static inline void *
 umem_cache_alloc(umem_cache_t *cp, int flags)
 {
-       void *ptr;
+       void *ptr = NULL;
 
        if (cp->cache_align != 0)
                ptr = umem_alloc_aligned(