summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarcel Huber <[email protected]>2014-05-21 11:17:23 +0200
committerBrian Behlendorf <[email protected]>2014-05-22 09:44:15 -0700
commit58bd7ad060b4675c47389844da25f7c25a209704 (patch)
tree9a9ed85d32f14b43e713d535e5213bc4ca252282 /lib
parent5f3c101b8ff05a5af9e83a5e86b5019bd6b02a3c (diff)
Omit compiler warning by sticking to RAII
Resolve gcc 4.9.0 20140507 warnings about uninitialized 'ptr' when using -Wmaybe-uninitialized. The first two cases appears appear to be legitimate but not the second two. In general this is a good practice so they are all initialized. Signed-off-by: Marcel Huber <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #2345
Diffstat (limited to 'lib')
-rw-r--r--lib/libspl/include/umem.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libspl/include/umem.h b/lib/libspl/include/umem.h
index 0d0778cfb..b3ce6e710 100644
--- a/lib/libspl/include/umem.h
+++ b/lib/libspl/include/umem.h
@@ -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);
@@ -117,7 +117,7 @@ umem_alloc_aligned(size_t size, size_t align, int flags)
static inline void *
umem_zalloc(size_t size, int flags)
{
- void *ptr;
+ void *ptr = NULL;
ptr = umem_alloc(size, flags);
if (ptr)
@@ -170,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(