Commit f314f0ca authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

env/vtophys: eliminate redundant error check



Change-Id: I238b02e2df154b2ac40c746f156c0746f2518764
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 302804d1
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@
#include <rte_config.h>
#include <rte_eal_memconfig.h>

#include "spdk/assert.h"

/* x86-64 userspace virtual addresses use only the low 47 bits [0..46],
 * which is enough to cover 128 TB.
 */
@@ -344,9 +346,12 @@ spdk_vtophys(void *buf)
	map_2mb = &map_1gb->map[idx_1gb];

	paddr_2mb = map_2mb->paddr_2mb;
	if (paddr_2mb == SPDK_VTOPHYS_ERROR) {
		return SPDK_VTOPHYS_ERROR;
	}

	/*
	 * SPDK_VTOPHYS_ERROR has all bits set, so if the lookup returned SPDK_VTOPHYS_ERROR,
	 * we will still bitwise-or it with the buf offset below, but the result will still be
	 * SPDK_VTOPHYS_ERROR.
	 */
	SPDK_STATIC_ASSERT(SPDK_VTOPHYS_ERROR == UINT64_C(-1), "SPDK_VTOPHYS_ERROR should be all 1s");
	return paddr_2mb | ((uint64_t)buf & MASK_2MB);
}