[postgis-tickets] [SCM] PostGIS; Spatial objects for PostgreSQL. branch master updated. 0cbdd4d61558320575c6ec9f7e775ed785bdcfee
git at osgeo.org
git at osgeo.org
Mon Nov 11 21:53:50 PST 2019
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS; Spatial objects for PostgreSQL.".
The branch, master has been updated
via 0cbdd4d61558320575c6ec9f7e775ed785bdcfee (commit)
via 15151172faa487dfc3489bd6ab21c9ea305a98ef (commit)
from e9f44e9b44b64719b33a8a6983f9e0621c6ab78f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0cbdd4d61558320575c6ec9f7e775ed785bdcfee
Author: Darafei Praliaskouski <me at komzpa.net>
Date: Sun Nov 10 20:15:42 2019 +0300
Enable Link Time Optimization if available in compiler
diff --git a/NEWS b/NEWS
index 478e3ce..97c8bc4 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ PostGIS 3.1.0
- #4539, Unify libm includes (Raúl Marín)
- #4569, Allow unknown SRID geometry insertion into typmod SRID column (Paul Ramsey)
- #4149, ST_Simplify(geom, 0) is now O(N) (Darafei Praliaskouski)
+ - #4574, Link Time Optimizations enabled (Darafei Praliaskouski)
* Bug fixes *
- #4544, Fix leak when parsing a WKT geometry_list (Raúl Marín)
diff --git a/ci/travis/run_usan_clang.sh b/ci/travis/run_usan_clang.sh
index a3126ac..74226ef 100644
--- a/ci/travis/run_usan_clang.sh
+++ b/ci/travis/run_usan_clang.sh
@@ -3,7 +3,7 @@ set -e
# Enable undefined behaviour sanitizer using traps
CFLAGS_USAN="-g3 -O0 -mtune=generic -fno-omit-frame-pointer -fsanitize=undefined,implicit-conversion -fsanitize-undefined-trap-on-error -fno-sanitize-recover=implicit-conversion"
-LDFLAGS_STD="-Wl,-Bsymbolic-functions -Wl,-z,relro"
+LDFLAGS_STD="-Wl,-Bsymbolic-functions -Wl,-z,relro -fsanitize=undefined,implicit-conversion -fsanitize-undefined-trap-on-error -fno-sanitize-recover=implicit-conversion"
# Sanitizer options to continue avoid stopping the runs on leaks (expected on postgres binaries)
export ASAN_OPTIONS=halt_on_error=false,leak_check_at_exit=false,exitcode=0
@@ -15,5 +15,5 @@ LD_PRELOAD=/usr/lib/clang/8/lib/linux/libclang_rt.asan-x86_64.so /usr/local/pgsq
# Build with Clang and usan flags
./autogen.sh
-./configure CC=clang CFLAGS="${CFLAGS_USAN}" LDFLAGS="${LDFLAGS_STD}"
+./configure --enable-debug CC=clang CFLAGS="${CFLAGS_USAN}" LDFLAGS="${LDFLAGS_STD}"
bash ./ci/travis/logbt -- make -j check RUNTESTFLAGS=--verbose
diff --git a/ci/travis/run_usan_gcc.sh b/ci/travis/run_usan_gcc.sh
index 8943dd7..8b991dd 100644
--- a/ci/travis/run_usan_gcc.sh
+++ b/ci/travis/run_usan_gcc.sh
@@ -3,7 +3,7 @@ set -e
# Enable undefined behaviour sanitizer using traps to
CFLAGS_STD="-g3 -O0 -mtune=generic -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-undefined-trap-on-error"
-LDFLAGS_STD="-Wl,-Bsymbolic-functions -Wl,-z,relro"
+LDFLAGS_STD="-Wl,-Bsymbolic-functions -Wl,-z,relro -fsanitize=undefined"
/usr/local/pgsql/bin/pg_ctl -c -l /tmp/logfile start
./autogen.sh
diff --git a/configure.ac b/configure.ac
index 103589e..db77736 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1128,6 +1128,8 @@ if test $ENABLE_DEBUG -eq 1; then
else
AC_DEFINE([PARANOIA_LEVEL], [0], [Disable use of memory checks])
AC_DEFINE([NDEBUG], [0], [Disable C asserts])
+ AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -flto], [_cv_flto], [-flto], [], [CFLAGS="$CFLAGS -flto"], [])
+ AC_LIBTOOL_LINKER_OPTION([if $compiler supports -flto], [_cv_flto], [[-flto]], [LDFLAGS="$LDFLAGS -flto"])
fi
commit 15151172faa487dfc3489bd6ab21c9ea305a98ef
Author: Darafei Praliaskouski <me at komzpa.net>
Date: Sun Nov 10 21:01:52 2019 +0300
Fix maybe-unitialized warnings
diff --git a/liblwgeom/cunit/cu_algorithm.c b/liblwgeom/cunit/cu_algorithm.c
index a9bb846..4d31a62 100644
--- a/liblwgeom/cunit/cu_algorithm.c
+++ b/liblwgeom/cunit/cu_algorithm.c
@@ -432,9 +432,10 @@ static void test_lwpoint_get_ordinate(void)
}
-static void test_point_interpolate(void)
+static void
+test_point_interpolate(void)
{
- POINT4D p, q, r;
+ POINT4D p, q, r = {0, 0, 0, 0};
int rv = 0;
p.x = 10.0;
@@ -448,21 +449,20 @@ static void test_point_interpolate(void)
q.m = 50.0;
rv = point_interpolate(&p, &q, &r, 1, 1, 'Z', 35.0);
- CU_ASSERT_EQUAL( rv, LW_SUCCESS );
- CU_ASSERT_EQUAL( r.x, 15.0);
+ CU_ASSERT_EQUAL(rv, LW_SUCCESS);
+ CU_ASSERT_EQUAL(r.x, 15.0);
rv = point_interpolate(&p, &q, &r, 1, 1, 'M', 41.0);
- CU_ASSERT_EQUAL( rv, LW_SUCCESS );
- CU_ASSERT_EQUAL( r.y, 21.0);
+ CU_ASSERT_EQUAL(rv, LW_SUCCESS);
+ CU_ASSERT_EQUAL(r.y, 21.0);
rv = point_interpolate(&p, &q, &r, 1, 1, 'M', 50.0);
- CU_ASSERT_EQUAL( rv, LW_SUCCESS );
- CU_ASSERT_EQUAL( r.y, 30.0);
+ CU_ASSERT_EQUAL(rv, LW_SUCCESS);
+ CU_ASSERT_EQUAL(r.y, 30.0);
rv = point_interpolate(&p, &q, &r, 1, 1, 'M', 40.0);
- CU_ASSERT_EQUAL( rv, LW_SUCCESS );
- CU_ASSERT_EQUAL( r.y, 20.0);
-
+ CU_ASSERT_EQUAL(rv, LW_SUCCESS);
+ CU_ASSERT_EQUAL(r.y, 20.0);
}
static void test_lwline_interpolate_points(void)
diff --git a/liblwgeom/lwgeom_api.c b/liblwgeom/lwgeom_api.c
index 64b74c9..313a767 100644
--- a/liblwgeom/lwgeom_api.c
+++ b/liblwgeom/lwgeom_api.c
@@ -270,34 +270,30 @@ getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *op)
uint8_t *ptr;
int zmflag;
- if ( ! pa )
+ if (!pa)
{
lwerror("%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
- return 0;
+ return LW_FALSE;
}
- if ( n>=pa->npoints )
+ if (n >= pa->npoints)
{
lwerror("%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->npoints);
- return 0;
+ return LW_FALSE;
}
- LWDEBUGF(2, "getPoint3dm_p(%d) called on array of %d-dimensions / %u pts",
- n, FLAGS_NDIMS(pa->flags), pa->npoints);
-
-
/* Get a pointer to nth point offset and zmflag */
- ptr=getPoint_internal(pa, n);
- zmflag=FLAGS_GET_ZM(pa->flags);
+ ptr = getPoint_internal(pa, n);
+ zmflag = FLAGS_GET_ZM(pa->flags);
/*
* if input POINTARRAY has the M and NO Z,
* we can issue a single memcpy
*/
- if ( zmflag == 1 )
+ if (zmflag == 1)
{
memcpy(op, ptr, sizeof(POINT3DM));
- return 1;
+ return LW_TRUE;
}
/*
@@ -311,20 +307,17 @@ getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *op)
* copy next double, otherwise initialize
* M to NO_M_VALUE
*/
- if ( zmflag == 3 )
+ if (zmflag == 3)
{
- ptr+=sizeof(POINT3DZ);
+ ptr += sizeof(POINT3DZ);
memcpy(&(op->m), ptr, sizeof(double));
}
else
- {
- op->m=NO_M_VALUE;
- }
+ op->m = NO_M_VALUE;
- return 1;
+ return LW_TRUE;
}
-
/*
* Copy a point from the point array into the parameter point
* z value (if present) is not returned.
diff --git a/liblwgeom/lwline.c b/liblwgeom/lwline.c
index 71efd45..4406b07 100644
--- a/liblwgeom/lwline.c
+++ b/liblwgeom/lwline.c
@@ -453,31 +453,34 @@ lwline_is_closed(const LWLINE *line)
int
lwline_is_trajectory(const LWLINE *line)
{
- POINT3DM p;
- int i, n;
- double m = -1 * FLT_MAX;
-
- if ( ! FLAGS_GET_M(line->flags) ) {
- lwnotice("Line does not have M dimension");
- return LW_FALSE;
- }
-
- n = line->points->npoints;
- if ( n < 2 ) return LW_TRUE; /* empty or single-point are "good" */
-
- for (i=0; i<n; ++i) {
- getPoint3dm_p(line->points, i, &p);
- if ( p.m <= m ) {
- lwnotice("Measure of vertex %d (%g) not bigger than measure of vertex %d (%g)",
- i, p.m, i-1, m);
- return LW_FALSE;
- }
- m = p.m;
- }
-
- return LW_TRUE;
-}
+ if (!FLAGS_GET_M(line->flags))
+ {
+ lwnotice("Line does not have M dimension");
+ return LW_FALSE;
+ }
+ uint32_t n = line->points->npoints;
+
+ if (n < 2)
+ return LW_TRUE; /* empty or single-point are "good" */
+
+ double m = -1 * FLT_MAX;
+ for (uint32_t i = 0; i < n; ++i)
+ {
+ POINT3DM p;
+ if (!getPoint3dm_p(line->points, i, &p))
+ return LW_FALSE;
+ if (p.m <= m)
+ {
+ lwnotice(
+ "Measure of vertex %d (%g) not bigger than measure of vertex %d (%g)", i, p.m, i - 1, m);
+ return LW_FALSE;
+ }
+ m = p.m;
+ }
+
+ return LW_TRUE;
+}
LWLINE*
lwline_force_dims(const LWLINE *line, int hasz, int hasm)
diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c
index 859b36d..552ae0d 100644
--- a/loader/shp2pgsql-core.c
+++ b/loader/shp2pgsql-core.c
@@ -839,10 +839,7 @@ int
ShpLoaderOpenShape(SHPLOADERSTATE *state)
{
SHPObject *obj = NULL;
- int j, z;
int ret = SHPLOADEROK;
-
- int field_precision, field_width;
char name[MAXFIELDNAMELEN];
char name2[MAXFIELDNAMELEN];
DBFFieldType type = FTInvalid;
@@ -905,7 +902,7 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
if (state->config->null_policy == POLICY_NULL_ABORT)
{
/* If we abort on null items, scan the entire file for NULLs */
- for (j = 0; j < state->num_entities; j++)
+ for (int j = 0; j < state->num_entities; j++)
{
obj = SHPReadObject(state->hSHPHandle, j);
@@ -1104,8 +1101,9 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
/* Generate a string of comma separated column names of the form "col1, col2 ... colN" for the SQL
insertion string */
- for (j = 0; j < state->num_fields; j++)
+ for (int j = 0; j < state->num_fields; j++)
{
+ int field_precision = 0, field_width = 0;
type = DBFGetFieldInfo(state->hDBFHandle, j, name, &field_width, &field_precision);
state->types[j] = type;
@@ -1183,7 +1181,7 @@ ShpLoaderOpenShape(SHPLOADERSTATE *state)
}
/* Avoid duplicating field names */
- for (z = 0; z < j ; z++)
+ for (int z = 0; z < j; z++)
{
if (strcmp(state->field_names[z], name) == 0)
{
diff --git a/raster/rt_core/rt_raster.c b/raster/rt_core/rt_raster.c
index 9d02a34..e75a89b 100644
--- a/raster/rt_core/rt_raster.c
+++ b/raster/rt_core/rt_raster.c
@@ -1708,92 +1708,79 @@ rt_raster_to_gdal(
* @return set of "gdaldriver" values of available GDAL drivers
*/
rt_gdaldriver
-rt_raster_gdal_drivers(uint32_t *drv_count, uint8_t can_write) {
- const char *cc;
- const char *vio;
- const char *txt;
- int txt_len;
- GDALDriverH *drv = NULL;
- rt_gdaldriver rtn = NULL;
- int count;
- int i;
- uint32_t j;
-
+rt_raster_gdal_drivers(uint32_t *drv_count, uint8_t can_write)
+{
assert(drv_count != NULL);
-
+ uint32_t output_driver = 0;
rt_util_gdal_register_all(0);
- count = GDALGetDriverCount();
- RASTER_DEBUGF(3, "%d drivers found", count);
+ uint32_t count = (uint32_t)GDALGetDriverCount();
- rtn = (rt_gdaldriver) rtalloc(count * sizeof(struct rt_gdaldriver_t));
- if (NULL == rtn) {
+ rt_gdaldriver rtn = (rt_gdaldriver)rtalloc(count * sizeof(struct rt_gdaldriver_t));
+ if (!rtn)
+ {
rterror("rt_raster_gdal_drivers: Could not allocate memory for gdaldriver structure");
- return 0;
+ *drv_count = output_driver;
+ return NULL;
}
- for (i = 0, j = 0; i < count; i++) {
- drv = GDALGetDriver(i);
+ for (uint32_t i = 0; i < count; i++)
+ {
+ GDALDriverH *drv = GDALGetDriver(i);
#ifdef GDAL_DCAP_RASTER
/* Starting with GDAL 2.0, vector drivers can also be returned */
/* Only keep raster drivers */
const char *is_raster;
is_raster = GDALGetMetadataItem(drv, GDAL_DCAP_RASTER, NULL);
- if (is_raster == NULL || !EQUAL(is_raster, "YES"))
+ if (!is_raster || !EQUAL(is_raster, "YES"))
continue;
#endif
/* CreateCopy support */
- cc = GDALGetMetadataItem(drv, GDAL_DCAP_CREATECOPY, NULL);
+ const char *cc = GDALGetMetadataItem(drv, GDAL_DCAP_CREATECOPY, NULL);
+ if (can_write && !cc)
+ continue;
/* VirtualIO support */
- vio = GDALGetMetadataItem(drv, GDAL_DCAP_VIRTUALIO, NULL);
-
- if (can_write && (cc == NULL || vio == NULL))
+ const char *vio = GDALGetMetadataItem(drv, GDAL_DCAP_VIRTUALIO, NULL);
+ if (can_write && !vio)
continue;
/* we can always read what GDAL can load */
- rtn[j].can_read = 1;
+ rtn[output_driver].can_read = 1;
/* we require CreateCopy and VirtualIO support to write to GDAL */
- rtn[j].can_write = (cc != NULL && vio != NULL);
-
- if (rtn[j].can_write) {
- RASTER_DEBUGF(3, "driver %s (%d) supports CreateCopy() and VirtualIO()", txt, i);
- }
+ rtn[output_driver].can_write = (cc != NULL && vio != NULL);
/* index of driver */
- rtn[j].idx = i;
+ rtn[output_driver].idx = i;
/* short name */
- txt = GDALGetDriverShortName(drv);
- txt_len = strlen(txt);
-
+ const char *txt = GDALGetDriverShortName(drv);
+ size_t txt_len = strlen(txt);
txt_len = (txt_len + 1) * sizeof(char);
- rtn[j].short_name = (char *) rtalloc(txt_len);
- memcpy(rtn[j].short_name, txt, txt_len);
+ rtn[output_driver].short_name = (char *)rtalloc(txt_len);
+ memcpy(rtn[output_driver].short_name, txt, txt_len);
/* long name */
txt = GDALGetDriverLongName(drv);
txt_len = strlen(txt);
-
txt_len = (txt_len + 1) * sizeof(char);
- rtn[j].long_name = (char *) rtalloc(txt_len);
- memcpy(rtn[j].long_name, txt, txt_len);
+ rtn[output_driver].long_name = (char *)rtalloc(txt_len);
+ memcpy(rtn[output_driver].long_name, txt, txt_len);
/* creation options */
txt = GDALGetDriverCreationOptionList(drv);
txt_len = strlen(txt);
-
txt_len = (txt_len + 1) * sizeof(char);
- rtn[j].create_options = (char *) rtalloc(txt_len);
- memcpy(rtn[j].create_options, txt, txt_len);
+ rtn[output_driver].create_options = (char *)rtalloc(txt_len);
+ memcpy(rtn[output_driver].create_options, txt, txt_len);
- j++;
+ output_driver++;
}
/* free unused memory */
- rtn = rtrealloc(rtn, j * sizeof(struct rt_gdaldriver_t));
- *drv_count = j;
+ rtn = rtrealloc(rtn, output_driver * sizeof(struct rt_gdaldriver_t));
+ *drv_count = output_driver;
return rtn;
}
-----------------------------------------------------------------------
Summary of changes:
NEWS | 1 +
ci/travis/run_usan_clang.sh | 4 +--
ci/travis/run_usan_gcc.sh | 2 +-
configure.ac | 2 ++
liblwgeom/cunit/cu_algorithm.c | 22 ++++++------
liblwgeom/lwgeom_api.c | 31 +++++++----------
liblwgeom/lwline.c | 51 +++++++++++++++-------------
loader/shp2pgsql-core.c | 10 +++---
raster/rt_core/rt_raster.c | 77 ++++++++++++++++++------------------------
9 files changed, 92 insertions(+), 108 deletions(-)
hooks/post-receive
--
PostGIS; Spatial objects for PostgreSQL.
More information about the postgis-tickets
mailing list