Skip to content

Commit

Permalink
Fix '-Wunused-parameter' compiler warnings (#2770)
Browse files Browse the repository at this point in the history
The absolute majority of the "-Wunused-parameter" compiler warnings are addressed by adding
__attribute__((unused)) with the macro 'UNUSED'.
  • Loading branch information
nilason committed Feb 12, 2023
1 parent 2080e73 commit 7d6ff54
Show file tree
Hide file tree
Showing 236 changed files with 654 additions and 492 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ jobs:
env:
# TODO: -pedantic-errors here won't go through ./configure (with GNU C)
CFLAGS: -std=${{ matrix.c }} -fPIC -Wall -Wextra
-Wno-error=implicit-fallthrough -Wno-error=unused-parameter
-Wno-error=implicit-fallthrough
# TODO: -pedantic-errors here won't compile
CXXFLAGS: -std=${{ matrix.cpp }} -fPIC -Wall -Wextra
-Wno-error=implicit-fallthrough -Wno-error=unused-parameter
-Wno-error=implicit-fallthrough
run: .github/workflows/build_ubuntu-22.04.sh $HOME/install -Werror
4 changes: 2 additions & 2 deletions .github/workflows/macos_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ CONFIGURE_FLAGS="\
--with-readline-libs=${CONDA_PREFIX}/lib
"

export CFLAGS="-O2 -pipe -arch ${CONDA_ARCH} -DGL_SILENCE_DEPRECATION -Wall -Wextra -Wno-error=unused-parameter"
export CXXFLAGS="-O2 -pipe -stdlib=libc++ -arch ${CONDA_ARCH} -Wall -Wextra -Wno-error=unused-parameter"
export CFLAGS="-O2 -pipe -arch ${CONDA_ARCH} -DGL_SILENCE_DEPRECATION -Wall -Wextra"
export CXXFLAGS="-O2 -pipe -stdlib=libc++ -arch ${CONDA_ARCH} -Wall -Wextra"

./configure $CONFIGURE_FLAGS

Expand Down
3 changes: 2 additions & 1 deletion db/drivers/dbf/dbfexe.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ void get_col_def(SQLPSTMT *st, int col, int *type, int *width, int *decimals)
}
}

void eval_val(int tab, int row, int col, SQLPVALUE *inval, SQLPVALUE *val)
void eval_val(int tab, int row, int col UNUSED, SQLPVALUE *inval,
SQLPVALUE *val)
{

double retval;
Expand Down
2 changes: 1 addition & 1 deletion db/drivers/dbf/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "globals.h"
#include "proto.h"

int db__driver_init(int argc, char *argv[])
int db__driver_init(int argc UNUSED, char *argv[] UNUSED)
{
init_error();
return DB_OK;
Expand Down
2 changes: 1 addition & 1 deletion db/drivers/dbf/listtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "globals.h"
#include "proto.h"

int db__driver_list_tables(dbString **tlist, int *tcount, int system)
int db__driver_list_tables(dbString **tlist, int *tcount, int system UNUSED)
{
dbString *list;
int i;
Expand Down
2 changes: 1 addition & 1 deletion db/drivers/ogr/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
\return DB_OK on success
*/
int db__driver_init(int argc, char *argv[])
int db__driver_init(int argc UNUSED, char *argv[] UNUSED)
{
init_error();
return DB_OK;
Expand Down
2 changes: 1 addition & 1 deletion db/drivers/ogr/listtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
\return DB_OK on success
\return DB_FAILED on failure
*/
int db__driver_list_tables(dbString **tlist, int *tcount, int system)
int db__driver_list_tables(dbString **tlist, int *tcount, int system UNUSED)
{
int i, nlayers;
dbString *list;
Expand Down
2 changes: 1 addition & 1 deletion db/drivers/postgres/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "globals.h"
#include "proto.h"

static void notice_processor(void *arg, const char *message)
static void notice_processor(void *arg UNUSED, const char *message)
{
/* print notice messages only on verbose level */
if (G_verbose() > G_verbose_std()) {
Expand Down
2 changes: 1 addition & 1 deletion db/drivers/postgres/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "globals.h"
#include "proto.h"

int db__driver_init(int argc, char *argv[])
int db__driver_init(int argc UNUSED, char *argv[] UNUSED)
{
init_error();
return DB_OK;
Expand Down
2 changes: 1 addition & 1 deletion db/drivers/sqlite/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "globals.h"
#include "proto.h"

int db__driver_init(int argc, char *argv[])
int db__driver_init(int argc UNUSED, char *argv[] UNUSED)
{
init_error();

Expand Down
2 changes: 1 addition & 1 deletion db/drivers/sqlite/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int main(int argc, char *argv[])
exit(db_driver(argc, argv));
}

int sqlite_busy_callback(void *arg, int n_calls)
int sqlite_busy_callback(void *arg UNUSED, int n_calls)
{
static time_t start_time = 0;
time_t curr_time;
Expand Down
2 changes: 1 addition & 1 deletion display/d.path/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#define WDTH 5

int display(struct Map_info *Map, struct line_pnts *Points,
int display(struct Map_info *Map UNUSED, struct line_pnts *Points,
const struct color_rgb *color, int first, int last, int be_bold)
{
int from, to;
Expand Down
2 changes: 1 addition & 1 deletion display/d.rhumbline/plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "local_proto.h"

void plot(double lon1, double lat1, double lon2, double lat2, int line_color,
int text_color)
int text_color UNUSED)
{
int nsteps = 1000;
int i;
Expand Down
2 changes: 1 addition & 1 deletion display/d.vect.thematic/area.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
int dareatheme(struct Map_info *Map, struct cat_list *Clist,
dbCatValArray *cvarr, double *breaks, int nbreaks,
const struct color_rgb *colors, const struct color_rgb *bcolor,
int chcat, struct Cell_head *window, int default_width)
int chcat, struct Cell_head *window, int default_width UNUSED)
{

int num, area, isle, n_isles, n_points;
Expand Down
2 changes: 1 addition & 1 deletion display/d.vect.thematic/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int display_lines(struct Map_info *Map, struct cat_list *Clist, int chcat,
}

int draw_line(int ltype, int line, const struct line_pnts *Points,
const struct line_cats *Cats, int chcat, double size,
const struct line_cats *Cats, int chcat, double size UNUSED,
int default_width, const struct cat_list *Clist, SYMBOL *Symb,
RGBA_Color *primary_color, int *n_points, int *n_lines,
int *n_centroids, int *n_boundaries, int *n_faces,
Expand Down
7 changes: 4 additions & 3 deletions display/d.vect.thematic/plot1.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ struct rgb_color palette[16] = {
/* *************************************************************** */
/* *************************************************************** */
/* *************************************************************** */
int plot1(struct Map_info *Map, int type, int area, struct cat_list *Clist,
const struct color_rgb *color, const struct color_rgb *fcolor,
int chcat, SYMBOL *Symb, int size, int id_flag, int table_colors_flag,
int plot1(struct Map_info *Map, int type, int area UNUSED,
struct cat_list *Clist, const struct color_rgb *color,
const struct color_rgb *fcolor, int chcat, SYMBOL *Symb,
int size UNUSED, int id_flag, int table_colors_flag,
int cats_color_flag, char *rgb_column, int default_width,
char *width_column, double width_scale)
{
Expand Down
2 changes: 2 additions & 0 deletions general/g.findfile/element.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ void list_elements(void)
M_show_elements();
}

#if 0
int check_element(const char *element)
{
return M_read_list(FALSE, NULL);
}
#endif
2 changes: 1 addition & 1 deletion general/g.findfile/local_proto.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* element.c */
void list_elements(void);
int check_element(const char *);
/* int check_element(const char *); */
5 changes: 3 additions & 2 deletions imagery/i.eb.netrad/r_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

#define PI M_PI

double r_net(double bbalb, double ndvi, double tempk, double dtair, double e0,
double tsw, double doy, double utc, double sunzangle)
double r_net(double bbalb, double ndvi UNUSED, double tempk, double dtair,
double e0, double tsw, double doy, double utc UNUSED,
double sunzangle)
{

/* Tsw = atmospheric transmissivity single-way (~0.7 -) */
Expand Down
4 changes: 3 additions & 1 deletion imagery/i.evapo.mh/mh_original.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <grass/gis.h>

/*Hargreaves et al, 1985. */
double mh_original(double ra, double tavg, double tmax, double tmin, double p)
double mh_original(double ra, double tavg, double tmax, double tmin,
double p UNUSED)
{
double td, result;

Expand Down
4 changes: 2 additions & 2 deletions imagery/i.evapo.pm/functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ DCELL calc_ETp(DCELL T, DCELL Z, DCELL u2, DCELL Rn, int night, DCELL Rh,
return ETp;
}

DCELL calc_openwaterETp(DCELL T, DCELL Z, DCELL u2, DCELL Rn, int day, DCELL Rh,
DCELL hc)
DCELL calc_openwaterETp(DCELL T, DCELL Z, DCELL u2, DCELL Rn, int day UNUSED,
DCELL Rh, DCELL hc UNUSED)
{
DCELL ea, delta, gamma, lambda;
DCELL P, ed, ETaero, ETp;
Expand Down
4 changes: 2 additions & 2 deletions imagery/i.gensig/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ double **matrix(int nrl, int nrh, int ncl, int nch)
return m;
}

int free_vector(double *v, int nl, int nh)
int free_vector(double *v, int nl, int nh UNUSED)
{
G_free((char *)(v + nl));

return 0;
}

int free_matrix(double **m, int nrl, int nrh, int ncl, int nch)
int free_matrix(double **m, int nrl, int nrh, int ncl, int nch UNUSED)
{
int i;

Expand Down
4 changes: 2 additions & 2 deletions imagery/i.ortho.photo/lib/cam_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ int I_read_cam_info(FILE *fd, struct Ortho_Camera_File_Ref *cam_info)
return 1;
}

int I_new_fid_point(struct Ortho_Camera_File_Ref *cam_info, char fid_id[30],
double Xf, double Yf)
int I_new_fid_point(struct Ortho_Camera_File_Ref *cam_info UNUSED,
char fid_id[30] UNUSED, double Xf UNUSED, double Yf UNUSED)
{
return 0;
}
Expand Down
9 changes: 5 additions & 4 deletions imagery/i.ortho.photo/lib/orthoref.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,8 +611,8 @@ int I_compute_ortho_equations(struct Ortho_Control_Points *cpz,
/* given ground coordinates (e1,n1,z1) and the solution from above */
/* compute the photo coordinate (e2,n2) position */
int I_ortho_ref(double e1, double n1, double z1, double *e2, double *n2,
double *z2, struct Ortho_Camera_File_Ref *cam_info, double XC,
double YC, double ZC, MATRIX M)
double *z2 UNUSED, struct Ortho_Camera_File_Ref *cam_info,
double XC, double YC, double ZC, MATRIX M)
{
MATRIX UVW, XYZ;
double U, V, W;
Expand Down Expand Up @@ -683,8 +683,9 @@ int I_ortho_ref(double e1, double n1, double z1, double *e2, double *n2,
/* and the solution from I_compute_ortho_equation */
/* compute ground position (e2,n2) */
int I_inverse_ortho_ref(double e1, double n1, double z1, double *e2, double *n2,
double *z2, struct Ortho_Camera_File_Ref *cam_info,
double XC, double YC, double ZC, MATRIX M)
double *z2 UNUSED,
struct Ortho_Camera_File_Ref *cam_info, double XC,
double YC, double ZC, MATRIX M)
{
MATRIX UVW, XYZ;
double lam, mu, nu;
Expand Down
2 changes: 1 addition & 1 deletion imagery/i.segment/watershed.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <grass/rbtree.h> /* Red Black Tree library functions */
#include "iseg.h"

int watershed(struct globals *globals)
int watershed(struct globals *globals UNUSED)
{
G_fatal_error(_("Watershed is not yet implemented"));

Expand Down
6 changes: 3 additions & 3 deletions include/grass/defs/gis.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ double G_transverse_radius_of_curvature(double, double, double);
double G_radius_of_conformal_tangent_sphere(double, double, double);

/* rd_cellhd.c */
void G__read_Cell_head(FILE *, struct Cell_head *, int);
void G__read_Cell_head_array(char **, struct Cell_head *, int);
void G__read_Cell_head(FILE *, struct Cell_head *);
void G__read_Cell_head_array(char **, struct Cell_head *);

/* remove.c */
int G_remove(const char *, const char *);
Expand Down Expand Up @@ -818,7 +818,7 @@ int G_set_verbose(int);
/* view.c */
void G_3dview_warning(int);
int G_get_3dview_defaults(struct G_3dview *, struct Cell_head *);
int G_put_3dview(const char *, const char *, const struct G_3dview *,
int G_put_3dview(const char *, const struct G_3dview *,
const struct Cell_head *);
int G_get_3dview(const char *, const char *, struct G_3dview *);

Expand Down
14 changes: 12 additions & 2 deletions include/grass/gis.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@
#define __attribute__(x)
#endif

static const char *GRASS_copyright __attribute__((unused)) =
"GRASS GNU GPL licensed Software";
/*!
\def UNUSED
\brief A macro for an attribute, if attached to a variable,
indicating that the variable is not used
*/
#if (defined(__GNUC__) || defined(__APPLE__)) && !defined(_MSC_VER)
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif

static const char *GRASS_copyright UNUSED = "GRASS GNU GPL licensed Software";

/* GRASS version, GRASS date, git short hash of last change in GRASS headers
* (and anything else in include)
Expand Down
4 changes: 2 additions & 2 deletions include/grass/iostream/embuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class merge_key {
{
return (x.k == y.k);
}
friend merge_key operator+(const merge_key &x, const merge_key &y)
friend merge_key operator+(const merge_key &x, const merge_key &y UNUSED)
{
assert(0);
return x;
Expand Down Expand Up @@ -533,7 +533,7 @@ em_buffer<T, Key>::~em_buffer()
// memory (by a previous get_stream call, for instance) in order to
// find its length
template <class T, class Key>
void em_buffer<T, Key>::check_name(unsigned int i)
void em_buffer<T, Key>::check_name(unsigned int i UNUSED)
{

#ifdef EMBUF_CHECK_NAME
Expand Down
2 changes: 1 addition & 1 deletion include/grass/iostream/empq.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class em_pqueue {

// create an em_pqueue capable to store <= N elements
em_pqueue();
em_pqueue(long N) { em_pqueue(); }; // N not used
em_pqueue(long N UNUSED) { em_pqueue(); }; // N not used

#ifdef SAVE_MEMORY
// create an empq, initialize its pq with im and insert amis in
Expand Down
2 changes: 1 addition & 1 deletion include/grass/iostream/empq_adaptive.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class EMPQueueAdaptive {
public:
/* start in INMEM regim by allocating im of size precisely twice the
size of the (pqueue within) the em_pqueue; */
EMPQueueAdaptive(long N) : EMPQueueAdaptive(){};
EMPQueueAdaptive(long N UNUSED) : EMPQueueAdaptive(){};
EMPQueueAdaptive();
EMPQueueAdaptive(size_t inMem);
~EMPQueueAdaptive();
Expand Down
2 changes: 1 addition & 1 deletion lib/calc/calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int columns;

/****************************************************************************/

static void handle_fpe(int n)
static void handle_fpe(int n UNUSED)
{
floating_point_exception = 1;
floating_point_exception_occurred = 1;
Expand Down
6 changes: 3 additions & 3 deletions lib/calc/xif.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
if(a,b,c,d) d,c,b b if a is positive, c if a is zero, d if a is negative
********************************************************************/

static int f_if_i(int argc, const int *argt, void **args)
static int f_if_i(int argc, const int *argt UNUSED, void **args)
{
CELL *res = args[0];
DCELL *arg1 = args[1];
Expand Down Expand Up @@ -89,7 +89,7 @@ static int f_if_i(int argc, const int *argt, void **args)
return 0;
}

static int f_if_f(int argc, const int *argt, void **args)
static int f_if_f(int argc, const int *argt UNUSED, void **args)
{
FCELL *res = args[0];
DCELL *arg1 = args[1];
Expand Down Expand Up @@ -164,7 +164,7 @@ static int f_if_f(int argc, const int *argt, void **args)
return 0;
}

static int f_if_d(int argc, const int *argt, void **args)
static int f_if_d(int argc, const int *argt UNUSED, void **args)
{
DCELL *res = args[0];
DCELL *arg1 = args[1];
Expand Down
2 changes: 1 addition & 1 deletion lib/cdhc/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <grass/cdhc.h>
#include "local_proto.h"

int main(int argc, char **argv)
int main(void)
{
double z[1000];
double *w;
Expand Down

0 comments on commit 7d6ff54

Please sign in to comment.