From: Darafei Praliaskouski Date: Thu, 13 Sep 2018 13:48:42 +0000 (+0000) Subject: Fix Travis GCC warnings X-Git-Tag: 3.0.0alpha1~420 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c61e871d83fecbbc58b6355f058286b212055cc7;p=postgis Fix Travis GCC warnings -Wno-implicit-fallthrough added because of Bison-generated code. -Wno-unknown-warning-option added because of clang. -Wno-cast-function-type added because of SFCGAL error printing. Most other warnings fixed. Closes https://github.com/postgis/postgis/pull/299 git-svn-id: http://svn.osgeo.org/postgis/trunk@16776 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/.travis.yml b/.travis.yml index e313557e1..436f00f60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ env: matrix: - CFLAGS="-g -O1" MATRIX_EVAL="touch check-no-trailing-blanks" - CFLAGS="-g -O2 -fstack-protector -Wformat -Werror=format-security" LDFLAGS="-Wl,-Bsymbolic-functions -Wl,-z,relro" - - CFLAGS="-g -O3 -mtune=generic -fno-omit-frame-pointer -Werror -Wall -Wextra -Wno-unused-parameter" + - CFLAGS="-g -O3 -mtune=generic -fno-omit-frame-pointer -Werror -Wall -Wextra -Wno-unused-parameter -Wno-implicit-fallthrough -Wno-unknown-warning-option -Wno-cast-function-type" - CFLAGS="-g -O0 --coverage -fprofile-arcs -ftest-coverage" LDFLAGS="--coverage -fprofile-arcs -ftest-coverage" CONFIGURE_FLAGS="--enable-debug" addons: @@ -17,21 +17,21 @@ before_install: - eval "${MATRIX_EVAL}" - sudo sh -c "echo /usr/lib/x86_64-linux-gnu/libeatmydata.so >> /etc/ld.so.preload" - sudo service postgresql stop - + - curl -sSfL https://github.com/mapbox/logbt/archive/v2.0.3.tar.gz | sudo tar --gunzip --extract --strip-components=1 --exclude="*md" --exclude="test*" --directory=/usr/local - curl -sSfL https://raw.githubusercontent.com/mapbox/logbt/30c554dd37b6c96c23fc424f75910fc6d6696f00/bin/logbt | sudo tee /usr/local/bin/logbt > /dev/null - sudo logbt --setup - + - sudo apt-get remove postgresql-9.4 postgresql-9.5 postgresql-9.6 postgresql-10 postgresql-client-9.4 postgresql-client-9.5 postgresql-client-9.6 postgresql-client-10 - sudo add-apt-repository --yes ppa:ubuntugis/ppa - sudo add-apt-repository --yes ppa:ubuntugis/ubuntugis-unstable - - sudo sh -c "echo deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse >> /etc/apt/sources.list" + - sudo sh -c "echo deb http://archive.ubuntu.com/ubuntu/ cosmic main restricted universe multiverse >> /etc/apt/sources.list" - sudo apt-get update -qq - mkdir -p /home/travis/deb && touch /home/travis/deb/__ && sudo cp -n /home/travis/deb/* /var/cache/apt/archives || true - - sudo apt-get install -y --allow-unauthenticated --no-install-recommends --no-install-suggests postgresql-11 postgresql-client-11 postgresql-server-dev-11 postgresql-11-dbgsym libproj-dev libprotobuf-c-dev protobuf-c-compiler libc++abi-dev libc++-dev libgcc1-dbg libsfcgal1 libsfcgal-dev libxml2-utils libcunit1-dev xsltproc docbook-xsl docbook-mathml dblatex libgeos-dev libjson-c-dev libprotobuf-c0-dev libgdal-dev gdb libc6-dbg gcc - + - sudo apt-get install -y --allow-unauthenticated --no-install-recommends --no-install-suggests postgresql-11 postgresql-client-11 postgresql-server-dev-11 postgresql-11-dbgsym libproj-dev libprotobuf-c-dev protobuf-c-compiler libc++abi-dev libc++-dev libgcc1-dbg libsfcgal1 libsfcgal-dev libxml2-utils libcunit1-dev xsltproc docbook-xsl docbook-mathml dblatex libgeos-dev libjson-c-dev libgdal-dev gdb libc6-dbg gcc + - cp -n /var/cache/apt/archives/* /home/travis/deb || true - + - echo "postgres soft core unlimited" | sudo tee -a /etc/security/limits.conf - echo "postgres hard core unlimited" | sudo tee -a /etc/security/limits.conf - echo "pg_ctl_options = '-c'" | sudo tee /etc/postgresql/11/main/pg_ctl.conf @@ -40,9 +40,9 @@ before_install: - sudo usermod -u 1000 postgres - sudo adduser travis ssl-cert - sudo service postgresql start - - sudo service postgresql status + - sudo service postgresql status - sudo -u postgres createuser --superuser travis - + - sudo ldconfig after_failure: diff --git a/doc/html/image_src/Makefile.in b/doc/html/image_src/Makefile.in index fa7fb090d..88e0432bf 100644 --- a/doc/html/image_src/Makefile.in +++ b/doc/html/image_src/Makefile.in @@ -10,7 +10,7 @@ # ********************************************************************** CC=@CC@ -CFLAGS=@CFLAGS@ @WARNFLAGS@ @PROJ_CPPFLAGS@ +CFLAGS=@WARNFLAGS@ @CFLAGS@ @PROJ_CPPFLAGS@ top_builddir = @top_builddir@ SHELL = @SHELL@ LIBTOOL = @LIBTOOL@ diff --git a/extensions/address_standardizer/pagc_api.h b/extensions/address_standardizer/pagc_api.h index 18e4ab3d4..b84821136 100644 --- a/extensions/address_standardizer/pagc_api.h +++ b/extensions/address_standardizer/pagc_api.h @@ -258,7 +258,7 @@ typedef struct err_param typedef int NODE ; typedef int DEFDEF ; -#define MAXTEXT 31 +#define MAXTEXT MAXSTRLEN #define FIRST_LEX_POS 0 #define RIGHT_COMPRESS STOPWORD diff --git a/extensions/address_standardizer/tokenize.c b/extensions/address_standardizer/tokenize.c index ef5eb2940..1dd9554c4 100644 --- a/extensions/address_standardizer/tokenize.c +++ b/extensions/address_standardizer/tokenize.c @@ -979,8 +979,7 @@ static int phrase_from_morphs( struct morph *morph_vector , a ; BLANK_STRING(Dest) ; - strcpy( Dest , - morph_vector[ beg ] . Text ) ; + strlcpy(Dest, morph_vector[beg].Text, MAXTEXT); for ( i = beg + 1 ; i <= end ; i++ ) { diff --git a/liblwgeom/Makefile.in b/liblwgeom/Makefile.in index 265302c2c..696b43562 100644 --- a/liblwgeom/Makefile.in +++ b/liblwgeom/Makefile.in @@ -24,7 +24,7 @@ CC = @CC@ CPPFLAGS = @CPPFLAGS@ -CFLAGS = @CFLAGS@ @PICFLAGS@ @WARNFLAGS@ @GEOS_CPPFLAGS@ @PROJ_CPPFLAGS@ @JSON_CPPFLAGS@ +CFLAGS = @WARNFLAGS@ @CFLAGS@ @PICFLAGS@ @GEOS_CPPFLAGS@ @PROJ_CPPFLAGS@ @JSON_CPPFLAGS@ LDFLAGS = @LDFLAGS@ @GEOS_LDFLAGS@ -lgeos_c @PROJ_LDFLAGS@ -lproj @JSON_LDFLAGS@ -lm NUMERICFLAGS = @NUMERICFLAGS@ top_builddir = @top_builddir@ diff --git a/liblwgeom/cunit/Makefile.in b/liblwgeom/cunit/Makefile.in index 4538d7d44..0a3c06513 100644 --- a/liblwgeom/cunit/Makefile.in +++ b/liblwgeom/cunit/Makefile.in @@ -17,7 +17,7 @@ LIBTOOL = @LIBTOOL@ CUNIT_LDFLAGS=@CUNIT_LDFLAGS@ CUNIT_CPPFLAGS=@CUNIT_CPPFLAGS@ -I.. -CFLAGS=@CFLAGS@ @WARNFLAGS@ @GEOS_CPPFLAGS@ @PROJ_CPPFLAGS@ $(CUNIT_CPPFLAGS) +CFLAGS=@WARNFLAGS@ @CFLAGS@ @GEOS_CPPFLAGS@ @PROJ_CPPFLAGS@ $(CUNIT_CPPFLAGS) LDFLAGS = @GEOS_LDFLAGS@ -lgeos_c $(CUNIT_LDFLAGS) -lm # ADD YOUR NEW TEST FILE HERE (1/1) diff --git a/liblwgeom/lwhomogenize.c b/liblwgeom/lwhomogenize.c index 047b1e749..8bc9faf82 100644 --- a/liblwgeom/lwhomogenize.c +++ b/liblwgeom/lwhomogenize.c @@ -77,42 +77,39 @@ lwcollection_build_buffer(const LWCOLLECTION *col, HomogenizeBuffer *buffer) { uint32_t i; - if ( ! col ) return; - if ( lwgeom_is_empty(lwcollection_as_lwgeom(col)) ) return; - for ( i = 0; i < col->ngeoms; i++ ) + if (!col || lwcollection_is_empty(col)) + return; + + for (i = 0; i < col->ngeoms; i++) { LWGEOM *geom = col->geoms[i]; - switch(geom->type) + switch (geom->type) { - case POINTTYPE: - case LINETYPE: - case CIRCSTRINGTYPE: - case COMPOUNDTYPE: - case TRIANGLETYPE: - case CURVEPOLYTYPE: - case POLYGONTYPE: - { - /* Init if necessary */ - if ( ! buffer->buf[geom->type] ) - { - LWCOLLECTION *bufcol = lwcollection_construct_empty(COLLECTIONTYPE, col->srid, FLAGS_GET_Z(col->flags), FLAGS_GET_M(col->flags)); - bufcol->type = lwtype_get_collectiontype(geom->type); - buffer->buf[geom->type] = bufcol; - } - /* Add sub-geom to buffer */ - lwcollection_add_lwgeom(buffer->buf[geom->type], lwgeom_clone(geom)); - /* Increment count for this singleton type */ - buffer->cnt[geom->type] = buffer->cnt[geom->type] + 1; - } - /* FALLTHROUGH */ - default: + case POINTTYPE: + case LINETYPE: + case CIRCSTRINGTYPE: + case COMPOUNDTYPE: + case TRIANGLETYPE: + case CURVEPOLYTYPE: + case POLYGONTYPE: + /* Init if necessary */ + if (!buffer->buf[geom->type]) { - lwcollection_build_buffer(lwgeom_as_lwcollection(geom), buffer); - break; + LWCOLLECTION *bufcol = lwcollection_construct_empty( + COLLECTIONTYPE, col->srid, FLAGS_GET_Z(col->flags), FLAGS_GET_M(col->flags)); + bufcol->type = lwtype_get_collectiontype(geom->type); + buffer->buf[geom->type] = bufcol; } + /* Add sub-geom to buffer */ + lwcollection_add_lwgeom(buffer->buf[geom->type], lwgeom_clone(geom)); + /* Increment count for this singleton type */ + buffer->cnt[geom->type]++; + break; + default: + lwcollection_build_buffer(lwgeom_as_lwcollection(geom), buffer); + break; } } - return; } static LWGEOM* diff --git a/liblwgeom/lwinline.h b/liblwgeom/lwinline.h index 0f3869c38..d97a6e94c 100644 --- a/liblwgeom/lwinline.h +++ b/liblwgeom/lwinline.h @@ -121,41 +121,31 @@ lwgeom_get_type(const LWGEOM *geom) static inline int lwpoint_is_empty(const LWPOINT *point) { - if (!point->point || point->point->npoints < 1) - return LW_TRUE; - return LW_FALSE; + return !point->point || point->point->npoints < 1; } static inline int lwline_is_empty(const LWLINE *line) { - if (!line->points || line->points->npoints < 1) - return LW_TRUE; - return LW_FALSE; + return !line->points || line->points->npoints < 1; } static inline int lwcircstring_is_empty(const LWCIRCSTRING *circ) { - if (!circ->points || circ->points->npoints < 1) - return LW_TRUE; - return LW_FALSE; + return !circ->points || circ->points->npoints < 1; } static inline int lwpoly_is_empty(const LWPOLY *poly) { - if ((poly->nrings < 1) || (!poly->rings) || (!poly->rings[0]) || (poly->rings[0]->npoints < 1)) - return LW_TRUE; - return LW_FALSE; + return poly->nrings < 1 || !poly->rings || !poly->rings[0] || poly->rings[0]->npoints < 1; } static inline int lwtriangle_is_empty(const LWTRIANGLE *triangle) { - if (!triangle->points || triangle->points->npoints < 1) - return LW_TRUE; - return LW_FALSE; + return !triangle->points || triangle->points->npoints < 1; } static inline int lwgeom_is_empty(const LWGEOM *geom); @@ -164,7 +154,7 @@ static inline int lwcollection_is_empty(const LWCOLLECTION *col) { uint32_t i; - if ((col->ngeoms == 0) || (!col->geoms)) + if (col->ngeoms == 0 || !col->geoms) return LW_TRUE; for (i = 0; i < col->ngeoms; i++) { diff --git a/liblwgeom/lwkmeans.c b/liblwgeom/lwkmeans.c index 747385bd3..360983daf 100644 --- a/liblwgeom/lwkmeans.c +++ b/liblwgeom/lwkmeans.c @@ -123,7 +123,7 @@ kmeans(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, uint32_t k) } static void -kmeans_init(POINT2D** objs, int* clusters, uint32_t n, POINT2D** centers, POINT2D* centers_raw, uint32_t k) +kmeans_init(POINT2D **objs, uint32_t n, POINT2D **centers, POINT2D *centers_raw, uint32_t k) { double* distances; uint32_t p1 = 0, p2 = 0; @@ -327,12 +327,12 @@ lwgeom_cluster_2d_kmeans(const LWGEOM** geoms, uint32_t n, uint32_t k) if (k > 1) { - kmeans_init(objs, clusters, n, centers, centers_raw, k); + kmeans_init(objs, n, centers, centers_raw, k); result = kmeans(objs, clusters, n, centers, k); } else { - /* k=0: everythong is unclusterable + /* k=0: everything is unclusterable * k=1: mark up NULL and non-NULL */ for (i = 0; i < n; i++) { diff --git a/libpgcommon/Makefile.in b/libpgcommon/Makefile.in index da368cc85..3252c301b 100644 --- a/libpgcommon/Makefile.in +++ b/libpgcommon/Makefile.in @@ -10,7 +10,7 @@ # ********************************************************************** CC=@CC@ -CFLAGS=-I../liblwgeom @CFLAGS@ @PGSQL_BE_CPPFLAGS@ @PROJ_CPPFLAGS@ @PICFLAGS@ @WARNFLAGS@ @GETTEXT_CFLAGS@ +CFLAGS=-I../liblwgeom @WARNFLAGS@ @CFLAGS@ @PGSQL_BE_CPPFLAGS@ @PROJ_CPPFLAGS@ @PICFLAGS@ @GETTEXT_CFLAGS@ LDFLAGS=@GETTEXT_LDFLAGS@ @LIBINTL@ NUMERICFLAGS=@NUMERICFLAGS@ @@ -39,15 +39,15 @@ all: libpgcommon.a install uninstall: libpgcommon.a: $(SA_OBJS) $(SA_HEADERS) - ar rs libpgcommon.a $(SA_OBJS) + ar rs libpgcommon.a $(SA_OBJS) maintainer-clean: clean -clean: +clean: $(MAKE) -C cunit clean - rm -f $(SA_OBJS) - rm -f $(NM_OBJS) - rm -f libpgcommon.a + rm -f $(SA_OBJS) + rm -f $(NM_OBJS) + rm -f libpgcommon.a distclean: clean $(MAKE) -C cunit distclean @@ -57,7 +57,7 @@ check: libpgcommon.a $(MAKE) -C cunit check # Command to build each of the .o files -$(SA_OBJS): %.o: %.c +$(SA_OBJS): %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< $(SA_OBJS): ../postgis_config.h diff --git a/loader/Makefile.in b/loader/Makefile.in index 830db51c8..6954a6cd4 100644 --- a/loader/Makefile.in +++ b/loader/Makefile.in @@ -22,7 +22,7 @@ include $(PGXS) # Set CFLAGS afer PGXS, otherwise it will get overwritten with the PGXS # version which is not what we want. CC=@CC@ -CFLAGS=-I ../liblwgeom @CFLAGS@ @PICFLAGS@ @WARNFLAGS@ @PROJ_CPPFLAGS@ +CFLAGS=-I ../liblwgeom @WARNFLAGS@ @CFLAGS@ @PICFLAGS@ @PROJ_CPPFLAGS@ top_builddir = @top_builddir@ SHELL = @SHELL@ INSTALL = @INSTALL@ diff --git a/loader/cunit/Makefile.in b/loader/cunit/Makefile.in index 8bc51fee2..2c8401dd7 100644 --- a/loader/cunit/Makefile.in +++ b/loader/cunit/Makefile.in @@ -11,7 +11,7 @@ top_builddir = @top_builddir@ CC=@CC@ -CFLAGS=@CFLAGS@ @WARNFLAGS@ +CFLAGS=@WARNFLAGS@ @CFLAGS@ SHELL = @SHELL@ LIBTOOL = @LIBTOOL@ @@ -78,7 +78,7 @@ check: cu_tester endif # Build the main unit test executable -cu_tester: $(LOADER_OBJS) $(OBJS) +cu_tester: $(LOADER_OBJS) $(OBJS) $(LIBTOOL) --mode=link \ $(CC) $^ -o $@ $(LIBLWGEOM) $(LDFLAGS) diff --git a/raster/Makefile.in b/raster/Makefile.in index fa6e1048b..d37d78736 100644 --- a/raster/Makefile.in +++ b/raster/Makefile.in @@ -20,7 +20,7 @@ ############################################################################# CC=@CC@ -CFLAGS=-I../liblwgeom @CFLAGS@ @WARNFLAGS@ +CFLAGS=-I../liblwgeom @WARNFLAGS@ @CFLAGS@ LDFLAGS = @LDFLAGS@ all: @RT_CORE_LIB@ @RT_PG_LIB@ @RT_LOADER@ @RT_POSTGIS_SQL@ diff --git a/raster/loader/Makefile.in b/raster/loader/Makefile.in index f7353dbe6..e59e73be2 100644 --- a/raster/loader/Makefile.in +++ b/raster/loader/Makefile.in @@ -57,7 +57,7 @@ ICONV_LDFLAGS=@ICONV_LDFLAGS@ ICONV_CFLAGS=@ICONV_CFLAGS@ CFLAGS = \ - @CFLAGS@ @PICFLAGS@ @WARNFLAGS@ \ + @WARNFLAGS@ @CFLAGS@ @PICFLAGS@ \ $(RTCORE_CFLAGS) \ $(LIBLWGEOM_CFLAGS) \ $(PROJ_CFLAGS) \ diff --git a/raster/rt_core/Makefile.in b/raster/rt_core/Makefile.in index d5a8f5d58..1ec49cd18 100644 --- a/raster/rt_core/Makefile.in +++ b/raster/rt_core/Makefile.in @@ -28,7 +28,7 @@ LIBGDAL_LDFLAGS = @LIBGDAL_LDFLAGS@ GEOS_LDFLAGS = @GEOS_LDFLAGS@ -lgeos_c PROJ_LDFLAGS = @PROJ_LDFLAGS@ -lproj LDFLAGS = $(LIBLWGEOM_LDFLAGS) $(LIBGDAL_LDFLAGS) $(PROJ_LDFLAGS) $(GEOS_LDFLAGS) -CFLAGS = $(LIBLWGEOM_CFLAGS) @CFLAGS@ @PICFLAGS@ @WARNFLAGS@ $(LIBGDAL_CFLAGS) @PROJ_CPPFLAGS@ @GEOS_CPPFLAGS@ +CFLAGS = $(LIBLWGEOM_CFLAGS) @WARNFLAGS@ @CFLAGS@ @PICFLAGS@ $(LIBGDAL_CFLAGS) @PROJ_CPPFLAGS@ @GEOS_CPPFLAGS@ # Standalone RTCORE objects RT_OBJS = \ diff --git a/raster/rt_pg/rtpg_mapalgebra.c b/raster/rt_pg/rtpg_mapalgebra.c index 9793bfe47..01eb2a373 100644 --- a/raster/rt_pg/rtpg_mapalgebra.c +++ b/raster/rt_pg/rtpg_mapalgebra.c @@ -6369,6 +6369,7 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS) switch (extenttype) { case ET_FIRST: i = 0; + /* fall through */ case ET_SECOND: if (i > 1) i = 1; diff --git a/raster/test/cunit/Makefile.in b/raster/test/cunit/Makefile.in index 4124c630c..37f13d358 100644 --- a/raster/test/cunit/Makefile.in +++ b/raster/test/cunit/Makefile.in @@ -30,7 +30,7 @@ RTCORE_LDFLAGS=$(RT_CORE)/librtcore.a CC=@CC@ CFLAGS = \ - @CFLAGS@ @WARNFLAGS@ \ + @WARNFLAGS@ @CFLAGS@ \ $(RTCORE_CFLAGS) \ $(LIBLWGEOM_CFLAGS) \ $(PROJ_CFLAGS) \ @@ -62,7 +62,7 @@ OBJS= \ cu_spatial_relationship.o \ cu_mapalgebra.o \ cu_misc.o \ - cu_tester.o + cu_tester.o # If we couldn't find the cunit library then display a helpful message ifeq ($(CUNIT_LDFLAGS),)