[dpdk-dev,1/7] mempool: fix build with debug enabled
Commit Message
error: format ‘%p’ expects argument of type ‘void *’,
but argument 5 has type ‘const struct rte_mempool *’ [-Werror=format=]
mp type is (const struct rte_mempool *) and must be casted into a simpler
type to be printed.
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
lib/librte_mempool/rte_mempool.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
Hi Thomas,
On 03/03/2015 04:23 PM, Thomas Monjalon wrote:
> error: format ‘%p’ expects argument of type ‘void *’,
> but argument 5 has type ‘const struct rte_mempool *’ [-Werror=format=]
>
> mp type is (const struct rte_mempool *) and must be casted into a simpler
> type to be printed.
I was a bit surprised to see this warning although the standard says:
The argument shall be a pointer to void. The value of the pointer is
converted to a sequence of printing wide characters, in an
implementation-defined manner.
But I think we often do this in dpdk, without any warning:
struct foo_s *foo = ...;
printf("%p\n", foo);
After some search, the reason why you get a warning here is that you
compile a C file that includes this header with the "-pedantic" flag.
So, I think doing this fix is justified for header files as we cannot
predict which options are used by the user of these headers.
So:
Acked-by: Olivier Matz <olivier.matz@6wind.com>
@@ -345,7 +345,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
rte_log_set_history(0);
RTE_LOG(CRIT, MEMPOOL,
"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
- obj, mp, cookie);
+ obj, (const void *) mp, cookie);
rte_panic("MEMPOOL: bad header cookie (put)\n");
}
__mempool_write_header_cookie(obj, 1);
@@ -355,7 +355,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
rte_log_set_history(0);
RTE_LOG(CRIT, MEMPOOL,
"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
- obj, mp, cookie);
+ obj, (const void *) mp, cookie);
rte_panic("MEMPOOL: bad header cookie (get)\n");
}
__mempool_write_header_cookie(obj, 0);
@@ -366,7 +366,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
rte_log_set_history(0);
RTE_LOG(CRIT, MEMPOOL,
"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
- obj, mp, cookie);
+ obj, (const void *) mp, cookie);
rte_panic("MEMPOOL: bad header cookie (audit)\n");
}
}
@@ -375,7 +375,7 @@ static inline void __mempool_check_cookies(const struct rte_mempool *mp,
rte_log_set_history(0);
RTE_LOG(CRIT, MEMPOOL,
"obj=%p, mempool=%p, cookie=%" PRIx64 "\n",
- obj, mp, cookie);
+ obj, (const void *) mp, cookie);
rte_panic("MEMPOOL: bad trailer cookie\n");
}
}