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
10 changes: 5 additions & 5 deletions cifti/afni_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static int show_attrs (afni_xml_control *, const char **, int);

static int64_t loc_strnlen (const char * str, int64_t maxlen);
static afni_xml_t * make_afni_xml (const char * ename, const char ** attr);
static char * strip_whitespace(const char * str, int slen);
static const char * strip_whitespace(const char * str, int slen);

/*----------------------- main I/O functions ---------------------------*/

Expand Down Expand Up @@ -888,7 +888,7 @@ static int show_attrs(afni_xml_control * xd, const char ** attr, int showd)
static void free_whitespace(void) { strip_whitespace(NULL,-2); }

/* if slen == 0, use entire length */
static char * strip_whitespace(const char * str, int slen)
static const char * strip_whitespace(const char * str, int slen)
{
static char * buf = NULL;
static int blen = 0;
Expand All @@ -898,18 +898,18 @@ static char * strip_whitespace(const char * str, int slen)
if(!str && slen == -2){ free(buf); buf=NULL; blen=0; return 0; }

/* if string is long, forget it */
if( !str || slen > 1024 ) return (char *)str;
if( !str || slen > 1024 ) return str;

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

/* make sure we have local space */
if( len > blen ) { /* allocate a bigger buffer */
buf = (char *)safe_realloc(buf, (len+1) * sizeof(char));
if( !buf ) {
fprintf(stderr,"** failed to alloc wspace buf of len %d\n", len+1);
return (char *)str;
return str;
}
blen = len;
}
Expand Down
14 changes: 8 additions & 6 deletions cifti/afni_xml_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int axio_text_to_binary(afni_xml_t * ax)

int axio_num_tokens(const char * str, int64_t maxlen)
{
char * sp = (char *)str;
const char * sp = str;
int64_t ind, len, ntok;
int intok; /* flag: are we inside a token? */

Expand All @@ -123,7 +123,7 @@ int axio_num_tokens(const char * str, int64_t maxlen)

ntok = 0;
intok = 0;
for( ind = 0, sp = (char *)str; ind < len; ind++, sp++ ) {
for( ind = 0, sp = str; ind < len; ind++, sp++ ) {
/* just look for state switches */
if( intok ) {
if( isspace(*sp) || (*sp == ',') )
Expand Down Expand Up @@ -519,15 +519,16 @@ static int can_process_dtype(int dtype)
* varies, unfortunately */
static int64_t text_to_i64(int64_t * result, const char * text, int64_t nvals)
{
char * eptr, * sptr;
char * eptr;
const char * sptr;
int64_t * rptr, val;
int64_t nread;

assert(result && text);
*result = 0; /* Initialize to zero in case of failure */
if( nvals <= 0 ) return 0;

sptr = (char *)text;
sptr = text;

nread = 0;
rptr = result;
Expand All @@ -548,14 +549,15 @@ static int64_t text_to_i64(int64_t * result, const char * text, int64_t nvals)

static int64_t text_to_f64(double * result, const char * text, int64_t nvals)
{
char * eptr, * sptr;
char * eptr;
const char * sptr;
double * rptr, val;
int64_t nread;

if( ! text || ! result) return 1;
if( nvals <= 0 ) return 0;

sptr = (char *)text;
sptr = text;

nread = 0;
rptr = result;
Expand Down
9 changes: 4 additions & 5 deletions fsliolib/fslio.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ int FslBaseFileType(int filetype)

static int FslGetFileType2(const FSLIO *fslio, int quiet)
{
FSLIO *mutablefslio;
if (fslio==NULL) FSLIOERR("FslGetFileType: Null pointer passed for FSLIO");
if ( (fslio->file_mode==FSL_TYPE_MINC) || (fslio->file_mode==FSL_TYPE_MINC_GZ) ) {
return fslio->file_mode;
Expand All @@ -112,8 +111,7 @@ static int FslGetFileType2(const FSLIO *fslio, int quiet)
fprintf(stderr,"Warning: nifti structure and fsl structure disagree on file type\n");
fprintf(stderr,"nifti = %d and fslio = %d\n",fslio->niftiptr->nifti_type,fslio->file_mode);
}
mutablefslio = (FSLIO *) fslio; /* dodgy and will generate warnings */
mutablefslio->niftiptr->nifti_type = FslBaseFileType(fslio->file_mode);
fslio->niftiptr->nifti_type = FslBaseFileType(fslio->file_mode);
return fslio->file_mode;
}
}
Expand Down Expand Up @@ -926,10 +924,11 @@ size_t FslWriteVolumes(FSLIO *fslio, const void *buffer, size_t nvols)
&& (FslGetLeftRightOrder(fslio)==FSL_NEUROLOGICAL) ) {
/* If it is Analyze and Neurological order then SWAP DATA into Radiological order */
/* This is nasty - but what else can be done?!? */
char *tmpbuf, *inbuf;
char *tmpbuf;
const char *inbuf;
long int x, b, n, nrows;
short nx, ny, nz, nv;
inbuf = (char *) buffer;
inbuf = buffer;
tmpbuf = (char *)calloc(nbytes,1);
FslGetDim(fslio,&nx,&ny,&nz,&nv);
nrows = nbytes / (nx * bpv);
Expand Down
Loading