lib: remove unneeded header includes
[dpdk.git] / lib / eal / common / eal_common_memzone.c
index 7c21aa9..860fb5f 100644 (file)
@@ -2,20 +2,16 @@
  * Copyright(c) 2010-2014 Intel Corporation
  */
 
-#include <stdlib.h>
 #include <stdio.h>
 #include <stdint.h>
-#include <stdarg.h>
 #include <inttypes.h>
 #include <string.h>
 #include <errno.h>
-#include <sys/queue.h>
 
 #include <rte_log.h>
 #include <rte_memory.h>
 #include <rte_memzone.h>
 #include <rte_eal.h>
-#include <rte_per_lcore.h>
 #include <rte_errno.h>
 #include <rte_string_fns.h>
 #include <rte_common.h>
@@ -53,6 +49,18 @@ memzone_lookup_thread_unsafe(const char *name)
        return NULL;
 }
 
+#define MEMZONE_KNOWN_FLAGS (RTE_MEMZONE_2MB \
+       | RTE_MEMZONE_1GB \
+       | RTE_MEMZONE_16MB \
+       | RTE_MEMZONE_16GB \
+       | RTE_MEMZONE_256KB \
+       | RTE_MEMZONE_256MB \
+       | RTE_MEMZONE_512MB \
+       | RTE_MEMZONE_4GB \
+       | RTE_MEMZONE_SIZE_HINT_ONLY \
+       | RTE_MEMZONE_IOVA_CONTIG \
+       )
+
 static const struct rte_memzone *
 memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
                int socket_id, unsigned int flags, unsigned int align,
@@ -128,6 +136,11 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len,
                return NULL;
        }
 
+       if ((flags & ~MEMZONE_KNOWN_FLAGS) != 0) {
+               rte_errno = EINVAL;
+               return NULL;
+       }
+
        /* only set socket to SOCKET_ID_ANY if we aren't allocating for an
         * external heap.
         */
@@ -283,8 +296,7 @@ rte_memzone_free(const struct rte_memzone *mz)
 
        rte_rwlock_write_unlock(&mcfg->mlock);
 
-       if (addr != NULL)
-               rte_free(addr);
+       rte_free(addr);
 
        rte_eal_trace_memzone_free(name, addr, ret);
        return ret;