Skip to content

Commit edf9a98

Browse files
nilasonninsbl
authored andcommitted
Match format specifier with argument type (OSGeo#1256)
Addresses -Wformat compiler warnings.
1 parent 59fb781 commit edf9a98

15 files changed

Lines changed: 40 additions & 49 deletions

File tree

db/drivers/ogr/execute.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int db__driver_execute_immediate(dbString * sql)
8888
hFeature = OGR_L_GetNextFeature(hLayer);
8989
if (!hFeature)
9090
break;
91-
G_debug(5, "\tfid=%ld", OGR_F_GetFID(hFeature));
91+
G_debug(5, "\tfid=%lld", OGR_F_GetFID(hFeature));
9292

9393
for (i = 0; i < ncols; i++) {
9494
if (cols[i].qindex > -1) {
@@ -110,7 +110,7 @@ int db__driver_execute_immediate(dbString * sql)
110110
OGR_F_SetFieldString(hFeature, cols[i].index, value);
111111
}
112112
if (OGR_L_SetFeature(hLayer, hFeature) != OGRERR_NONE)
113-
G_warning(_("\tOGR failed to write feature fid=%ld to layer <%s>"),
113+
G_warning(_("\tOGR failed to write feature fid=%lld to layer <%s>"),
114114
OGR_F_GetFID(hFeature), OGR_L_GetName(hLayer));
115115
OGR_F_Destroy(hFeature);
116116
}

lib/vector/Vlib/open_nat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,11 @@ int check_coor(struct Map_info *Map)
150150

151151
if (dif > 0) {
152152
G_warning(_("Coor file of vector map <%s@%s> is larger than it should be "
153-
"(%ld bytes excess)"), Map->name, Map->mapset, dif);
153+
"(%" PRI_OFF_T " bytes excess)"), Map->name, Map->mapset, dif);
154154
}
155155
else if (dif < 0) {
156156
G_warning(_("Coor file of vector <%s@%s> is shorter than it should be "
157-
"(%ld bytes missing)."), Map->name, Map->mapset, -dif);
157+
"(%" PRI_OFF_T " bytes missing)."), Map->name, Map->mapset, -dif);
158158
}
159159
return 1;
160160
}

lib/vector/Vlib/write.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ off_t Vect_rewrite_line(struct Map_info *Map, off_t line, int type,
222222
{
223223
off_t ret;
224224

225-
G_debug(3, "Vect_rewrite_line(): name = %s, format = %d, level = %d, line/offset = %"PRI_OFF_T,
225+
G_debug(3, "Vect_rewrite_line(): name = %s, format = %d, level = %d, line/offset = %" PRI_OFF_T,
226226
Map->name, Map->format, Map->level, line);
227227

228228
if (!check_map(Map))
@@ -231,7 +231,7 @@ off_t Vect_rewrite_line(struct Map_info *Map, off_t line, int type,
231231
ret = (*Vect_rewrite_line_array[Map->format][Map->level]) (Map, line, type,
232232
points, cats);
233233
if (ret == -1)
234-
G_warning(_("Unable to rewrite feature/offset %lu in vector map <%s>"),
234+
G_warning(_("Unable to rewrite feature/offset %" PRI_OFF_T " in vector map <%s>"),
235235
line, Vect_get_name(Map));
236236

237237
return ret;
@@ -254,7 +254,7 @@ int Vect_delete_line(struct Map_info *Map, off_t line)
254254
{
255255
int ret;
256256

257-
G_debug(3, "Vect_delete_line(): name = %s, line/offset = %"PRI_OFF_T,
257+
G_debug(3, "Vect_delete_line(): name = %s, line/offset = %" PRI_OFF_T,
258258
Map->name, line);
259259

260260
if (!check_map(Map))
@@ -263,7 +263,7 @@ int Vect_delete_line(struct Map_info *Map, off_t line)
263263
ret = (*Vect_delete_line_array[Map->format][Map->level]) (Map, line);
264264

265265
if (ret == -1)
266-
G_warning(_("Unable to delete feature/offset %lu from vector map <%s>"),
266+
G_warning(_("Unable to delete feature/offset %" PRI_OFF_T " from vector map <%s>"),
267267
line, Vect_get_name(Map));
268268

269269
return ret;
@@ -287,7 +287,7 @@ int Vect_restore_line(struct Map_info *Map, off_t offset, off_t line)
287287
{
288288
int ret;
289289

290-
G_debug(3, "Vect_restore_line(): name = %s, level = %d, offset = %"PRI_OFF_T", line = %"PRI_OFF_T,
290+
G_debug(3, "Vect_restore_line(): name = %s, level = %d, offset = %" PRI_OFF_T ", line = %" PRI_OFF_T,
291291
Map->name, Map->level, offset, line);
292292

293293
if (!check_map(Map))
@@ -296,7 +296,7 @@ int Vect_restore_line(struct Map_info *Map, off_t offset, off_t line)
296296
ret = (*Vect_restore_line_array[Map->format][Map->level]) (Map, offset, line);
297297

298298
if (ret == -1)
299-
G_warning(_("Unable to restore feature/offset %"PRI_OFF_T" in vector map <%s>"),
299+
G_warning(_("Unable to restore feature/offset %" PRI_OFF_T " in vector map <%s>"),
300300
offset, Vect_get_name(Map));
301301

302302
return ret;

lib/vector/Vlib/write_nat.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ off_t V1_rewrite_line_nat(struct Map_info *Map, off_t offset, int type,
105105
static struct line_pnts *old_points = NULL;
106106
static struct line_cats *old_cats = NULL;
107107

108-
G_debug(3, "V1_rewrite_line_nat(): offset = %"PRI_OFF_T,
108+
G_debug(3, "V1_rewrite_line_nat(): offset = %" PRI_OFF_T,
109109
offset);
110110

111111
/* First compare numbers of points and cats with tha old one */
@@ -241,7 +241,7 @@ int V1_delete_line_nat(struct Map_info *Map, off_t offset)
241241
char rhead;
242242
struct gvfile *dig_fp;
243243

244-
G_debug(3, "V1_delete_line_nat(): offset = %"PRI_OFF_T, offset);
244+
G_debug(3, "V1_delete_line_nat(): offset = %" PRI_OFF_T, offset);
245245

246246
dig_set_cur_port(&(Map->head.port));
247247
dig_fp = &(Map->dig_fp);
@@ -342,7 +342,7 @@ int V1_restore_line_nat(struct Map_info *Map, off_t offset, off_t line)
342342
char rhead;
343343
struct gvfile *dig_fp;
344344

345-
G_debug(3, "V1_restore_line_nat(): offset = %"PRI_OFF_T", line (not used) = %"PRI_OFF_T, offset, line);
345+
G_debug(3, "V1_restore_line_nat(): offset = %" PRI_OFF_T ", line (not used) = %" PRI_OFF_T, offset, line);
346346

347347
dig_set_cur_port(&(Map->head.port));
348348
dig_fp = &(Map->dig_fp);
@@ -392,10 +392,10 @@ int V2_restore_line_nat(struct Map_info *Map, off_t offset, off_t line)
392392

393393
plus = &(Map->plus);
394394

395-
G_debug(3, "V2_restore_line_nat(): offset = %"PRI_OFF_T", line = %"PRI_OFF_T, offset, line);
395+
G_debug(3, "V2_restore_line_nat(): offset = %" PRI_OFF_T ", line = %" PRI_OFF_T, offset, line);
396396

397397
if (line < 1 || line > plus->n_lines) {
398-
G_warning(_("Attempt to access feature with invalid id (%"PRI_OFF_T")"), line);
398+
G_warning(_("Attempt to access feature with invalid id (%" PRI_OFF_T ")"), line);
399399
return -1;
400400
}
401401

@@ -463,7 +463,7 @@ off_t V1__write_line_nat(struct Map_info *Map, off_t offset, int type,
463463
return -1;
464464

465465
offset = dig_ftell(&(Map->dig_fp));
466-
G_debug(3, "V1__rewrite_line_nat(): offset = %lu", offset);
466+
G_debug(3, "V1__rewrite_line_nat(): offset = %" PRI_OFF_T, offset);
467467
if (offset == -1)
468468
return -1;
469469
}
@@ -885,7 +885,7 @@ int V2__add_line_to_topo_nat(struct Map_info *Map, off_t offset, int type,
885885

886886
plus = &(Map->plus);
887887

888-
G_debug(3, "V2__add_line_to_topo_nat(): offset = %ld (build level = %d)", offset, plus->built);
888+
G_debug(3, "V2__add_line_to_topo_nat(): offset = %" PRI_OFF_T " (build level = %d)", offset, plus->built);
889889

890890
if (plus->built < GV_BUILD_BASE) /* nothing to build */
891891
return 0;

lib/vector/Vlib/write_ogr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ off_t V1_rewrite_line_ogr(struct Map_info *Map,
8989
off_t offset, int type,
9090
const struct line_pnts *points, const struct line_cats *cats)
9191
{
92-
G_debug(3, "V1_rewrite_line_ogr(): type=%d offset=%"PRI_OFF_T,
92+
G_debug(3, "V1_rewrite_line_ogr(): type=%d offset=%" PRI_OFF_T,
9393
type, offset);
9494
#ifdef HAVE_OGR
9595
if (type != V1_read_line_ogr(Map, NULL, NULL, offset)) {
@@ -131,7 +131,7 @@ int V1_delete_line_ogr(struct Map_info *Map, off_t offset)
131131
}
132132

133133
if (offset >= ogr_info->offset.array_num) {
134-
G_warning(_("Invalid offset (%ld)"), offset);
134+
G_warning(_("Invalid offset (%" PRI_OFF_T ")"), offset);
135135
return -1;
136136
}
137137

lib/vector/Vlib/write_pg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ off_t V1_rewrite_line_pg(struct Map_info * Map,
181181
const struct line_pnts * points,
182182
const struct line_cats * cats)
183183
{
184-
G_debug(3, "V1_rewrite_line_pg(): type=%d offset=%"PRI_OFF_T,
184+
G_debug(3, "V1_rewrite_line_pg(): type=%d offset=%" PRI_OFF_T,
185185
type, offset);
186186
#ifdef HAVE_POSTGRES
187187
if (type != V1_read_line_pg(Map, NULL, NULL, offset)) {
@@ -278,7 +278,7 @@ off_t V2_rewrite_line_pg(struct Map_info *Map, off_t line, int type,
278278
}
279279

280280
geom_data = line_to_wkb(pg_info, &points, 1, type, Map->head.with_z);
281-
G_asprintf(&stmt, "UPDATE \"%s\".\"%s\" SET geom = '%s'::GEOMETRY WHERE %s_id = %ld",
281+
G_asprintf(&stmt, "UPDATE \"%s\".\"%s\" SET geom = '%s'::GEOMETRY WHERE %s_id = %" PRI_OFF_T,
282282
schema_name, table_name, geom_data, keycolumn, line);
283283
G_free(geom_data);
284284

@@ -324,7 +324,7 @@ int V1_delete_line_pg(struct Map_info *Map, off_t offset)
324324
}
325325

326326
if (offset >= pg_info->offset.array_num) {
327-
G_warning(_("Invalid offset (%ld)"), offset);
327+
G_warning(_("Invalid offset (%" PRI_OFF_T ")"), offset);
328328
return -1;
329329
}
330330

raster/r.compress/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ static int process(char *name, int uncompress)
216216

217217
if (newsize < oldsize)
218218
G_message(uncompress
219-
? _("DONE: uncompressed file is %lu %s (%.2f%) smaller")
220-
: _("DONE: compressed file is %lu %s (%.2f%) smaller"),
219+
? _("DONE: uncompressed file is %lu %s (%.2f%%) smaller")
220+
: _("DONE: compressed file is %lu %s (%.2f%%) smaller"),
221221
(unsigned long)diff, sizestr, (double) 100.0 - 100.0 * newsize / oldsize);
222222
else if (newsize > oldsize)
223223
G_message(uncompress
224-
? _("DONE: uncompressed file is %lu %s (%.2f%) larger")
225-
: _("DONE: compressed file is %lu %s (%.2f%) larger"),
224+
? _("DONE: uncompressed file is %lu %s (%.2f%%) larger")
225+
: _("DONE: compressed file is %lu %s (%.2f%%) larger"),
226226
(unsigned long)diff, sizestr, (double) 100.0 * newsize / oldsize - 100.0);
227227
else
228228
G_message(_("same size"));

raster/r.terraflow/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,13 @@ printMaxSortSize(long nodata_count) {
413413
off_t maxneed = (fillmaxsize > flowmaxsize) ? fillmaxsize: flowmaxsize;
414414
maxneed = 2*maxneed; /* need 2*N to sort */
415415

416-
G_debug(1, "total elements=%lld, nodata elements=%ld",
416+
G_debug(1, "total elements=%" PRI_OFF_T ", nodata elements=%ld",
417417
(off_t)nrows * ncols, nodata_count);
418418
G_debug(1, "largest temporary files: ");
419-
G_debug(1, "\t\t FILL: %s [%lld elements, %ldB each]",
419+
G_debug(1, "\t\t FILL: %s [%" PRI_OFF_T " elements, %ldB each]",
420420
formatNumber(buf, fillmaxsize),
421421
(off_t)nrows * ncols, sizeof(waterWindowType));
422-
G_debug(1, "\t\t FLOW: %s [%lld elements, %ldB each]",
422+
G_debug(1, "\t\t FLOW: %s [%" PRI_OFF_T " elements, %ldB each]",
423423
formatNumber(buf, flowmaxsize),
424424
(off_t)nrows * ncols - nodata_count, sizeof(sweepItem));
425425
G_debug(1, "Will need at least %s space available in %s",

raster/r.terraflow/stats.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,25 +171,16 @@ statsRecorder::comment(const int n) {
171171

172172

173173

174-
#if __FreeBSD__ && __i386__
175-
#define LDFMT "%qd"
176-
#else
177-
#if __linux__
178-
#define LDFMT "%lld"
179-
#else
180-
#define LDFMT "%ld"
181-
#endif
182-
#endif
183174
char *
184175
formatNumber(char *buf, off_t val) {
185176
if(val > (1<<30)) {
186-
sprintf(buf, "%.2fG (" LDFMT ")", (double)val/(1<<30), val);
177+
sprintf(buf, "%.2fG (%" PRI_OFF_T ")", (double)val/(1<<30), val);
187178
} else if(val > (1<<20)) {
188-
sprintf(buf, "%.2fM (" LDFMT ")", (double)val/(1<<20), val);
179+
sprintf(buf, "%.2fM (%" PRI_OFF_T ")", (double)val/(1<<20), val);
189180
} else if(val > (1<<10)) {
190-
sprintf(buf, "%.2fK (" LDFMT ")", (double)val/(1<<10), val);
181+
sprintf(buf, "%.2fK (%" PRI_OFF_T ")", (double)val/(1<<10), val);
191182
} else {
192-
sprintf(buf, LDFMT, val);
183+
sprintf(buf, "%" PRI_OFF_T, val);
193184
}
194185
return buf;
195186
}

raster/r.terraflow/sweep.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ sweep(AMI_STREAM<sweepItem> *sweepstr, const flowaccumulation_type D8CUT,
207207
/* read next sweepItem = (prio, elevwin, topoRankwin, dir) */
208208
ae = sweepstr->read_item(&crtpoint);
209209
if (ae != AMI_ERROR_NO_ERROR) {
210-
fprintf(stderr, "sweep: k=%ld: cannot read next item..\n", k);
210+
fprintf(stderr, "sweep: k=%" PRI_OFF_T ": cannot read next item..\n", k);
211211
exit(1);
212212
}
213213
/* cout << "k=" << k << " prio =" << crtpoint->getPriority() << "\n"; */

0 commit comments

Comments
 (0)