Skip to content

Commit

Permalink
fix -Wunused-but-set-variable warnings (#2752)
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason committed Jan 17, 2023
1 parent 8030ea4 commit 7780e94
Show file tree
Hide file tree
Showing 34 changed files with 57 additions and 177 deletions.
10 changes: 5 additions & 5 deletions display/d.grid/plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ int plot_geogrid(double size, struct pj_info *info_in, struct pj_info *info_out,
double east, west, north, south;
double start_coord;
double lat, lon;
int j, ll;
int ll;
int SEGS = 100;
char text[128];
float border_off = 4.5;
Expand Down Expand Up @@ -274,7 +274,7 @@ int plot_geogrid(double size, struct pj_info *info_in, struct pj_info *info_out,
/* Lines of Latitude */
g = floor(north / size) * size;
e1 = east;
for (j = 0; g >= south; j++, g -= size) {
for (; g >= south; g -= size) {
start_coord = -9999.;
if (g == north || g == south || direction == DIRN_LON)
continue;
Expand Down Expand Up @@ -320,7 +320,7 @@ int plot_geogrid(double size, struct pj_info *info_in, struct pj_info *info_out,
/* Lines of Longitude */
g = floor(east / size) * size;
n1 = north;
for (j = 0; g > west; j++, g -= size) {
for (; g > west; g -= size) {
start_coord = -9999.;
extra_y_off = 0.0;
if (g == east || g == west || direction == DIRN_LAT)
Expand Down Expand Up @@ -428,7 +428,7 @@ int plot_geogrid(double size, struct pj_info *info_in, struct pj_info *info_out,
if (do_text) {
g = floor(north / size) * size;
e1 = east;
for (j = 0; g >= south; j++, g -= size) {
for (; g >= south; g -= size) {
start_coord = -9999.;
if (g == north || g == south || direction == DIRN_LON)
continue;
Expand Down Expand Up @@ -488,7 +488,7 @@ int plot_geogrid(double size, struct pj_info *info_in, struct pj_info *info_out,
if (do_text) {
g = floor(east / size) * size;
n1 = north;
for (j = 0; g > west; j++, g -= size) {
for (; g > west; g -= size) {
start_coord = -9999.;
extra_y_off = 0.0;
if (g == east || g == west || direction == DIRN_LAT)
Expand Down
2 changes: 0 additions & 2 deletions include/grass/iostream/ami_sort_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,12 @@ AMI_STREAM<T> *singleMerge(queue<char *> *streamList, Compare *cmp)
ReplacementHeap<T, Compare> rheap(arity, streamList);
SDEBUG rheap.print(cerr);

int i = 0;
while (!rheap.empty()) {
// mergedStr->write_item( rheap.extract_min() );
// xxx should check error here
elt = rheap.extract_min();
mergedStr->write_item(elt);
// SDEBUG cerr << "smerge: written " << elt << endl;
i++;
}

SDEBUG cout << "..done\n";
Expand Down
10 changes: 0 additions & 10 deletions lib/gis/parser_wps.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ void G__wps_print_process_description(void)
const char **keywords = NULL;
int data_type, is_input, is_output;
int num_raster_inputs = 0, num_raster_outputs = 0;
int num_vector_inputs = 0, num_vector_outputs = 0;
int num_strds_inputs = 0, num_strds_outputs = 0;
int num_stvds_inputs = 0, num_stvds_outputs = 0;
int min = 0, max = 0;
int num_keywords = 0;
int found_output = 0;
Expand Down Expand Up @@ -275,10 +273,6 @@ void G__wps_print_process_description(void)
}
if (strcmp(token, "vector") == 0) {
data_type = TYPE_VECTOR;
if (is_input == 1)
num_vector_inputs++;
if (is_output == 1)
num_vector_outputs++;
}
/* Modules may have different types of space time datasets
* as inputs */
Expand All @@ -294,10 +288,6 @@ void G__wps_print_process_description(void)
}
if (strcmp(token, "stvds") == 0) {
data_type = TYPE_STVDS;
if (is_input == 1)
num_stvds_inputs++;
if (is_output == 1)
num_stvds_outputs++;
}
if (strcmp(token, "file") == 0) {
data_type = TYPE_PLAIN_TEXT;
Expand Down
4 changes: 2 additions & 2 deletions lib/gis/spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,13 +919,13 @@ int G_spawn_ex(const char *command, ...)
int G_spawn(const char *command, ...)
{
const char *args[MAX_ARGS];
int num_args = 0, i;
int num_args = 0;
va_list va;
int status = -1;

va_start(va, command);

for (i = 0;; i++) {
for (;;) {
const char *arg = va_arg(va, const char *);

args[num_args++] = arg;
Expand Down
5 changes: 1 addition & 4 deletions lib/gmath/blas_level_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,11 @@ void G_math_f_asum_norm(float *x, float *value, int rows)
{
int i;

int count = 0;

float s = 0.0;

#pragma omp parallel for schedule(static) private(i) reduction(+ : s, count)
#pragma omp parallel for schedule(static) private(i) reduction(+ : s)
for (i = 0; i < rows; i++) {
s += fabs(x[i]);
count++;
}
#pragma omp single
{
Expand Down
3 changes: 1 addition & 2 deletions lib/lidar/zones.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ void P_Aux_to_Vector(struct Map_info *Map, struct Map_info *Out,
dbDriver *driver, char *tab_name)
{

int more, type, count = 0;
int more, type;
double coordX, coordY, coordZ;

struct line_pnts *point;
Expand All @@ -592,7 +592,6 @@ void P_Aux_to_Vector(struct Map_info *Map, struct Map_info *Out,
db_open_select_cursor(driver, &sql, &cursor, DB_SEQUENTIAL);

while (db_fetch(&cursor, DB_NEXT, &more) == DB_OK && more) {
count++;
table = db_get_cursor_table(&cursor);

column = db_get_table_column(table, 0);
Expand Down
3 changes: 0 additions & 3 deletions lib/ogsf/gsd_fringe.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ void gsd_fringe_vert_line(float bot, geosurf *surf, int col, int side)
void gsd_fringe_horiz_line2(float bot, geosurf *surf, int row, int side)
{
int col;
int cnt;
float pt[4];
typbuff *buff;
long offset;
Expand All @@ -528,7 +527,6 @@ void gsd_fringe_horiz_line2(float bot, geosurf *surf, int row, int side)
pt[Z] = pt[Z] * surf->z_exag;
gsd_vert_func(pt);

cnt = 1;
for (col = 0; col < xcnt - 1; col++) {
/* bottom right */
pt[X] = surf->xmin + (col * (surf->x_mod * surf->xres));
Expand All @@ -537,7 +535,6 @@ void gsd_fringe_horiz_line2(float bot, geosurf *surf, int row, int side)
GET_MAPATT(buff, offset, pt[Z]);
pt[Z] = pt[Z] * surf->z_exag;
gsd_vert_func(pt);
cnt++;
}

col--;
Expand Down
4 changes: 0 additions & 4 deletions lib/ogsf/gsd_surf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,6 @@ int gsd_surf_map(geosurf *surf)
GLdouble modelMatrix[16], projMatrix[16];
GLint viewport[4];
GLint window[4];
int cnt1 = 0, cnt2 = 0;

int datacol1, datacol2, datacol3;

Expand Down Expand Up @@ -2263,8 +2262,6 @@ int gsd_surf_map(geosurf *surf)
}
*/

cnt1++;

/* Do not need BM_get because GET_MAPATT calls
* same and returns zero if masked
*/
Expand Down Expand Up @@ -2357,7 +2354,6 @@ int gsd_surf_map(geosurf *surf)

} /* close ii loop */
gsd_endtfan();
cnt2++;
} /* end col */
} /* end row */

Expand Down
3 changes: 0 additions & 3 deletions lib/proj/datum.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ struct datum_list *read_datum_table(void)
char buf[4096];
int line;
struct datum_list *current = NULL, *outputlist = NULL;
int count = 0;

sprintf(file, "%s%s", G_gisbase(), DATUMTABLE);

Expand Down Expand Up @@ -381,8 +380,6 @@ struct datum_list *read_datum_table(void)
current->dy = dy;
current->dz = dz;
current->next = NULL;

count++;
}

fclose(fd);
Expand Down
3 changes: 0 additions & 3 deletions lib/proj/ellipse.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ struct ellps_list *read_ellipsoid_table(int fatal)
struct ellps_list *current = NULL, *outputlist = NULL;
double a, e2, rf;

int count = 0;

sprintf(file, "%s%s", G_gisbase(), ELLIPSOIDTABLE);
fd = fopen(file, "r");

Expand Down Expand Up @@ -273,7 +271,6 @@ struct ellps_list *read_ellipsoid_table(int fatal)
current->es = e2;
current->rf = rf;
current->next = NULL;
count++;
}
else {
err++;
Expand Down
20 changes: 1 addition & 19 deletions lib/vector/Vlib/break_polygons.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void Vect_break_polygons_file(struct Map_info *Map, int type,
int i, j, k, ret, ltype, broken, last, nlines;
int nbreaks;
struct RTree *RTree;
int npoints, nallpoints, nmarks;
int npoints;
XPNT2 XPnt;
double dx, dy, a1 = 0, a2 = 0;
int closed, last_point;
Expand Down Expand Up @@ -149,9 +149,7 @@ void Vect_break_polygons_file(struct Map_info *Map, int type,
* points, if such point already exists check angles of segments and if
* differ mark for break */

nmarks = 0;
npoints = 1; /* index starts from 1 ! */
nallpoints = 0;
XPnt.used = 0;

G_message(_("Breaking polygons (pass 1: select break points)..."));
Expand Down Expand Up @@ -183,7 +181,6 @@ void Vect_break_polygons_file(struct Map_info *Map, int type,

for (j = 0; j < Points->n_points; j++) {
G_debug(3, "j = %d", j);
nallpoints++;

if (j == last_point && closed)
continue; /* do not register last of close polygon */
Expand Down Expand Up @@ -237,7 +234,6 @@ void Vect_break_polygons_file(struct Map_info *Map, int type,
/* Check angles */
if (cross) {
XPnt.cross = 1;
nmarks++;
/* write point */
lseek(xpntfd, (off_t)(fpoint - 1) * sizeof(XPNT2),
SEEK_SET);
Expand All @@ -253,7 +249,6 @@ void Vect_break_polygons_file(struct Map_info *Map, int type,
}
else {
XPnt.cross = 1;
nmarks++;
/* write point */
lseek(xpntfd, (off_t)(fpoint - 1) * sizeof(XPNT2),
SEEK_SET);
Expand All @@ -271,7 +266,6 @@ void Vect_break_polygons_file(struct Map_info *Map, int type,
XPnt.a1 = 0;
XPnt.a2 = 0;
XPnt.cross = 1;
nmarks++;
}
else {
XPnt.a1 = a1;
Expand Down Expand Up @@ -319,7 +313,6 @@ void Vect_break_polygons_file(struct Map_info *Map, int type,
G_debug(3, "n_points = %d", Points->n_points);
for (j = 1; j < Points->n_points; j++) {
G_debug(3, "j = %d", j);
nallpoints++;

/* Box */
rect.boundary[0] = Points->x[j];
Expand Down Expand Up @@ -425,7 +418,6 @@ void Vect_break_polygons_mem(struct Map_info *Map, int type,
int i, j, k, ret, ltype, broken, last, nlines;
int nbreaks;
struct RB_TREE *RBTree;
int npoints, nallpoints, nmarks;
XPNT *XPnt_found, XPnt_search;
double dx, dy, a1 = 0, a2 = 0;
int closed, last_point, cross;
Expand All @@ -446,9 +438,6 @@ void Vect_break_polygons_mem(struct Map_info *Map, int type,
* points, if such point already exists check angles of segments and if
* differ mark for break */

nmarks = 0;
npoints = 0;
nallpoints = 0;
XPnt_search.used = 0;

G_message(_("Breaking polygons (pass 1: select break points)..."));
Expand Down Expand Up @@ -480,7 +469,6 @@ void Vect_break_polygons_mem(struct Map_info *Map, int type,

for (j = 0; j < Points->n_points; j++) {
G_debug(3, "j = %d", j);
nallpoints++;

if (j == last_point && closed)
continue; /* do not register last of close polygon */
Expand Down Expand Up @@ -522,7 +510,6 @@ void Vect_break_polygons_mem(struct Map_info *Map, int type,
/* check angles */
if (cross) {
XPnt_found->cross = 1;
nmarks++;
}
else {
G_debug(3, "a1 = %f xa1 = %f a2 = %f xa2 = %f", a1,
Expand All @@ -533,7 +520,6 @@ void Vect_break_polygons_mem(struct Map_info *Map, int type,
}
else {
XPnt_found->cross = 1;
nmarks++;
}
}
}
Expand All @@ -543,7 +529,6 @@ void Vect_break_polygons_mem(struct Map_info *Map, int type,
XPnt_search.a1 = 0;
XPnt_search.a2 = 0;
XPnt_search.cross = 1;
nmarks++;
}
else {
XPnt_search.a1 = a1;
Expand All @@ -553,13 +538,11 @@ void Vect_break_polygons_mem(struct Map_info *Map, int type,

/* Add to tree */
rbtree_insert(RBTree, &XPnt_search);
npoints++;
}
}
}

nbreaks = 0;
nallpoints = 0;
G_debug(2, "Break polygons: unique vertices: %ld", (long int)RBTree->count);

/* uncomment to check if search tree is healthy */
Expand Down Expand Up @@ -594,7 +577,6 @@ void Vect_break_polygons_mem(struct Map_info *Map, int type,
G_debug(3, "n_points = %d", Points->n_points);
for (j = 1; j < Points->n_points; j++) {
G_debug(3, "j = %d", j);
nallpoints++;

if (Points->n_points <= 1 ||
(j == (Points->n_points - 1) && !broken))
Expand Down
8 changes: 4 additions & 4 deletions lib/vector/Vlib/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ int Vect_build_partial(struct Map_info *Map, int build)

if (plus->built >= GV_BUILD_AREAS) {
int line, nlines, area, nareas, err_boundaries, err_centr_out,
err_centr_dupl, err_nocentr;
err_centr_dupl /*, err_nocentr */;
struct P_line *Line;
struct Plus_head *Plus;

Expand Down Expand Up @@ -961,14 +961,14 @@ int Vect_build_partial(struct Map_info *Map, int build)
}
}

err_nocentr = 0;
/* err_nocentr = 0; */
nareas = Vect_get_num_areas(Map);
for (area = 1; area <= nareas; area++) {
if (!Vect_area_alive(Map, area))
continue;
line = Vect_get_area_centroid(Map, area);
if (line == 0)
err_nocentr++;
/* if (line == 0)
err_nocentr++; */
}

G_verbose_message(_("Number of areas: %d"), plus->n_areas);
Expand Down

0 comments on commit 7780e94

Please sign in to comment.