Skip to content

Commit

Permalink
Merge pull request #2840 from ZedThree/silence-ncdump-warnings
Browse files Browse the repository at this point in the history
Silence ncdump warnings
  • Loading branch information
WardF authored Feb 9, 2024
2 parents 6671a80 + 700dfd2 commit 25fc13b
Show file tree
Hide file tree
Showing 20 changed files with 104 additions and 133 deletions.
17 changes: 6 additions & 11 deletions ncdump/chunkspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ dimchunkspec_size(int indimid) {
/* Return number of dimensions for which chunking was specified in
* chunkspec string on command line, 0 if no chunkspec string was
* specified. */
int
size_t
dimchunkspec_ndims(void) {
return dimchunkspecs.ndims;
}
Expand Down Expand Up @@ -337,8 +337,7 @@ varchunkspec_parse(int igrp, const char *spec0)
int
varchunkspec_kind(int grpid, int varid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == grpid && spec->ivarid == varid)
return spec->kind;
Expand All @@ -349,8 +348,7 @@ varchunkspec_kind(int grpid, int varid)
bool_t
varchunkspec_exists(int igrpid, int ivarid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == igrpid && spec->ivarid == ivarid)
return true;
Expand All @@ -361,8 +359,7 @@ varchunkspec_exists(int igrpid, int ivarid)
bool_t
varchunkspec_omit(int igrpid, int ivarid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == igrpid && spec->ivarid == ivarid)
return spec->omit;
Expand All @@ -373,8 +370,7 @@ varchunkspec_omit(int igrpid, int ivarid)
size_t*
varchunkspec_chunksizes(int igrpid, int ivarid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == igrpid && spec->ivarid == ivarid)
return spec->chunksizes;
Expand All @@ -385,8 +381,7 @@ varchunkspec_chunksizes(int igrpid, int ivarid)
size_t
varchunkspec_rank(int igrpid, int ivarid)
{
int i;
for(i=0;i<listlength(varchunkspecs);i++) {
for(size_t i=0;i<listlength(varchunkspecs);i++) {
struct VarChunkSpec* spec = listget(varchunkspecs,i);
if(spec->igrpid == igrpid && spec->ivarid == ivarid)
return spec->rank;
Expand Down
5 changes: 4 additions & 1 deletion ncdump/chunkspec.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#ifndef _CHUNKSPEC_H_
#define _CHUNKSPEC_H_

#include <stddef.h>
#include "utils.h"

/* Parse chunkspec string and convert into internal data structure,
* associating dimids from open file or group specified by ncid with
* corresponding chunk sizes */
Expand All @@ -25,7 +28,7 @@ dimchunkspec_exists(int indimid);
/* Return number of dimensions for which chunking was specified in
* chunkspec string on command line, 0 if no chunkspec string was
* specified. */
extern int
extern size_t
dimchunkspec_ndims(void);

/* Return whether chunking should be omitted, due to explicit
Expand Down
16 changes: 6 additions & 10 deletions ncdump/dumplib.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ int ncstring_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp
sp = sout;
*sp++ = '"' ;
while(*cp) {
switch (uc = *cp++ & 0377) {
switch (uc = (unsigned char)*cp++ & 0377) {
case '\b':
*sp++ = '\\';
*sp++ = 'b' ;
Expand Down Expand Up @@ -904,7 +904,7 @@ int ncstring_typ_tostring(const nctype_t *typ, safebuf_t *sfbf, const void *valp
sp += 4;
}
else
*sp++ = uc;
*sp++ = (char)uc;
break;
}
}
Expand Down Expand Up @@ -1045,7 +1045,7 @@ chars_tostring(
len--;
for (iel = 0; iel < len; iel++) {
unsigned char uc;
switch (uc = *vals++ & 0377) {
switch (uc = (unsigned char)(*vals++ & 0377)) {
case '\b':
case '\f':
case '\n':
Expand All @@ -1062,7 +1062,7 @@ chars_tostring(
if (isprint(uc))
*cp++ = *(char *)&uc; /* just copy, even if char is signed */
else {
size_t remaining = sout_size - (cp - sout);
size_t remaining = sout_size - (size_t)(cp - sout);
snprintf(cp,remaining,"\\%.3o",uc);
cp += 4;
}
Expand Down Expand Up @@ -1806,10 +1806,8 @@ print_type_name(int locid, int typeid) {
static int
init_is_unlim(int ncid, int **is_unlim_p)
{
int num_grps; /* total number of groups */
int num_dims = 0; /* total number of dimensions in all groups */
size_t num_grps; /* total number of groups */
int max_dimid = -1; /* maximum dimid across whole dataset */
int num_undims = 0; /* total number of unlimited dimensions in all groups */
int *grpids = NULL; /* temporary list of all grpids */
int igrp;
int grpid;
Expand All @@ -1824,7 +1822,7 @@ init_is_unlim(int ncid, int **is_unlim_p)
return NC_EBADGRPID;
/* Now ncid is root group. Get total number of groups and their ids */
NC_CHECK( nc_inq_grps_full(ncid, &num_grps, NULL) );
grpids = emalloc((size_t)(num_grps + 1) * sizeof(int));
grpids = emalloc((num_grps + 1) * sizeof(int));
NC_CHECK( nc_inq_grps_full(ncid, &num_grps, grpids) );
#define DONT_INCLUDE_PARENTS 0
/* Get all dimensions in groups and info about which ones are unlimited */
Expand All @@ -1836,7 +1834,6 @@ init_is_unlim(int ncid, int **is_unlim_p)
int* dimids = NULL;
grpid = grpids[igrp];
NC_CHECK( nc_inq_dimids(grpid, &ndims, NULL, DONT_INCLUDE_PARENTS) );
num_dims += ndims;
dimids = (int*)emalloc((size_t)ndims*sizeof(int));
NC_CHECK( nc_inq_dimids(grpid, &ndims, dimids, DONT_INCLUDE_PARENTS) );
for(i=0;i<ndims;i++) {if(dimids[i] > max_dimid) max_dimid = dimids[i];}
Expand All @@ -1863,7 +1860,6 @@ init_is_unlim(int ncid, int **is_unlim_p)
int* isunlim = *is_unlim_p;
int did = dimids[idim];
isunlim[did] = 1;
num_undims++;
}
if(dimids)
free(dimids);
Expand Down
3 changes: 1 addition & 2 deletions ncdump/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ int
listfreeall(List* l)
{
if(l) {
int i;
for(i=0;i<listlength(l);i++) {
for(size_t i=0;i<listlength(l);i++) {
void* elem = listget(l,i);
if(elem != NULL) free(elem);
}
Expand Down
10 changes: 4 additions & 6 deletions ncdump/nc4printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,8 @@ printNode(NC4printer* out, NCID* node, int depth)
CAT(">\n");
depth++;
for(i=0;i<count;i++) {
long long value;
if((ret=nc_inq_enum_member(GROUPOF(node),node->id,i,name,&numvalue))) FAIL;
value = getNumericValue(numvalue,node->base->id);
long long value = (long long)getNumericValue(numvalue,node->base->id);
INDENT(depth);
CAT("<EnumConst");
printXMLAttributeName(out, "name", name);
Expand Down Expand Up @@ -443,15 +442,14 @@ static int
printAttribute(NC4printer* out, NCID* attr, int depth)
{
int ret = NC_NOERR;
int i = 0;
void* values;

INDENT(depth); CAT("<Attribute");
printXMLAttributeName(out,"name",attr->name);
CAT(">\n");
if((ret=readAttributeValues(attr,&values))) FAIL;
depth++;
for(i=0;i<attr->size;i++) {
for(size_t i=0;i<attr->size;i++) {
void* value = computeOffset(attr->base,values,i);
if((ret=printValue(out,attr->base,value,depth))) FAIL;
}
Expand Down Expand Up @@ -696,7 +694,7 @@ entityEscape(NCbytes* escaped, const char* s)
const char* p;
ncbytesclear(escaped);
for(p=s;*p;p++) {
int c = *p;
char c = *p;
switch (c) {
case '&': ncbytescat(escaped,"&amp;"); break;
case '<': ncbytescat(escaped,"&lt;"); break;
Expand Down Expand Up @@ -735,7 +733,7 @@ printString(NCbytes* out, const char* s, int quotes)
if(quotes) ncbytesappend(out,'"');
if(s == NULL) s = "";
for(p=s;*p;p++) {
int c = *p;
char c = *p;
if(c == '\\') ncbytescat(out,"\\\\");
else if(c == '"') ncbytescat(out,"\\\"");
else ncbytesappend(out,c);
Expand Down
Loading

0 comments on commit 25fc13b

Please sign in to comment.