Hi,
while compiling on gcc 7.2.0 (on ARM), I got this warning:
rangetypes_spgist.c: In function 'spg_range_quad_inner_consistent':
rangetypes_spgist.c:559:29: warning: comparison between pointer and
zero character constant [-Wpointer-compare]
if (in->traversalValue != (Datum) 0)
^~
rangetypes_spgist.c:559:10: note: did you mean to dereference the
pointer?
if (in->traversalValue != (Datum) 0)
^
I believe we should simply treat the traversalValue as pointer, and
change the condition to
if (in->traversalValue)
Patch attached.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 3b0528e9b56b9ff2dec4c3670d78ad9018224065 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <[email protected]>
Date: Sat, 18 Nov 2017 20:25:02 +0100
Subject: [PATCH] Fix compiler warning when comparing traversalValue
On gcc 7.2.0, comparing pointer to (Datum)0 produces a warning. Treat
it as a simple pointer to fix that.
---
src/backend/utils/adt/rangetypes_spgist.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/utils/adt/rangetypes_spgist.c b/src/backend/utils/adt/rangetypes_spgist.c
index d934105..27fbf66 100644
--- a/src/backend/utils/adt/rangetypes_spgist.c
+++ b/src/backend/utils/adt/rangetypes_spgist.c
@@ -556,7 +556,7 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
* for lower or upper bounds to be adjacent. Deserialize
* previous centroid range if present for checking this.
*/
- if (in->traversalValue != (Datum) 0)
+ if (in->traversalValue)
{
prevCentroid = DatumGetRangeTypeP(in->traversalValue);
range_deserialize(typcache, prevCentroid,
--
2.9.5