diff --git a/fsliolib/fslio.c b/fsliolib/fslio.c index 5b775e7..1307e22 100644 --- a/fsliolib/fslio.c +++ b/fsliolib/fslio.c @@ -1008,7 +1008,7 @@ size_t FslReadSliceSeries(FSLIO *fslio, void *buffer, short slice, size_t nvols) if ((slice<0) || (slice>=z)) FSLIOERR("FslReadSliceSeries: slice outside valid range"); - slbytes = x * y * (FslGetDataType(fslio, &type) / 8); + slbytes = (size_t)x * (size_t)y * (FslGetDataType(fslio, &type) / 8); volbytes = slbytes * z; orig_offset = znztell(fslio->fileptr); @@ -1129,7 +1129,7 @@ size_t FslReadTimeSeries(FSLIO *fslio, void *buffer, short xVox, short yVox, sho if ((zVox<0) || (zVox >=zdim)) FSLIOERR("FslReadTimeSeries: voxel outside valid range"); wordsize = fslio->niftiptr->nbyper; - volbytes = xdim * ydim * zdim * wordsize; + volbytes = (size_t)xdim * (size_t)ydim * (size_t)zdim * wordsize; orig_offset = znztell(fslio->fileptr); offset = ((ydim * zVox + yVox) * xdim + xVox) * wordsize; @@ -2352,16 +2352,16 @@ double ***d3matrix(int zh, int yh, int xh) /** allocate pointers to slices */ - t=(double ***) malloc((size_t)((nslice)*sizeof(double**))); + t=(double ***) malloc(nslice*sizeof(double**)); if (!t) FSLIOERR("d3matrix: allocation failure"); /** allocate pointers for ydim */ - t[0]=(double **) malloc((size_t)((nslice*nrow)*sizeof(double*))); + t[0]=(double **) malloc(nslice*nrow*sizeof(double*)); if (!t[0]) FSLIOERR("d3matrix: allocation failure"); /** allocate the data blob */ - t[0][0]=(double *) malloc((size_t)((nslice*nrow*ncol)*sizeof(double))); + t[0][0]=(double *) malloc(nslice*nrow*ncol*sizeof(double)); if (!t[0][0]) FSLIOERR("d3matrix: allocation failure"); diff --git a/nifti2/nifti2_io.c b/nifti2/nifti2_io.c index 862e47a..c3e29fc 100644 --- a/nifti2/nifti2_io.c +++ b/nifti2/nifti2_io.c @@ -6432,7 +6432,7 @@ static int nifti_read_next_extension( nifti1_extension * nex, nifti_image *nim, if( count != 2 || code == -1 ){ if( g_opts.debug > 2 ) fprintf(stderr,"-d current extension read failed\n"); - znzseek(fp, -4*count, SEEK_CUR); /* back up past any read */ + znzseek(fp, -4L*count, SEEK_CUR); /* back up past any read */ return 0; /* no extension, no error condition */ } @@ -8713,7 +8713,7 @@ int nifti_short_order(void) /* determine this CPU's byte order */ put rhs string into nim->"nam" string, with field size = "sz" */ #define QSTR(nam,sz) if( strcmp(lhs,#nam) == 0 ) \ - strncpy(nim->nam,rhs,sz), nim->nam[sz-1]='\0' + strncpy(nim->nam,rhs,sz), nim->nam[(sz)-1]='\0' /*---------------------------------------------------------------------------*/ /*! Take an XML-ish ASCII string and create a NIFTI image header to match. diff --git a/nifti2/nifti_tool.h b/nifti2/nifti_tool.h index d548f66..ba57369 100644 --- a/nifti2/nifti_tool.h +++ b/nifti2/nifti_tool.h @@ -108,10 +108,10 @@ typedef struct{ #define NT_NIM_NUM_FIELDS 63 /* in the nifti_image struct */ #define NT_HDR_TIME_NFIELDS 8 /* num slice timing fields in hdr */ #define NT_NIM_TIME_NFIELDS 11 /* num slice timing fields in nim */ -#define NT_DT_STRING -0xfff /* some strange number to abuse... */ -#define NT_DT_POINTER -0xfef /* some strange number to abuse... */ -#define NT_DT_CHAR_PTR -0xfee /* another... */ -#define NT_DT_EXT_PTR -0xfed /* and another... */ +#define NT_DT_STRING (-0xfff) /* some strange number to abuse... */ +#define NT_DT_POINTER (-0xfef) /* some strange number to abuse... */ +#define NT_DT_CHAR_PTR (-0xfee) /* another... */ +#define NT_DT_EXT_PTR (-0xfed) /* and another... */ typedef struct { int type; /* one of the DT_* types from nifti1.h */ @@ -142,7 +142,7 @@ typedef struct { dtype * pd = dptr; \ stype * ps = sptr; \ int64_t index; \ - for(index=0; index 2 ) fprintf(stderr,"-d current extension read failed\n"); - znzseek(fp, -4*count, SEEK_CUR); /* back up past any read */ + znzseek(fp, -4L*count, SEEK_CUR); /* back up past any read */ return 0; /* no extension, no error condition */ } @@ -6597,7 +6597,7 @@ int nifti_short_order(void) /* determine this CPU's byte order */ put rhs string into nim->"nam" string, with field size = "sz" */ #define QSTR(nam,sz) if( strcmp(lhs,#nam) == 0 ) \ - strncpy(nim->nam,rhs,sz), nim->nam[sz-1]='\0' + strncpy(nim->nam,rhs,sz), nim->nam[(sz)-1]='\0' /*---------------------------------------------------------------------------*/ /*! Take an XML-ish ASCII string and create a NIFTI image header to match. diff --git a/niftilib/nifti1_tool.h b/niftilib/nifti1_tool.h index a8ca5dd..9c57b27 100644 --- a/niftilib/nifti1_tool.h +++ b/niftilib/nifti1_tool.h @@ -72,10 +72,10 @@ typedef struct{ #define NT_HDR_NUM_FIELDS 43 /* in the nifti_1_header struct */ #define NT_ANA_NUM_FIELDS 47 /* in the nifti_analyze75 struct */ #define NT_NIM_NUM_FIELDS 63 /* in the nifti_image struct */ -#define NT_DT_STRING -0xfff /* some strange number to abuse... */ -#define NT_DT_POINTER -0xfef /* some strange number to abuse... */ -#define NT_DT_CHAR_PTR -0xfee /* another... */ -#define NT_DT_EXT_PTR -0xfed /* and another... */ +#define NT_DT_STRING (-0xfff) /* some strange number to abuse... */ +#define NT_DT_POINTER (-0xfef) /* some strange number to abuse... */ +#define NT_DT_CHAR_PTR (-0xfee) /* another... */ +#define NT_DT_EXT_PTR (-0xfed) /* and another... */ typedef struct { int type; /* one of the DT_* types from nifti1.h */ diff --git a/niftilib/nifti_tester001.c b/niftilib/nifti_tester001.c index 3fbc065..126e6bd 100644 --- a/niftilib/nifti_tester001.c +++ b/niftilib/nifti_tester001.c @@ -492,7 +492,7 @@ int main (int argc, const char *argv[]) snprintf(buf,sizeof(buf),"nifti_datatype_string %d",constant); \ PrintTest( \ buf, \ - nifti_is_inttype(constant) != rval, \ + nifti_is_inttype(constant) != (rval), \ true, \ &Errors); \ } @@ -620,7 +620,7 @@ int main (int argc, const char *argv[]) nifti_datatype_sizes(constant,&nbyper,&swapsize); \ PrintTest( \ buf, \ - nbyper != Nbyper || swapsize != Swapsize, \ + nbyper != (Nbyper) || swapsize != (Swapsize), \ true, \ &Errors); \ }