Skip to content

Commit

Permalink
Fix -Wformat compiler warnings (#2878)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason committed Mar 9, 2023
1 parent 22b69f8 commit 270d56b
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions display/d.text/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,11 @@ int main(int argc, char **argv)

static void set_color(char *tcolor)
{
int r, g, b, color;
unsigned int r, g, b, color;

if (sscanf(tcolor, "%d:%d:%d", &r, &g, &b) == 3 ||
if (sscanf(tcolor, "%u:%u:%u", &r, &g, &b) == 3 ||
sscanf(tcolor, "0x%02x%02x%02x", &r, &g, &b) == 3) {
if (r >= 0 && r < 256 && g >= 0 && g < 256 && b >= 0 && b < 256) {
if (r < 256 && g < 256 && b < 256) {
D_RGB_color(r, g, b);
}
}
Expand Down
2 changes: 1 addition & 1 deletion general/g.pnmcomp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void read_header(FILE *fp, unsigned char *magic, int *maxval)

read_line(buf, sizeof(buf), fp);

if (sscanf(buf, "%d %d", &ncols, &nrows) != 2)
if (sscanf(buf, "%u %u", &ncols, &nrows) != 2)
G_fatal_error(_("Invalid PPM file"));

if (ncols != width || nrows != height)
Expand Down
2 changes: 1 addition & 1 deletion lib/cairodriver/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void init_xlib(void)
}

p = getenv("GRASS_RENDER_CAIRO_VISUAL");
if (!p || sscanf(p, "%li", &xid) != 1) {
if (!p || sscanf(p, "%lu", &xid) != 1) {
G_debug(1, "cairo: GRASS_RENDER_CAIRO_VISUAL=%s", p);
xid = DefaultVisual(ca.dpy, scrn)->visualid;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/gis/color_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int G_str_to_color(const char *str, int *red, int *grn, int *blu)
return 1;
}

int hex;
unsigned int hex;

if (sscanf(buf, "#%x", &hex) == 1) {
*red = (hex >> 16) & 0xFF;
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/Vlib/ascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ int Vect_read_ascii(FILE *ascii, struct Map_info *Map)
continue;
}

if (sscanf(buff, "%u%u", &catn, &cat) != 2) {
if (sscanf(buff, "%d%d", &catn, &cat) != 2) {
G_warning(_("Error reading categories: [%s]"), buff);
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion raster3d/r3.stats/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char *argv[])
rows = region.rows;
depths = region.depths;

sscanf(steps->answer, "%i", &nsteps);
sscanf(steps->answer, "%u", &nsteps);

/* break if the wrong number of subranges are given */
if (nsteps <= 0)
Expand Down

0 comments on commit 270d56b

Please sign in to comment.