Skip to content
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
8 changes: 4 additions & 4 deletions cifti/afni_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ afni_xml_list axml_read_file(const char * fname, int read_data)
{
if( reset_xml_buf(xd, &buf, &bsize) ) break;

blen = fread(buf, 1, (size_t)bsize, fp);
blen = (unsigned)fread(buf, 1, (size_t)bsize, fp);

/* check for early termination */
bshort = loc_strnlen(buf, blen);
Expand Down Expand Up @@ -285,7 +285,7 @@ afni_xml_list axml_read_buf(const char * buf_in, int64_t bin_len)

/* decide how much to copy and copy */
if( bin_remain >= bsize ) blen = (unsigned)bsize;
else blen = bin_remain;
else blen = (unsigned)bin_remain;

if(blen > 0 && blen <= (unsigned)bsize) {
memcpy(buf, bin_ptr, blen);
Expand Down Expand Up @@ -900,7 +900,7 @@ static char * strip_whitespace(const char * str, int slen)
/* if string is long, forget it */
if( !str || slen > 1024 ) return (char *)str;

len = strlen(str);
len = (int)strlen(str);
if( slen > 0 && slen < len ) len = slen;
if( len <= 0 ) return (char *)str;

Expand Down Expand Up @@ -994,7 +994,7 @@ static int disp_gen_text(afni_xml_control * xd, const char * header,

if( len == wlen ) {
str = "whitespace"; /* just note the whitespace */
len = strlen(str);
len = (int)strlen(str);
}

show_depth(xd, 1);
Expand Down
4 changes: 2 additions & 2 deletions cifti/afni_xml_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ int axio_num_tokens(const char * str, int64_t maxlen)
}
}

return ntok;
return (int)ntok;
}


Expand Down Expand Up @@ -165,7 +165,7 @@ int axio_show_attrs(FILE * fp, afni_xml_t * ax, int indent)
if( !ax ) return 1;

for( ind = 0, maxl = 1; ind < ax->attrs.length; ind++ ) {
slen = strlen(ax->attrs.name[ind]);
slen = (int)strlen(ax->attrs.name[ind]);
if( slen > maxl ) maxl = slen;
}

Expand Down
37 changes: 19 additions & 18 deletions fsliolib/fslio.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static int FslFileType(const char* fname)
int flen;
int retval=-1;
if (fname==NULL) return retval;
flen = strlen(fname);
flen = (int)strlen(fname);
/* debian@onerussian.com had to group conditions to avoid possible
* illegal memory read-ins */
if (flen<5) return retval; /* smallest name + extension is a.nii */
Expand Down Expand Up @@ -301,7 +301,7 @@ char *FslMakeBaseName(const char *fname)
char *basename;
int blen;
basename = nifti_makebasename(fname);
blen = strlen(basename);
blen = (int)strlen(basename);
#ifdef HAVE_ZLIB
if ((blen>7) && (strcmp(basename + blen-7,".mnc.gz") == 0))
{ basename[blen-7]='\0'; return basename; }
Expand Down Expand Up @@ -841,13 +841,13 @@ void* FslReadAllVolumes(FSLIO* fslio, char* filename)
*/
size_t FslReadVolumes(FSLIO *fslio, void *buffer, size_t nvols)
{
int volbytes;
size_t volbytes;
size_t retval=0;
if (fslio==NULL) FSLIOERR("FslReadVolumes: Null pointer passed for FSLIO");
if (znz_isnull(fslio->fileptr)) FSLIOERR("FslReadVolumes: Null file pointer");
if (fslio->niftiptr!=NULL) {
fslio->niftiptr->data = buffer;
volbytes = FslGetVolSize(fslio) * fslio->niftiptr->nbyper;
volbytes = FslGetVolSize(fslio) * (size_t)fslio->niftiptr->nbyper;
retval = nifti_read_buffer(fslio->fileptr,fslio->niftiptr->data,nvols*volbytes,fslio->niftiptr);
retval /= volbytes;
}
Expand Down Expand Up @@ -1167,13 +1167,14 @@ size_t FslReadTimeSeries(FSLIO *fslio, void *buffer, short xVox, short yVox, sho

int FslSeekVolume(FSLIO *fslio, size_t vols)
{
int offset;
znz_off_t offset;
if (fslio==NULL) FSLIOERR("FslSeekVolume: Null pointer passed for FSLIO");
if (fslio->niftiptr!=NULL) {
offset = fslio->niftiptr->iname_offset +
vols * FslGetVolSize(fslio) * fslio->niftiptr->nbyper;
offset = (znz_off_t)fslio->niftiptr->iname_offset
+ (znz_off_t)vols * (znz_off_t)FslGetVolSize(fslio) * fslio->niftiptr->nbyper;
if (znz_isnull(fslio->fileptr)) FSLIOERR("FslSeekVolume: Null file pointer");
return znzseek(fslio->fileptr,offset,SEEK_SET);
/* The int return cannot represent an offset beyond 2GB. */
return (int)znzseek(fslio->fileptr,offset,SEEK_SET);
}
if (fslio->mincptr!=NULL) {
fprintf(stderr,"Warning:: Minc is not yet supported\n");
Expand Down Expand Up @@ -1257,8 +1258,8 @@ void FslSetDimensionality(FSLIO *fslio, size_t dim)
{
if (fslio==NULL) FSLIOERR("FslSetDimensionality: Null pointer passed for FSLIO");
if (fslio->niftiptr!=NULL) {
fslio->niftiptr->ndim = dim;
fslio->niftiptr->dim[0] = dim;
fslio->niftiptr->ndim = (int)dim;
fslio->niftiptr->dim[0] = (int)dim;
}
if (fslio->mincptr!=NULL) {
fprintf(stderr,"Warning:: Minc is not yet supported\n");
Expand Down Expand Up @@ -2044,7 +2045,7 @@ int FslReadRawHeader(void *buffer, const char* filename)
fprintf(stderr,"Could not open header %s\n",filename);
return 0;
}
retval = znzread(buffer,1,348,fp);
retval = (int)znzread(buffer,1,348,fp);
znzclose(fp);
if (retval != 348) {
fprintf(stderr,"Could not read header %s\n",filename);
Expand Down Expand Up @@ -2148,9 +2149,9 @@ double ***FslGetVolumeAsScaledDouble(FSLIO *fslio, int vol)
if ((fslio->niftiptr->dim[0] < 3) || (fslio->niftiptr->dim[0] > 4))
FSLIOERR("FslGetVolumeAsScaledDouble: Incorrect dataset dimension, 3D-4D needed");

xx = (fslio->niftiptr->nx == 0 ? 1 : (long)fslio->niftiptr->nx);
yy = (fslio->niftiptr->ny == 0 ? 1 : (long)fslio->niftiptr->ny);
zz = (fslio->niftiptr->nz == 0 ? 1 : (long)fslio->niftiptr->nz);
xx = (fslio->niftiptr->nx == 0 ? 1 : fslio->niftiptr->nx);
yy = (fslio->niftiptr->ny == 0 ? 1 : fslio->niftiptr->ny);
zz = (fslio->niftiptr->nz == 0 ? 1 : fslio->niftiptr->nz);

if (fslio->niftiptr->scl_slope == 0) {
slope = 1.0;
Expand Down Expand Up @@ -2232,10 +2233,10 @@ double ****FslGetBufferAsScaledDouble(FSLIO *fslio)
if ((fslio->niftiptr->dim[0] <= 0) || (fslio->niftiptr->dim[0] > 4))
FSLIOERR("FslGetBufferAsScaledDouble: Incorrect dataset dimension, 1-4D needed");

xx = (fslio->niftiptr->nx == 0 ? 1 : (long)fslio->niftiptr->nx);
yy = (fslio->niftiptr->ny == 0 ? 1 : (long)fslio->niftiptr->ny);
zz = (fslio->niftiptr->nz == 0 ? 1 : (long)fslio->niftiptr->nz);
tt = (fslio->niftiptr->nt == 0 ? 1 : (long)fslio->niftiptr->nt);
xx = (fslio->niftiptr->nx == 0 ? 1 : fslio->niftiptr->nx);
yy = (fslio->niftiptr->ny == 0 ? 1 : fslio->niftiptr->ny);
zz = (fslio->niftiptr->nz == 0 ? 1 : fslio->niftiptr->nz);
tt = (fslio->niftiptr->nt == 0 ? 1 : fslio->niftiptr->nt);

if (fslio->niftiptr->scl_slope == 0) {
slope = 1.0;
Expand Down
25 changes: 13 additions & 12 deletions nifti2/nifti2_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ int nifti_fileexists(const char* fname);
/* prototypes for internal functions - not part of exported library */

/* extension routines */
static int nifti_read_extensions(nifti_image *nim, znzFile fp, int64_t remain);
static int nifti_read_next_extension( nifti1_extension * nex, nifti_image *nim, int remain, znzFile fp );
static int nifti_check_extension(nifti_image *nim, int size,int code, int rem);
static int64_t nifti_read_extensions(nifti_image *nim, znzFile fp, int64_t remain);
static int nifti_read_next_extension( nifti1_extension * nex, nifti_image *nim, int64_t remain, znzFile fp );
static int nifti_check_extension(nifti_image *nim, int size,int code, int64_t rem);
static void update_nifti_image_for_brick_list(nifti_image * nim,
int64_t nbricks);
static int nifti_add_exten_to_list(nifti1_extension * new_ext,
Expand All @@ -503,7 +503,7 @@ static int nifti_NBL_matches_nim(const nifti_image *nim,
static int rci_read_data(nifti_image *nim, int64_t *pivots, int64_t *prods,
int nprods, const int64_t dims[], char *data,
znzFile fp, int64_t base_offset);
static int rci_alloc_mem(void **data, const int64_t prods[8], int nprods, int nbyper);
static int64_t rci_alloc_mem(void **data, const int64_t prods[8], int nprods, int nbyper);
static int make_pivot_list(nifti_image * nim, const int64_t dims[8],
int64_t pivots[8], int64_t prods[8], int * nprods );

Expand Down Expand Up @@ -886,7 +886,8 @@ int nifti_image_load_bricks( nifti_image * nim , int64_t nbricks,

znzclose(fp);

return NBL->nbricks;
/* the count came from the caller, who passed it as this many bricks */
return (int)NBL->nbricks;
}


Expand Down Expand Up @@ -5983,7 +5984,7 @@ nifti_image *nifti_image_read( const char *hname , int read_data )
return NULL;
}
else if ( rv == 1 ) { /* process special file type */
nim = nifti_read_ascii_image( fp, hfile, filesize, read_data );
nim = nifti_read_ascii_image( fp, hfile, (int)filesize, read_data );
znzclose(fp);
free(hfile);
return nim;
Expand Down Expand Up @@ -6251,7 +6252,7 @@ nifti_image * nifti_read_ascii_image(znzFile fp, const char *fname, int flen,
*
* return the number of extensions read in, or < 0 on error
*----------------------------------------------------------------------*/
static int nifti_read_extensions( nifti_image *nim, znzFile fp, int64_t remain )
static int64_t nifti_read_extensions( nifti_image *nim, znzFile fp, int64_t remain )
{
nifti1_extender extdr; /* defines extension existence */
nifti1_extension extn; /* single extension to process */
Expand Down Expand Up @@ -6479,7 +6480,7 @@ static int nifti_fill_extension( nifti1_extension *ext, const char * data,
* error : -1
*----------------------------------------------------------------------*/
static int nifti_read_next_extension( nifti1_extension * nex, nifti_image *nim,
int remain, znzFile fp )
int64_t remain, znzFile fp )
{
int swap = nim->byteorder != nifti_short_order();
int count, size, code = -1;
Expand All @@ -6490,7 +6491,7 @@ static int nifti_read_next_extension( nifti1_extension * nex, nifti_image *nim,

if( remain < 16 ){
if( g_opts.debug > 2 )
fprintf(stderr,"-d only %d bytes remain, so no extension\n", remain);
fprintf(stderr,"-d only %" PRId64 " bytes remain, so no extension\n", remain);
return 0;
}

Expand Down Expand Up @@ -6696,7 +6697,7 @@ int nifti_is_valid_ecode( int ecode )
/*----------------------------------------------------------------------
* check for valid size and code, as well as can be done
*----------------------------------------------------------------------*/
static int nifti_check_extension(nifti_image *nim, int size, int code, int rem)
static int nifti_check_extension(nifti_image *nim, int size, int code, int64_t rem)
{
/* check for bad code before bad size */
if( ! nifti_is_valid_ecode(code) ) {
Expand All @@ -6713,7 +6714,7 @@ static int nifti_check_extension(nifti_image *nim, int size, int code, int rem)

if( size > rem ){
if( g_opts.debug > 2 )
fprintf(stderr,"-d ext size %d, space %d, no extension\n", size, rem);
fprintf(stderr,"-d ext size %d, space %" PRId64 ", no extension\n", size, rem);
return 0;
}

Expand Down Expand Up @@ -9525,7 +9526,7 @@ static int rci_read_data(nifti_image * nim, int64_t * pivots, int64_t * prods,

return total size on success, and < 0 on failure
*/
static int rci_alloc_mem(void **data, const int64_t prods[8], int nprods, int nbyper )
static int64_t rci_alloc_mem(void **data, const int64_t prods[8], int nprods, int nbyper )
{
int64_t size;
int memindex;
Expand Down
8 changes: 4 additions & 4 deletions nifti2/nifti_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -6771,7 +6771,7 @@ int act_disp_ci( nt_opts * opts )
}

/* should we change disp_raw_data to allow for 64-bit nvalues? */
disp_raw_data(data, nim->datatype, len64 / nim->nbyper, space, 1);
disp_raw_data(data, nim->datatype, (int)(len64 / nim->nbyper), space, 1);

nifti_image_free(nim);
}
Expand Down Expand Up @@ -7575,7 +7575,7 @@ void * nt_read_header(const char * fname, int * nver, int * swapped, int check,
*
* the returned object is a (max 4-D) nifti_image
*----------------------------------------------------------------------*/
nifti_image * nt_read_bricks(nt_opts * opts, char * fname, int len,
nifti_image * nt_read_bricks(nt_opts * opts, char * fname, int64_t len,
int64_t * list, nifti_brick_list * NBL)
{
nifti_image * nim;
Expand Down Expand Up @@ -7621,8 +7621,8 @@ nifti_image * nt_read_bricks(nt_opts * opts, char * fname, int len,
disp_raw_data(opts->new_dim, DT_INT64, 8, ' ', 1);
printf(" new_datatype = %d\n", opts->new_datatype);
if( list && len > 0 ) {
printf(" brick_list[%d] = ", len);
disp_raw_data(list, DT_INT64, len, ' ', 1);
printf(" brick_list[%" PRId64 "] = ", len);
disp_raw_data(list, DT_INT64, (int)len, ' ', 1);
}
fflush(stdout); /* disp_raw_data uses stdout */
}
Expand Down
2 changes: 1 addition & 1 deletion nifti2/nifti_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ NI2_API int write_hdr2_to_file(nifti_2_header * nhdr, const char * fname);
/* wrappers for nifti reading functions (allow MAKE_IM) */
NI2_API nifti_image * nt_image_read (nt_opts * opts, const char * fname,
int read_data, int make_ver);
NI2_API nifti_image * nt_read_bricks(nt_opts * opts, char * fname, int len,
NI2_API nifti_image * nt_read_bricks(nt_opts * opts, char * fname, int64_t len,
int64_t * list, nifti_brick_list * NBL);
NI2_API void * nt_read_header(const char * fname, int * nver, int * swapped, int check,
int new_datatype, int64_t new_dim[8]);
Expand Down
8 changes: 6 additions & 2 deletions niftilib/nifti1_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -7096,7 +7096,9 @@ int nifti_read_collapsed_image( nifti_image * nim, const int dims [8],
fprintf(stderr,"+d read %d bytes of collapsed image from %s\n",
bytes, nim->fname);

return bytes;
/* nifti_read_subregion_image() is declared to return int; a subregion
larger than 2GB cannot be requested through its int region_size. */
return (int)bytes;
}


Expand Down Expand Up @@ -7320,7 +7322,9 @@ int nifti_read_subregion_image( nifti_image * nim,
}
}
znzclose(fp);
return bytes;
/* nifti_read_subregion_image() is declared to return int; a subregion
larger than 2GB cannot be requested through its int region_size. */
return (int)bytes;
}


Expand Down
Loading