From 34161aab69dc7f97873947a68dc0f709260d6d02 Mon Sep 17 00:00:00 2001 From: Ward Fisher Date: Tue, 10 Jan 2017 13:54:09 -0700 Subject: [PATCH] Added fixes for Visual Studio 10 --- libsrc4/nc4hdf.c | 7 ++++--- ncgen/semantics.c | 39 ++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/libsrc4/nc4hdf.c b/libsrc4/nc4hdf.c index 9daa27a00..52a03fa7e 100644 --- a/libsrc4/nc4hdf.c +++ b/libsrc4/nc4hdf.c @@ -3651,7 +3651,7 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp) NC_DIM_INFO_T *dim; int retval = NC_NOERR; int i; - + assert(grp && grp->name); LOG((4, "%s: grp->name %s", __func__, grp->name)); @@ -3664,11 +3664,12 @@ nc4_rec_match_dimscales(NC_GRP_INFO_T *grp) * try and find a dimension for them. */ for (i=0; i < grp->vars.nelems; i++) { + int ndims; + int d; var = grp->vars.value[i]; if (!var) continue; /* Check all vars and see if dim[i] != NULL if dimids[i] valid. */ - int ndims = var->ndims; - int d; + ndims = var->ndims; for (d = 0; d < ndims; d++) { if (var->dim[d] == NULL) { diff --git a/ncgen/semantics.c b/ncgen/semantics.c index 018766ea1..c2da4dba3 100644 --- a/ncgen/semantics.c +++ b/ncgen/semantics.c @@ -600,6 +600,7 @@ computesize(Symbol* tsym) { int i; int offset = 0; + int largealign; unsigned long totaldimsize; if(tsym->touched) return; tsym->touched=1; @@ -627,29 +628,29 @@ computesize(Symbol* tsym) break; case NC_COMPOUND: /* keep if all fields are primitive*/ /* First, compute recursively, the size and alignment of fields*/ - for(i=0;isubnodes);i++) { + for(i=0;isubnodes);i++) { Symbol* field = (Symbol*)listget(tsym->subnodes,i); - ASSERT(field->subclass == NC_FIELD); + ASSERT(field->subclass == NC_FIELD); computesize(field); /* alignment of struct is same as alignment of first field*/ if(i==0) tsym->typ.alignment = field->typ.alignment; - } - /* now compute the size of the compound based on*/ - /* what user specified*/ - offset = 0; - int largealign = 1; - for(i=0;isubnodes);i++) { - Symbol* field = (Symbol*)listget(tsym->subnodes,i); - /* only support 'c' alignment for now*/ - int alignment = field->typ.alignment; - int padding = getpadding(offset,alignment); - offset += padding; - field->typ.offset = offset; - offset += field->typ.size; - if (alignment > largealign) { - largealign = alignment; - } - } + } + /* now compute the size of the compound based on*/ + /* what user specified*/ + offset = 0; + largealign = 1; + for(i=0;isubnodes);i++) { + Symbol* field = (Symbol*)listget(tsym->subnodes,i); + /* only support 'c' alignment for now*/ + int alignment = field->typ.alignment; + int padding = getpadding(offset,alignment); + offset += padding; + field->typ.offset = offset; + offset += field->typ.size; + if (alignment > largealign) { + largealign = alignment; + } + } tsym->typ.cmpdalign = largealign; /* total structure size alignment */ offset += (offset % largealign); tsym->typ.size = offset;