Opened 10 months ago

Last modified 8 months ago

#5558 closed defect

Compilation warning: uninitialized variable — at Initial Version

Reported by: Laurenz Albe Owned by: pramsey
Priority: medium Milestone: PostGIS 3.4.1
Component: postgis Version: master
Keywords: Cc:

Description

Building master, I get

In file included from mvt.h:40,
                 from mvt.c:30:
mvt.c: In function ‘mvt_clip_and_validate_geos’:
mvt.c:884:41: warning: ‘bgbox.flags’ may be used uninitialized [-Wmaybe-uninitialized]
  884 |                 FLAGS_SET_GEODETIC(bgbox.flags, 0);
../liblwgeom/liblwgeom.h:175:95: note: in definition of macro ‘FLAGS_SET_GEODETIC’
  175 | #define FLAGS_SET_GEODETIC(flags, value) ((flags) = (value) ? ((flags) | LWFLAG_GEODETIC) : ((flags) & ~LWFLAG_GEODETIC))
      |                                                                                               ^~~~~
mvt.c:881:22: note: ‘bgbox’ declared here
  881 |                 GBOX bgbox;
      |                      ^~~~~

Indeed, in postgis/mvt.c, bgbox.flag is not initialized:

GBOX bgbox;
bgbox.xmax = bgbox.ymax = (double)extent + (double)buffer;
bgbox.xmin = bgbox.ymin = -(double)buffer;
FLAGS_SET_GEODETIC(bgbox.flags, 0);

I guess it should be initialized to zero, as in the following patch:

  • postgis/mvt.c

    diff --git a/postgis/mvt.c b/postgis/mvt.c
    index 8aa916052..64bb28edb 100644
    a b mvt_clip_and_validate_geos(LWGEOM *lwgeom, uint8_t basic_type, uint32_t extent,  
    881881       GBOX bgbox;
    882882       bgbox.xmax = bgbox.ymax = (double)extent + (double)buffer;
    883883       bgbox.xmin = bgbox.ymin = -(double)buffer;
     884       bgbox.flags = 0;
    884885       FLAGS_SET_GEODETIC(bgbox.flags, 0);
    885886
    886887       ng = mvt_unsafe_clip_by_box(ng, &bgbox);

Change History (0)

Note: See TracTickets for help on using tickets.