]> granicus.if.org Git - postgis/commitdiff
Postgres 12 disallows variable length arrays in C, raster part
authorDarafei Praliaskouski <me@komzpa.net>
Thu, 13 Sep 2018 17:25:51 +0000 (17:25 +0000)
committerDarafei Praliaskouski <me@komzpa.net>
Thu, 13 Sep 2018 17:25:51 +0000 (17:25 +0000)
Patch by Laurenz Albe

Closes #4177

git-svn-id: http://svn.osgeo.org/postgis/trunk@16780 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rtpg_band_properties.c
raster/rt_pg/rtpg_gdal.c
raster/rt_pg/rtpg_geometry.c
raster/rt_pg/rtpg_mapalgebra.c
raster/rt_pg/rtpg_pixel.c
raster/rt_pg/rtpg_raster_properties.c
raster/rt_pg/rtpg_statistics.c

index 70b652fa3c0277eda0324082442322315683e615..1755c0dd118e26656870955e37acbdf7bddf3506 100644 (file)
@@ -464,6 +464,8 @@ Datum RASTER_getBandFileTimestamp(PG_FUNCTION_ARGS)
     PG_RETURN_INT64(fileSize);
 }
 
+#define VALUES_LENGTH 8
+
 /**
  * Get raster bands' meta data
  */
@@ -711,11 +713,10 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 8;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = UInt32GetDatum(bmd2[call_cntr].bandnum);
                values[1] = CStringGetTextDatum(bmd2[call_cntr].pixeltype);
index dd3a8ff3e2315a363a6599ac2457fcd396ac20ce..94f0bc151b81f8e0c99acec5bdbec7df8a298b69 100644 (file)
@@ -330,6 +330,8 @@ Datum RASTER_asGDALRaster(PG_FUNCTION_ARGS)
        PG_RETURN_POINTER(result);
 }
 
+#define VALUES_LENGTH 6
+
 /**
  * Returns available GDAL drivers
  */
@@ -396,15 +398,14 @@ Datum RASTER_getGDALDrivers(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 6;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
                POSTGIS_RT_DEBUGF(3, "Result %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = Int32GetDatum(drv_set2[call_cntr].idx);
                values[1] = CStringGetTextDatum(drv_set2[call_cntr].short_name);
index ea58f0003c395d3df4a61617e53c0deedcac1c92..4162c1394d1dd0628443203150d631712a768185 100644 (file)
@@ -188,6 +188,8 @@ Datum RASTER_convex_hull(PG_FUNCTION_ARGS)
        PG_RETURN_POINTER(gser);
 }
 
+#define VALUES_LENGTH 2
+
 PG_FUNCTION_INFO_V1(RASTER_dumpAsPolygons);
 Datum RASTER_dumpAsPolygons(PG_FUNCTION_ARGS) {
        FuncCallContext *funcctx;
@@ -309,9 +311,8 @@ Datum RASTER_dumpAsPolygons(PG_FUNCTION_ARGS) {
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 2;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple    tuple;
                Datum        result;
 
@@ -320,7 +321,7 @@ Datum RASTER_dumpAsPolygons(PG_FUNCTION_ARGS) {
 
                POSTGIS_RT_DEBUGF(3, "call number %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                /* convert LWGEOM to GSERIALIZED */
                gser = gserialized_from_lwgeom(lwpoly_as_lwgeom(geomval2[call_cntr].geom), &gser_size);
@@ -344,6 +345,9 @@ Datum RASTER_dumpAsPolygons(PG_FUNCTION_ARGS) {
        }
 }
 
+#undef VALUES_LENGTH
+#define VALUES_LENGTH 4
+
 /**
  * Return the geographical shape of all pixels
  */
@@ -611,9 +615,8 @@ Datum RASTER_getPixelPolygons(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 4;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
@@ -622,7 +625,7 @@ Datum RASTER_getPixelPolygons(PG_FUNCTION_ARGS)
 
                POSTGIS_RT_DEBUGF(3, "call number %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                /* convert LWGEOM to GSERIALIZED */
                gser = gserialized_from_lwgeom(pix2[call_cntr].geom, &gser_size);
index 01eb2a373350556527db4fc5196e7229901a8061..e41046d0ac8b30356f502828924c018e680f7457 100644 (file)
@@ -6068,6 +6068,8 @@ Datum RASTER_mapAlgebraFctNgb(PG_FUNCTION_ARGS)
     PG_RETURN_POINTER(pgrtn);
 }
 
+#define ARGKWCOUNT 8
+
 /**
  * Two raster MapAlgebra
  */
@@ -6115,11 +6117,10 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
        SPIPlanPtr spi_plan[3] = {NULL};
        uint16_t spi_empty = 0;
        Oid *argtype = NULL;
-       const uint32_t argkwcount = 8;
        uint8_t argpos[3][8] = {{0}};
        char *argkw[] = {"[rast1.x]", "[rast1.y]", "[rast1.val]", "[rast1]", "[rast2.x]", "[rast2.y]", "[rast2.val]", "[rast2]"};
-       Datum values[argkwcount];
-       char nulls[argkwcount];
+       Datum values[ARGKWCOUNT];
+       char nulls[ARGKWCOUNT];
        TupleDesc tupdesc;
        SPITupleTable *tuptable = NULL;
        HeapTuple tuple;
@@ -6639,7 +6640,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
                                        expr = text_to_cstring(PG_GETARG_TEXT_P(spi_exprpos[i]));
                                        POSTGIS_RT_DEBUGF(3, "raw expr #%d: %s", i, expr);
 
-                                       for (j = 0, k = 1; j < argkwcount; j++) {
+                                       for (j = 0, k = 1; j < ARGKWCOUNT; j++) {
                                                /* attempt to replace keyword with placeholder */
                                                len = 0;
                                                tmp = rtpg_strreplace(expr, argkw[j], place, &len);
@@ -6704,7 +6705,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
                                                }
 
                                                /* specify datatypes of parameters */
-                                               for (j = 0, k = 0; j < argkwcount; j++) {
+                                               for (j = 0, k = 0; j < ARGKWCOUNT; j++) {
                                                        if (argpos[i][j] < 1) continue;
 
                                                        /* positions are INT4 */
@@ -7003,14 +7004,14 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
                                                        POSTGIS_RT_DEBUGF(4, "Using prepared plan: %d", i);
 
                                                        /* reset values to (Datum) NULL */
-                                                       memset(values, (Datum) NULL, sizeof(Datum) * argkwcount);
+                                                       memset(values, (Datum) NULL, sizeof(Datum) * ARGKWCOUNT);
                                                        /* reset nulls to FALSE */
-                                                       memset(nulls, FALSE, sizeof(char) * argkwcount);
+                                                       memset(nulls, FALSE, sizeof(char) * ARGKWCOUNT);
 
                                                        /* expression has argument(s) */
                                                        if (spi_argcount[i]) {
                                                                /* set values and nulls */
-                                                               for (j = 0; j < argkwcount; j++) {
+                                                               for (j = 0; j < ARGKWCOUNT; j++) {
                                                                        idx = argpos[i][j];
                                                                        if (idx < 1) continue;
                                                                        idx--; /* 1-based becomes 0-based */
index 22260657fb1a1a0092a0c69d7acc6c3e38f0b22e..749bcbae92a46a3b74da94b962492192a5608137 100644 (file)
@@ -197,6 +197,8 @@ static void rtpg_dumpvalues_arg_destroy(rtpg_dumpvalues_arg arg) {
        pfree(arg);
 }
 
+#define VALUES_LENGTH 2
+
 PG_FUNCTION_INFO_V1(RASTER_dumpValues);
 Datum RASTER_dumpValues(PG_FUNCTION_ARGS)
 {
@@ -514,9 +516,8 @@ Datum RASTER_dumpValues(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 2;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
                ArrayType *mdValues = NULL;
@@ -527,7 +528,7 @@ Datum RASTER_dumpValues(PG_FUNCTION_ARGS)
                POSTGIS_RT_DEBUGF(3, "call number %d", call_cntr);
                POSTGIS_RT_DEBUGF(4, "dim = %d, %d", dim[0], dim[1]);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = Int32GetDatum(arg2->nbands[call_cntr] + 1);
 
@@ -1601,6 +1602,9 @@ Datum RASTER_setPixelValuesGeomval(PG_FUNCTION_ARGS)
        PG_RETURN_POINTER(pgrtn);
 }
 
+#undef VALUES_LENGTH
+#define VALUES_LENGTH 3
+
 /**
  * Get pixels of value
  */
@@ -1799,13 +1803,12 @@ Datum RASTER_pixelOfValue(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 3;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                /* 0-based to 1-based */
                pixels2[call_cntr].x += 1;
index 96624df1c80ba14d5ec119a599ff62fdc92450da..8d90631e7dd72e64ea1faa88e4e328fa85626b0a 100644 (file)
@@ -429,6 +429,8 @@ Datum RASTER_getPixelHeight(PG_FUNCTION_ARGS)
     PG_RETURN_FLOAT8(pheight);
 }
 
+#define VALUES_LENGTH 6
+
 /**
  * Calculates the physically relevant parameters of the supplied raster's
  * geotransform. Returns them as a set.
@@ -449,9 +451,8 @@ Datum RASTER_getGeotransform(PG_FUNCTION_ARGS)
                */
 
     TupleDesc result_tuple; /* for returning a composite */
-    int values_length = 6;
-    Datum values[values_length];
-    bool nulls[values_length];
+    Datum values[VALUES_LENGTH];
+    bool nulls[VALUES_LENGTH];
     HeapTuple heap_tuple ;   /* instance of the tuple to return */
     Datum result;
 
@@ -503,7 +504,7 @@ Datum RASTER_getGeotransform(PG_FUNCTION_ARGS)
     values[4] = Float8GetDatum(rt_raster_get_x_offset(raster));
     values[5] = Float8GetDatum(rt_raster_get_y_offset(raster));
 
-    memset(nulls, FALSE, sizeof(bool) * values_length);
+    memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
     /* stick em on the heap */
     heap_tuple = heap_form_tuple(result_tuple, values, nulls);
@@ -581,6 +582,9 @@ Datum RASTER_hasNoBand(PG_FUNCTION_ARGS)
     PG_RETURN_BOOL(hasnoband);
 }
 
+#undef VALUES_LENGTH
+#define VALUES_LENGTH 10
+
 /**
  * Get raster's meta data
  */
@@ -602,9 +606,8 @@ Datum RASTER_metadata(PG_FUNCTION_ARGS)
        uint32_t height;
 
        TupleDesc tupdesc;
-       int values_length = 10;
-       Datum values[values_length];
-       bool nulls[values_length];
+       Datum values[VALUES_LENGTH];
+       bool nulls[VALUES_LENGTH];
        HeapTuple tuple;
        Datum result;
 
@@ -672,7 +675,7 @@ Datum RASTER_metadata(PG_FUNCTION_ARGS)
        values[8] = Int32GetDatum(srid);
        values[9] = UInt32GetDatum(numBands);
 
-       memset(nulls, FALSE, sizeof(bool) * values_length);
+       memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
        /* build a tuple */
        tuple = heap_form_tuple(tupdesc, values, nulls);
@@ -683,6 +686,9 @@ Datum RASTER_metadata(PG_FUNCTION_ARGS)
        PG_RETURN_DATUM(result);
 }
 
+#undef VALUES_LENGTH
+#define VALUES_LENGTH 2
+
 PG_FUNCTION_INFO_V1(RASTER_rasterToWorldCoord);
 Datum RASTER_rasterToWorldCoord(PG_FUNCTION_ARGS)
 {
@@ -694,9 +700,8 @@ Datum RASTER_rasterToWorldCoord(PG_FUNCTION_ARGS)
        double cw[2] = {0};
 
        TupleDesc tupdesc;
-       int values_length = 2;
-       Datum values[values_length];
-       bool nulls[values_length];
+       Datum values[VALUES_LENGTH];
+       bool nulls[VALUES_LENGTH];
        HeapTuple tuple;
        Datum result;
 
@@ -767,7 +772,7 @@ Datum RASTER_rasterToWorldCoord(PG_FUNCTION_ARGS)
        values[0] = Float8GetDatum(cw[0]);
        values[1] = Float8GetDatum(cw[1]);
 
-       memset(nulls, FALSE, sizeof(bool) * values_length);
+       memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
        /* build a tuple */
        tuple = heap_form_tuple(tupdesc, values, nulls);
@@ -790,9 +795,8 @@ Datum RASTER_worldToRasterCoord(PG_FUNCTION_ARGS)
        bool skewed = false;
 
        TupleDesc tupdesc;
-       int values_length = 2;
-       Datum values[values_length];
-       bool nulls[values_length];
+       Datum values[VALUES_LENGTH];
+       bool nulls[VALUES_LENGTH];
        HeapTuple tuple;
        Datum result;
 
@@ -868,7 +872,7 @@ Datum RASTER_worldToRasterCoord(PG_FUNCTION_ARGS)
        values[0] = Int32GetDatum(cr[0]);
        values[1] = Int32GetDatum(cr[1]);
 
-       memset(nulls, FALSE, sizeof(bool) * values_length);
+       memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
        /* build a tuple */
        tuple = heap_form_tuple(tupdesc, values, nulls);
index 290ba4bc09baba4f5b5c221492734ca6247b5903..bb1e51c5b5924e9a68b02d3697742c5a9f7ab6cb 100644 (file)
@@ -64,6 +64,8 @@ Datum RASTER_quantileCoverage(PG_FUNCTION_ARGS);
 Datum RASTER_valueCount(PG_FUNCTION_ARGS);
 Datum RASTER_valueCountCoverage(PG_FUNCTION_ARGS);
 
+#define VALUES_LENGTH 6
+
 /**
  * Get summary stats of a band
  */
@@ -80,9 +82,8 @@ Datum RASTER_summaryStats(PG_FUNCTION_ARGS)
        rt_bandstats stats = NULL;
 
        TupleDesc tupdesc;
-       int values_length = 6;
-       Datum values[values_length];
-       bool nulls[values_length];
+       Datum values[VALUES_LENGTH];
+       bool nulls[VALUES_LENGTH];
        HeapTuple tuple;
        Datum result;
 
@@ -160,7 +161,7 @@ Datum RASTER_summaryStats(PG_FUNCTION_ARGS)
 
        BlessTupleDesc(tupdesc);
 
-       memset(nulls, FALSE, sizeof(bool) * values_length);
+       memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
        values[0] = Int64GetDatum(stats->count);
        if (stats->count > 0) {
@@ -224,9 +225,8 @@ Datum RASTER_summaryStatsCoverage(PG_FUNCTION_ARGS)
        rt_bandstats stats = NULL;
        rt_bandstats rtn = NULL;
 
-       int values_length = 6;
-       Datum values[values_length];
-       bool nulls[values_length];
+       Datum values[VALUES_LENGTH];
+       bool nulls[VALUES_LENGTH];
        Datum result;
 
        /* tablename is null, return null */
@@ -458,7 +458,7 @@ Datum RASTER_summaryStatsCoverage(PG_FUNCTION_ARGS)
 
        BlessTupleDesc(tupdesc);
 
-       memset(nulls, FALSE, sizeof(bool) * values_length);
+       memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
        values[0] = Int64GetDatum(rtn->count);
        if (rtn->count > 0) {
@@ -829,9 +829,8 @@ Datum RASTER_summaryStats_finalfn(PG_FUNCTION_ARGS)
 
        TupleDesc tupdesc;
        HeapTuple tuple;
-       int values_length = 6;
-       Datum values[values_length];
-       bool nulls[values_length];
+       Datum values[VALUES_LENGTH];
+       bool nulls[VALUES_LENGTH];
        Datum result;
 
        POSTGIS_RT_DEBUG(3, "Starting...");
@@ -878,7 +877,7 @@ Datum RASTER_summaryStats_finalfn(PG_FUNCTION_ARGS)
 
        BlessTupleDesc(tupdesc);
 
-       memset(nulls, FALSE, sizeof(bool) * values_length);
+       memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
        values[0] = Int64GetDatum(state->stats->count);
        if (state->stats->count > 0) {
@@ -908,6 +907,9 @@ Datum RASTER_summaryStats_finalfn(PG_FUNCTION_ARGS)
        PG_RETURN_DATUM(result);
 }
 
+#undef VALUES_LENGTH
+#define VALUES_LENGTH 4
+
 /**
  * Returns histogram for a band
  */
@@ -1153,15 +1155,14 @@ Datum RASTER_histogram(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 4;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
                POSTGIS_RT_DEBUGF(3, "Result %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = Float8GetDatum(hist2[call_cntr].min);
                values[1] = Float8GetDatum(hist2[call_cntr].max);
@@ -1680,15 +1681,14 @@ Datum RASTER_histogramCoverage(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 4;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
                POSTGIS_RT_DEBUGF(3, "Result %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = Float8GetDatum(covhist2[call_cntr].min);
                values[1] = Float8GetDatum(covhist2[call_cntr].max);
@@ -1710,6 +1710,9 @@ Datum RASTER_histogramCoverage(PG_FUNCTION_ARGS)
        }
 }
 
+#undef VALUES_LENGTH
+#define VALUES_LENGTH 2
+
 /**
  * Returns quantiles for a band
  */
@@ -1932,15 +1935,14 @@ Datum RASTER_quantile(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 2;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
                POSTGIS_RT_DEBUGF(3, "Result %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = Float8GetDatum(quant2[call_cntr].quantile);
                values[1] = Float8GetDatum(quant2[call_cntr].value);
@@ -2359,15 +2361,14 @@ Datum RASTER_quantileCoverage(PG_FUNCTION_ARGS)
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 2;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
                POSTGIS_RT_DEBUGF(3, "Result %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = Float8GetDatum(covquant2[call_cntr].quantile);
                if (covquant2[call_cntr].has_value)
@@ -2391,6 +2392,9 @@ Datum RASTER_quantileCoverage(PG_FUNCTION_ARGS)
        }
 }
 
+#undef VALUES_LENGTH
+#define VALUES_LENGTH 3
+
 /* get counts of values */
 PG_FUNCTION_INFO_V1(RASTER_valueCount);
 Datum RASTER_valueCount(PG_FUNCTION_ARGS) {
@@ -2573,15 +2577,14 @@ Datum RASTER_valueCount(PG_FUNCTION_ARGS) {
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 3;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
                POSTGIS_RT_DEBUGF(3, "Result %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = Float8GetDatum(vcnts2[call_cntr].value);
                values[1] = UInt32GetDatum(vcnts2[call_cntr].count);
@@ -3001,15 +3004,14 @@ Datum RASTER_valueCountCoverage(PG_FUNCTION_ARGS) {
 
        /* do when there is more left to send */
        if (call_cntr < max_calls) {
-               int values_length = 3;
-               Datum values[values_length];
-               bool nulls[values_length];
+               Datum values[VALUES_LENGTH];
+               bool nulls[VALUES_LENGTH];
                HeapTuple tuple;
                Datum result;
 
                POSTGIS_RT_DEBUGF(3, "Result %d", call_cntr);
 
-               memset(nulls, FALSE, sizeof(bool) * values_length);
+               memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
                values[0] = Float8GetDatum(covvcnts2[call_cntr].value);
                values[1] = UInt32GetDatum(covvcnts2[call_cntr].count);