Skip to content
Open
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
10 changes: 5 additions & 5 deletions fsliolib/fslio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");


Expand Down
4 changes: 2 additions & 2 deletions nifti2/nifti2_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}

Expand Down Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions nifti2/nifti_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -142,7 +142,7 @@ typedef struct {
dtype * pd = dptr; \
stype * ps = sptr; \
int64_t index; \
for(index=0; index<nvals; index++) { \
for(index=0; index<(nvals); index++) { \
*pd = (dtype)*ps; \
pd++; ps++; \
} } while(0)
Expand All @@ -158,7 +158,7 @@ typedef struct {
int64_t index; \
/* init bounds with first */ \
failure = 0; \
for(index=0; index<nvals; index++) { \
for(index=0; index<(nvals); index++) { \
*pd = (dtype)*ps; \
/* fail when we cannot invert */ \
if( !failure && *ps != (stype)*pd ) \
Expand Down
4 changes: 2 additions & 2 deletions niftilib/nifti1_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -4673,7 +4673,7 @@ static int nifti_read_next_extension( nifti1_extension * nex, nifti_image *nim,
if( count != 2 ){
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 */
}

Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions niftilib/nifti1_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions niftilib/nifti_tester001.c
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
}
Expand Down Expand Up @@ -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); \
}
Expand Down