Skip to content

Commit

Permalink
rst/interpfl lib: change devi arg to bool (#1271)
Browse files Browse the repository at this point in the history
Output deviation argument to IL_init_params_2d() and in the
interp_params struct, was defined as FILE*. In practice a char* of the
file path was given to the function in 'v.surf.rst/main.c' and this
pointer's only use was to check whether it was NULL or not. It was used
as a flag. This changes the argument to be a bool.

Addresses a -Wincompatible-pointer-types compiler warning.
  • Loading branch information
nilason committed Aug 19, 2021
1 parent 53a7768 commit 5e2fd30
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/rst/interp_float/init2d.c
Expand Up @@ -54,7 +54,7 @@ void IL_init_params_2d(struct interp_params *params,
double scl, /*!< anisotropy scaling factor */
FILE * t1, FILE * t2, FILE * t3, FILE * t4, FILE * t5,
FILE * t6, /*!< temp files for writing interp. values (t1-t6) */
FILE * dev, /*!< pointer to deviations file */
bool create_devi, /*!< create deviations file? */
struct TimeStamp *ts,
int c, /*!< cross validation */
const char *wheresql /*!< SQL WHERE statement */
Expand Down Expand Up @@ -99,7 +99,7 @@ void IL_init_params_2d(struct interp_params *params,
params->Tmp_fd_xx = t4;
params->Tmp_fd_yy = t5;
params->Tmp_fd_xy = t6;
params->fddevi = dev;
params->create_devi = create_devi;
params->ts = ts;
params->cv = c;
params->wheresql = wheresql;
Expand Down
4 changes: 2 additions & 2 deletions lib/rst/interp_float/interpf.h
Expand Up @@ -92,7 +92,7 @@ struct interp_params
FILE *Tmp_fd_z, *Tmp_fd_dx,
*Tmp_fd_dy, *Tmp_fd_xx,
*Tmp_fd_yy, *Tmp_fd_xy; /**< temp files for writing interp. values */
FILE *fddevi; /**< pointer to deviations file */
bool create_devi; /**< create deviations file? */

grid_calc_fn *grid_calc; /**< calculates grid for given segm */
matrix_create_fn *matrix_create; /**< creates matrix for a given segm */
Expand All @@ -118,7 +118,7 @@ void IL_init_params_2d(struct interp_params *, FILE *, int, int, double,
double, int, int, int, int, double,
char *, char *, char *, char *, char *, char *,
double, double, double, int, double, double,
FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, FILE *,
FILE *, FILE *, FILE *, FILE *, FILE *, FILE *, bool,
struct TimeStamp *, int, const char *);

void IL_init_func_2d(struct interp_params *, grid_calc_fn *,
Expand Down
2 changes: 1 addition & 1 deletion lib/rst/interp_float/point2d.c
Expand Up @@ -110,7 +110,7 @@ int IL_check_at_points_2d(struct interp_params *params,
else
inside = 0;

if (params->fddevi != NULL) {
if (params->create_devi) {

if (inside) { /* if the point is inside the region */
Vect_reset_line(Pnts);
Expand Down
2 changes: 1 addition & 1 deletion raster/r.resamp.rst/main.c
Expand Up @@ -451,7 +451,7 @@ int main(int argc, char *argv[])
fi, MAXPOINTS, SCIK1, SCIK2, SCIK3, smc, elev, slope,
aspect, pcurv, tcurv, mcurv, dmin, inp_x_orig,
inp_y_orig, deriv, theta, scalex, Tmp_fd_z, Tmp_fd_dx,
Tmp_fd_dy, Tmp_fd_xx, Tmp_fd_yy, Tmp_fd_xy, NULL, NULL,
Tmp_fd_dy, Tmp_fd_xx, Tmp_fd_yy, Tmp_fd_xy, false, NULL,
0, NULL);

/* In the above line, the penultimate argument is supposed to be a
Expand Down
4 changes: 3 additions & 1 deletion vector/v.surf.rst/main.c
Expand Up @@ -88,6 +88,7 @@ static char *tcurv = NULL;
static char *mcurv = NULL;
static char *maskmap = NULL;
static char *devi = NULL;
static bool create_devi = false;
static char *cvdev = NULL;
static int sdisk, disk, ddisk, sddisk;
static FILE *Tmp_fd_z = NULL;
Expand Down Expand Up @@ -631,6 +632,7 @@ int main(int argc, char *argv[])
}
db_begin_transaction(driver2);
count = 1;
create_devi = true;

}

Expand All @@ -643,7 +645,7 @@ int main(int argc, char *argv[])
SCIK1, SCIK2, SCIK3, rsm, elev, slope, aspect, pcurv,
tcurv, mcurv, dmin, x_orig, y_orig, deriv, theta,
scalex, Tmp_fd_z, Tmp_fd_dx, Tmp_fd_dy, Tmp_fd_xx,
Tmp_fd_yy, Tmp_fd_xy, devi, NULL, cv,
Tmp_fd_yy, Tmp_fd_xy, create_devi, NULL, cv,
parm.wheresql->answer);

IL_init_func_2d(&params, IL_grid_calc_2d, IL_matrix_create,
Expand Down

0 comments on commit 5e2fd30

Please sign in to comment.