Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings #1281

Merged
merged 9 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/ncconfigure.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ typedef unsigned short ushort;
typedef unsigned int uint;
#endif

#ifndef NC_UNUSED
#define NC_UNUSED(var) (void)var
#endif

#endif /* NCCONFIGURE_H */
23 changes: 23 additions & 0 deletions libdispatch/dparallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ int nc_create_par(const char *path, int cmode, MPI_Comm comm,
MPI_Info info, int *ncidp)
{
#ifndef USE_PARALLEL
NC_UNUSED(path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with this. This clutters up the code only in order to suppress warnings? That's what a warning suppression file is for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These warnings appear from VTK's embedding of NetCDF into its source tree (mainly for Windows users' convenience) where these warnings appear with our default CI configurations. We can certainly keep the patches in our import, but I'm trying to minimize our diffs against upstream code.

As for clutter, I don't see this as "clutter". It's an explicit acknowledgement that path is not used in the non-parallel path. I wish there were a way to say "warn if this line is no longer necessary", but I don't know of any. This line also fixes the warning for all known compilers with any given set of warning flags. Doing per-compiler suppression regexes or pragmas is, IME, way more complicated.

I can also go back to the literal (void)path; code rather than adding a new (internal) macro. Would adding a // unused parameter comment on the lines help?

NC_UNUSED(cmode);
NC_UNUSED(comm);
NC_UNUSED(info);
NC_UNUSED(ncidp);
return NC_ENOPAR;
#else
NC_MPI_INFO data;
Expand Down Expand Up @@ -201,6 +206,11 @@ nc_open_par(const char *path, int omode, MPI_Comm comm,
MPI_Info info, int *ncidp)
{
#ifndef USE_PARALLEL
NC_UNUSED(path);
NC_UNUSED(omode);
NC_UNUSED(comm);
NC_UNUSED(info);
NC_UNUSED(ncidp);
return NC_ENOPAR;
#else
NC_MPI_INFO mpi_data;
Expand Down Expand Up @@ -249,6 +259,11 @@ nc_open_par_fortran(const char *path, int omode, int comm,
int info, int *ncidp)
{
#ifndef USE_PARALLEL
NC_UNUSED(path);
NC_UNUSED(omode);
NC_UNUSED(comm);
NC_UNUSED(info);
NC_UNUSED(ncidp);
return NC_ENOPAR;
#else
MPI_Comm comm_c;
Expand Down Expand Up @@ -348,6 +363,9 @@ int
nc_var_par_access(int ncid, int varid, int par_access)
{
#ifndef USE_PARALLEL
NC_UNUSED(ncid);
NC_UNUSED(varid);
NC_UNUSED(par_access);
return NC_ENOPAR;
#else
int stat = NC_NOERR;
Expand Down Expand Up @@ -403,6 +421,11 @@ nc_create_par_fortran(const char *path, int cmode, int comm,
int info, int *ncidp)
{
#ifndef USE_PARALLEL
NC_UNUSED(path);
NC_UNUSED(cmode);
NC_UNUSED(comm);
NC_UNUSED(info);
NC_UNUSED(ncidp);
return NC_ENOPAR;
#else
MPI_Comm comm_c;
Expand Down
4 changes: 2 additions & 2 deletions libdispatch/drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ rcsearch(const char* prefix, const char* rcname, char** pathp)
{
char* path = NULL;
FILE* f = NULL;
int plen = strlen(prefix);
int rclen = strlen(rcname);
size_t plen = strlen(prefix);
size_t rclen = strlen(rcname);
int ret = NC_NOERR;

size_t pathlen = plen+rclen+1; /*+1 for '/' */
Expand Down
2 changes: 1 addition & 1 deletion libdispatch/dutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ NC_mktmp(const char* base)
char spid[7];
if(rno < 0) rno = -rno;
snprintf(spid,sizeof(spid),"%06d",rno);
strncat(tmp,spid,sizeof(tmp));
strncat(tmp,spid,sizeof(tmp) - strlen(tmp) - 1);
}
#endif /* HAVE_MKTEMP */
#ifdef _MSC_VER
Expand Down
1 change: 1 addition & 0 deletions libdispatch/nclog.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ Each line will be sent using nclog with the specified tag.
void
nclogtextn(int tag, const char* text, size_t count)
{
NC_UNUSED(tag);
if(!nclogging || nclogstream == NULL) return;
fwrite(text,1,count,nclogstream);
fflush(nclogstream);
Expand Down
4 changes: 3 additions & 1 deletion libdispatch/nctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include "ncconfigure.h"
#include "nctime.h"

static int cuErrOpts; /* Error options */
Expand Down Expand Up @@ -309,7 +310,7 @@ cdParseRelunits(cdCalenType timetype, char* relunits, cdUnitTime* unit, cdCompTi
char charunits[CD_MAX_RELUNITS];
char basetime_1[CD_MAX_CHARTIME];
char basetime_2[CD_MAX_CHARTIME];
char basetime[CD_MAX_CHARTIME];
char basetime[2 * CD_MAX_CHARTIME + 1];
int nconv1, nconv2, nconv;

/* Parse the relunits */
Expand Down Expand Up @@ -659,6 +660,7 @@ Cdh2e(CdTime *htime, double *etime)
static int
cdValidateTime(cdCalenType timetype, cdCompTime comptime)
{
NC_UNUSED(timetype);
if(comptime.month<1 || comptime.month>12){
cdError("Error on time conversion: invalid month = %hd\n",comptime.month);
return 1;
Expand Down
4 changes: 2 additions & 2 deletions libdispatch/ncuri.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static char* queryallow =
static char* userpwdallow =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!$&'()*+,-.;=_~?#/";

#ifndef HAVE_STRNCMP
#ifndef HAVE_STRNDUP
#define strndup ncstrndup
/* Not all systems have strndup, so provide one*/
char*
Expand Down Expand Up @@ -258,7 +258,7 @@ ncuriparse(const char* uri0, NCURI** durip)

isfile = (strcmp(tmp.protocol,"file")==0);
if(isfile) {
int l = strlen(p); /* to test if we have enough characters */
size_t l = strlen(p); /* to test if we have enough characters */
hashost = 0; /* always */
if(l >= 2 && p[1] == ':' && strchr(DRIVELETTERS,p[0]) != NULL) { /* case 1 */
; /* p points to the start of the path */
Expand Down
10 changes: 10 additions & 0 deletions libsrc/posixio.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ blksize(int fd)
return 8192;
}
/* else, silent in the face of error */
#else
NC_UNUSED(fd);
#endif
#else
NC_UNUSED(fd);
#endif
return (size_t) 2 * pagesize();
}
Expand Down Expand Up @@ -445,6 +449,7 @@ px_rel(ncio_px *const pxp, off_t offset, int rflags)
&& offset < pxp->bf_offset + (off_t) pxp->bf_extent);
assert(pIf(fIsSet(rflags, RGN_MODIFIED),
fIsSet(pxp->bf_rflags, RGN_WRITE)));
NC_UNUSED(offset);

if(fIsSet(rflags, RGN_MODIFIED))
{
Expand Down Expand Up @@ -797,6 +802,7 @@ px_double_buffer(ncio *const nciop, off_t to, off_t from,
int status = NC_NOERR;
void *src;
void *dest;
NC_UNUSED(rflags);

#if INSTRUMENT
fprintf(stderr, "\tdouble_buffr %ld %ld %ld\n",
Expand Down Expand Up @@ -1152,6 +1158,7 @@ ncio_spx_rel(ncio *const nciop, off_t offset, int rflags)
assert(offset < pxp->bf_offset + X_ALIGN);
assert(pxp->bf_cnt % X_ALIGN == 0 );
#endif
NC_UNUSED(offset);

if(fIsSet(rflags, RGN_MODIFIED))
{
Expand Down Expand Up @@ -1400,6 +1407,7 @@ ncio_spx_move(ncio *const nciop, off_t to, off_t from,
static int
ncio_spx_sync(ncio *const nciop)
{
NC_UNUSED(nciop);
/* NOOP */
return NC_NOERR;
}
Expand Down Expand Up @@ -1592,6 +1600,7 @@ posixio_create(const char *path, int ioflags,
int oflags = (O_RDWR|O_CREAT);
int fd;
int status;
NC_UNUSED(parameters);

if(initialsz < (size_t)igeto + igetsz)
initialsz = (size_t)igeto + igetsz;
Expand Down Expand Up @@ -1736,6 +1745,7 @@ posixio_open(const char *path,
int oflags = fIsSet(ioflags, NC_WRITE) ? O_RDWR : O_RDONLY;
int fd = -1;
int status = 0;
NC_UNUSED(parameters);

if(path == NULL || *path == 0)
return EINVAL;
Expand Down
3 changes: 3 additions & 0 deletions libsrc4/nc4var.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,9 @@ int
NC4_var_par_access(int ncid, int varid, int par_access)
{
#ifndef USE_PARALLEL4
NC_UNUSED(ncid);
NC_UNUSED(varid);
NC_UNUSED(par_access);
return NC_ENOPAR;
#else
NC *nc;
Expand Down