Skip to content

Commit

Permalink
Fixed remaining -Wcast-qual warnings, made public API return const st…
Browse files Browse the repository at this point in the history
…ring

This is a small change to public API, but not likely to affect users, not likely to even require any code change by them.
  • Loading branch information
seanm committed Jan 18, 2025
1 parent 8f72d11 commit 375470c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions nifti2/nifti2_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3501,13 +3501,13 @@ int nifti_validfilename(const char* fname)
\return a pointer to the extension substring within the original
function input parameter name, or NULL if not found.
\warning Note that if the input parameter is is immutabale
\warning Note that if the input parameter is immutabale
(i.e. a const char *) then this function performs an
implicit casting away of the mutability constraint and
the return parameter will appear as a mutable
even though it is part of the immuttable string.
*//*--------------------------------------------------------------------*/
char * nifti_find_file_extension( const char * name )
const char * nifti_find_file_extension( const char * name )
{
const char * ext;
char extcopy[8];
Expand Down Expand Up @@ -3540,7 +3540,7 @@ char * nifti_find_file_extension( const char * name )
ext);
return NULL;
}
else return (char *)ext; /* Cast away the constness of the input parameter */
else return ext;
}

#ifdef HAVE_ZLIB
Expand All @@ -3561,7 +3561,7 @@ char * nifti_find_file_extension( const char * name )
ext);
return NULL;
}
else return (char *)ext; /* Cast away the constness of the input parameter */
else return ext;
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion nifti2/nifti2_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ NI2_API char * nifti_makehdrname (const char * prefix, int nifti_type, int chec
NI2_API char * nifti_makeimgname (const char * prefix, int nifti_type, int check,
int comp);
NI2_API int is_nifti_file (const char *hname);
NI2_API char * nifti_find_file_extension(const char * name);
NI2_API const char * nifti_find_file_extension(const char * name);
NI2_API int nifti_is_complete_filename(const char* fname);
NI2_API int nifti_validfilename(const char* fname);

Expand Down
4 changes: 2 additions & 2 deletions nifti2/nifti_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -6355,7 +6355,7 @@ int diff_field(field_s *fieldp, void * str0, void * str1, int nfields)
/*----------------------------------------------------------------------
* display a single extension
*----------------------------------------------------------------------*/
int disp_cifti_extension( const char *mesg, nifti1_extension * ext, int maxlen)
int disp_cifti_extension( const char *mesg, const nifti1_extension * ext, int maxlen)
{
FILE * outfp = stdout;
int len;
Expand Down Expand Up @@ -6391,7 +6391,7 @@ int disp_cifti_extension( const char *mesg, nifti1_extension * ext, int maxlen)
/*----------------------------------------------------------------------
* display a single extension
*----------------------------------------------------------------------*/
int disp_nifti1_extension( const char *mesg, nifti1_extension * ext, int maxlen)
int disp_nifti1_extension( const char *mesg, const nifti1_extension * ext, int maxlen)
{
FILE * outfp = stdout;
int len;
Expand Down
4 changes: 2 additions & 2 deletions nifti2/nifti_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ NI2_API int add_string (str_list * slist, const char * str);
NI2_API int check_total_size ( const char *mesg, field_s *fields, int nfields, int tot_size);
NI2_API int clear_float_zeros( char * str );
NI2_API int diff_field (field_s *fieldp, void * str0, void * str1, int nfields);
NI2_API int disp_cifti_extension ( const char *mesg, nifti1_extension * ext, int maxlen);
NI2_API int disp_nifti1_extension( const char *mesg, nifti1_extension * ext, int maxlen);
NI2_API int disp_cifti_extension ( const char *mesg, const nifti1_extension * ext, int maxlen);
NI2_API int disp_nifti1_extension( const char *mesg, const nifti1_extension * ext, int maxlen);
NI2_API int disp_field (const char *mesg,field_s *fieldp,void *str,int nfields,int header);
NI2_API int disp_field_s_list(const char * mesg, field_s *, int nfields);
NI2_API int disp_nt_opts ( const char *mesg, nt_opts * opts);
Expand Down
6 changes: 3 additions & 3 deletions niftilib/nifti1_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2593,7 +2593,7 @@ int nifti_validfilename(const char* fname)
the return parameter will appear as a mutable
even though it is part of the immuttable string.
*//*--------------------------------------------------------------------*/
char * nifti_find_file_extension( const char * name )
const char * nifti_find_file_extension( const char * name )
{
const char * ext;
char extcopy[8];
Expand Down Expand Up @@ -2625,7 +2625,7 @@ char * nifti_find_file_extension( const char * name )
fprintf(stderr,"** mixed case extension '%s' is not valid\n", ext);
return NULL;
}
else return (char *)ext; /* Cast away the constness of the input parameter */
else return ext;
}

#ifdef HAVE_ZLIB
Expand All @@ -2645,7 +2645,7 @@ char * nifti_find_file_extension( const char * name )
fprintf(stderr,"** mixed case extension '%s' is not valid\n", ext);
return NULL;
}
else return (char *)ext; /* Cast away the constness of the input parameter */
else return ext;
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion niftilib/nifti1_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ NIO_API char * nifti_makehdrname ( const char * prefix, int nifti_type, int che
NIO_API char * nifti_makeimgname ( const char * prefix, int nifti_type, int check,
int comp);
NIO_API int is_nifti_file ( const char *hname);
NIO_API char * nifti_find_file_extension( const char * name);
NIO_API const char * nifti_find_file_extension( const char * name);
NIO_API int nifti_is_complete_filename( const char* fname);
NIO_API int nifti_validfilename( const char* fname);

Expand Down
2 changes: 1 addition & 1 deletion niftilib/nifti1_tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -3571,7 +3571,7 @@ int diff_field(field_s *fieldp, void * str0, void * str1, int nfields)
/*----------------------------------------------------------------------
* display a single extension
*----------------------------------------------------------------------*/
int disp_nifti1_extension( const char *mesg, nifti1_extension * ext, int maxlen)
int disp_nifti1_extension( const char *mesg, const nifti1_extension * ext, int maxlen)
{
int len;
if( mesg ) fputs(mesg, stdout);
Expand Down
2 changes: 1 addition & 1 deletion niftilib/nifti1_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ int add_string (str_list * slist, const char * str);
int check_total_size ( const char *mesg, field_s *fields, int nfields, int tot_size);
int clear_float_zeros( char * str );
int diff_field (field_s *fieldp, void * str0, void * str1, int nfields);
int disp_nifti1_extension( const char *mesg, nifti1_extension * ext, int maxlen);
int disp_nifti1_extension( const char *mesg, const nifti1_extension * ext, int maxlen);
int disp_field ( const char *mesg,field_s *fieldp,void *str,int nfields,int header);
int disp_field_s_list( const char *mesg, field_s *, int nfields);
int disp_nt_opts ( const char *mesg, nt_opts * opts);
Expand Down

0 comments on commit 375470c

Please sign in to comment.