@@ -546,7 +546,7 @@ nifti_image *nifti_image_read_bricks(const char * hname, int nbricks,
546
546
547
547
if ( !hname || !NBL ){
548
548
fprintf (stderr ,"** nifti_image_read_bricks: bad params (%p,%p)\n" ,
549
- hname , (void * )NBL );
549
+ ( const void * ) hname , (void * )NBL );
550
550
return NULL ;
551
551
}
552
552
@@ -1415,8 +1415,6 @@ char const *nifti_orientation_string( int ii )
1415
1415
\param nbyper pointer to return value: number of bytes per voxel
1416
1416
\param swapsize pointer to return value: size of swap blocks
1417
1417
1418
- \return appropriate values at nbyper and swapsize
1419
-
1420
1418
The swapsize is set to 0 if this datatype doesn't ever need swapping.
1421
1419
1422
1420
\sa NIFTI1_DATATYPES in nifti1.h
@@ -2142,7 +2140,7 @@ void nifti_mat44_to_orientation( mat44 R , int *icod, int *jcod, int *kcod )
2142
2140
*
2143
2141
* Due to alignment of structures at some architectures (e.g. on ARM),
2144
2142
* stick to char variables.
2145
- * Fixes http://bugs.debian.org/446893 Yaroslav <debian@ onerussian.com>
2143
+ * Fixes < http://bugs.debian.org/446893> Yaroslav <debian @ onerussian.com>
2146
2144
*
2147
2145
*/ /*--------------------------------------------------------------------*/
2148
2146
void nifti_swap_2bytes ( size_t n , void * ar ) /* 2 bytes at a time */
@@ -2581,7 +2579,7 @@ int nifti_validfilename(const char* fname)
2581
2579
2582
2580
\return a pointer to the extension substring within the original
2583
2581
function input parameter name, or NULL if not found.
2584
- \caution Note that if the input parameter is is immutabale
2582
+ \warning Note that if the input parameter is is immutabale
2585
2583
(i.e. a const char *) then this function performs an
2586
2584
implicit casting away of the mutability constraint and
2587
2585
the return parameter will appear as a mutable
@@ -2831,8 +2829,8 @@ char * nifti_findhdrname(const char* fname)
2831
2829
/*! check current directory for existing image file
2832
2830
2833
2831
\param fname filename to check for
2834
- \nifti_type nifti_type for dataset - this determines whether to
2835
- first check for ".nii" or ".img" (since both may exist)
2832
+ \param nifti_type nifti_type for dataset - this determines whether to
2833
+ first check for ".nii" or ".img" (since both may exist)
2836
2834
2837
2835
\return filename of data/img file on success and NULL if no appropriate
2838
2836
file could be found
@@ -3077,7 +3075,7 @@ int nifti_set_filenames( nifti_image * nim, const char * prefix, int check,
3077
3075
3078
3076
if ( !nim || !prefix ){
3079
3077
fprintf (stderr ,"** nifti_set_filenames, bad params %p, %p\n" ,
3080
- (void * )nim ,prefix );
3078
+ (void * )nim ,( const void * ) prefix );
3081
3079
return -1 ;
3082
3080
}
3083
3081
@@ -3403,7 +3401,7 @@ int nifti_set_type_from_names( nifti_image * nim )
3403
3401
3404
3402
if ( !nim -> fname || !nim -> iname ){
3405
3403
fprintf (stderr ,"** NSTFN: missing filename(s) fname @ %p, iname @ %p\n" ,
3406
- nim -> fname , nim -> iname );
3404
+ ( const void * ) nim -> fname , ( const void * ) nim -> iname );
3407
3405
return -1 ;
3408
3406
}
3409
3407
@@ -4489,7 +4487,7 @@ static int nifti_read_extensions( nifti_image *nim, znzFile fp, int remain )
4489
4487
4490
4488
\param nim - nifti_image to add extension to
4491
4489
\param data - raw extension data
4492
- \param length - length of raw extension data
4490
+ \param len - length of raw extension data
4493
4491
\param ecode - extension code
4494
4492
4495
4493
\sa extension codes NIFTI_ECODE_* in nifti1_io.h
@@ -4571,7 +4569,7 @@ static int nifti_fill_extension( nifti1_extension *ext, const char * data,
4571
4569
4572
4570
if ( !ext || !data || len < 0 ){
4573
4571
fprintf (stderr ,"** fill_ext: bad params (%p,%p,%d)\n" ,
4574
- (void * )ext , data , len );
4572
+ (void * )ext , ( const void * ) data , len );
4575
4573
return -1 ;
4576
4574
} else if ( ! nifti_is_valid_ecode (ecode ) ){
4577
4575
fprintf (stderr ,"** warning: writing unknown ecode %d\n" , ecode );
@@ -4819,7 +4817,7 @@ static znzFile nifti_image_load_prep( nifti_image *nim )
4819
4817
if ( g_opts .debug > 0 ){
4820
4818
if ( !nim ) fprintf (stderr ,"** ERROR: N_image_load: no nifti image\n" );
4821
4819
else fprintf (stderr ,"** ERROR: N_image_load: bad params (%p,%d,%u)\n" ,
4822
- nim -> iname , nim -> nbyper , (unsigned )nim -> nvox );
4820
+ ( const void * ) nim -> iname , nim -> nbyper , (unsigned )nim -> nvox );
4823
4821
}
4824
4822
return NULL ;
4825
4823
}
@@ -5903,8 +5901,6 @@ znzFile nifti_write_ascii_image(nifti_image *nim, const nifti_brick_list * NBL,
5903
5901
fields from the qto_xyz matrix, you can use the utility function
5904
5902
nifti_mat44_to_quatern()
5905
5903
5906
- \return 0 on success, -1 on error
5907
-
5908
5904
\sa nifti_image_write_bricks, nifti_image_free, nifti_set_filenames,
5909
5905
nifti_image_write_hdr_img
5910
5906
*/ /*------------------------------------------------------------------------*/
@@ -6193,15 +6189,16 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6193
6189
6194
6190
if ( nim == NULL ) return NULL ; /* stupid caller */
6195
6191
6196
- buf = (char * )calloc (1 ,65534 ); /* longer than needed, to be safe */
6192
+ const size_t bufLen = 65534 ; /* longer than needed, to be safe */
6193
+ buf = (char * )calloc (1 ,bufLen );
6197
6194
if ( !buf ){
6198
- fprintf (stderr ,"** NITA: failed to alloc %d bytes\n" ,65534 );
6195
+ fprintf (stderr ,"** NITA: failed to alloc %zu bytes\n" ,bufLen );
6199
6196
return NULL ;
6200
6197
}
6201
6198
6202
- sprintf ( buf , "<nifti_image\n" ) ; /* XML-ish opener */
6199
+ snprintf ( buf , bufLen , "<nifti_image\n" ) ; /* XML-ish opener */
6203
6200
6204
- sprintf ( buf + strlen (buf ) , " nifti_type = '%s'\n" ,
6201
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " nifti_type = '%s'\n" ,
6205
6202
(nim -> nifti_type == NIFTI_FTYPE_NIFTI1_1 ) ? "NIFTI-1+"
6206
6203
:(nim -> nifti_type == NIFTI_FTYPE_NIFTI1_2 ) ? "NIFTI-1"
6207
6204
:(nim -> nifti_type == NIFTI_FTYPE_ASCII ) ? "NIFTI-1A"
@@ -6215,126 +6212,126 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6215
6212
- The result is that the NIFTI ASCII-format header is XML-compliant. */
6216
6213
6217
6214
ebuf = escapize_string (nim -> fname ) ;
6218
- sprintf ( buf + strlen (buf ) , " header_filename = %s\n" ,ebuf ); free (ebuf );
6215
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " header_filename = %s\n" ,ebuf ); free (ebuf );
6219
6216
6220
6217
ebuf = escapize_string (nim -> iname ) ;
6221
- sprintf ( buf + strlen (buf ) , " image_filename = %s\n" , ebuf ); free (ebuf );
6218
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " image_filename = %s\n" , ebuf ); free (ebuf );
6222
6219
6223
- sprintf ( buf + strlen (buf ) , " image_offset = '%d'\n" , nim -> iname_offset );
6220
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " image_offset = '%d'\n" , nim -> iname_offset );
6224
6221
6225
- sprintf (buf + strlen (buf ), " ndim = '%d'\n" , nim -> ndim );
6226
- sprintf (buf + strlen (buf ), " nx = '%d'\n" , nim -> nx );
6222
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " ndim = '%d'\n" , nim -> ndim );
6223
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " nx = '%d'\n" , nim -> nx );
6227
6224
if (nim -> ndim > 1 )
6228
- sprintf (buf + strlen (buf ), " ny = '%d'\n" , nim -> ny );
6225
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " ny = '%d'\n" , nim -> ny );
6229
6226
if (nim -> ndim > 2 )
6230
- sprintf (buf + strlen (buf ), " nz = '%d'\n" , nim -> nz );
6227
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " nz = '%d'\n" , nim -> nz );
6231
6228
if (nim -> ndim > 3 )
6232
- sprintf (buf + strlen (buf ), " nt = '%d'\n" , nim -> nt );
6229
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " nt = '%d'\n" , nim -> nt );
6233
6230
if (nim -> ndim > 4 )
6234
- sprintf (buf + strlen (buf ), " nu = '%d'\n" , nim -> nu );
6231
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " nu = '%d'\n" , nim -> nu );
6235
6232
if (nim -> ndim > 5 )
6236
- sprintf (buf + strlen (buf ), " nv = '%d'\n" , nim -> nv );
6233
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " nv = '%d'\n" , nim -> nv );
6237
6234
if (nim -> ndim > 6 )
6238
- sprintf (buf + strlen (buf ), " nw = '%d'\n" , nim -> nw );
6239
- sprintf (buf + strlen (buf ), " dx = '%g'\n" , nim -> dx );
6235
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " nw = '%d'\n" , nim -> nw );
6236
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " dx = '%g'\n" , nim -> dx );
6240
6237
if (nim -> ndim > 1 )
6241
- sprintf (buf + strlen (buf ), " dy = '%g'\n" , nim -> dy );
6238
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " dy = '%g'\n" , nim -> dy );
6242
6239
if (nim -> ndim > 2 )
6243
- sprintf (buf + strlen (buf ), " dz = '%g'\n" , nim -> dz );
6240
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " dz = '%g'\n" , nim -> dz );
6244
6241
if (nim -> ndim > 3 )
6245
- sprintf (buf + strlen (buf ), " dt = '%g'\n" , nim -> dt );
6242
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " dt = '%g'\n" , nim -> dt );
6246
6243
if (nim -> ndim > 4 )
6247
- sprintf (buf + strlen (buf ), " du = '%g'\n" , nim -> du );
6244
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " du = '%g'\n" , nim -> du );
6248
6245
if (nim -> ndim > 5 )
6249
- sprintf (buf + strlen (buf ), " dv = '%g'\n" , nim -> dv );
6246
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " dv = '%g'\n" , nim -> dv );
6250
6247
if (nim -> ndim > 6 )
6251
- sprintf (buf + strlen (buf ), " dw = '%g'\n" , nim -> dw );
6248
+ snprintf (buf + strlen ( buf ), bufLen - strlen (buf ), " dw = '%g'\n" , nim -> dw );
6252
6249
6253
- sprintf ( buf + strlen (buf ) , " datatype = '%d'\n" , nim -> datatype ) ;
6254
- sprintf ( buf + strlen (buf ) , " datatype_name = '%s'\n" ,
6250
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " datatype = '%d'\n" , nim -> datatype ) ;
6251
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " datatype_name = '%s'\n" ,
6255
6252
nifti_datatype_string (nim -> datatype ) ) ;
6256
6253
6257
- sprintf ( buf + strlen (buf ) , " nvox = '%u'\n" , (unsigned )nim -> nvox ) ;
6258
- sprintf ( buf + strlen (buf ) , " nbyper = '%d'\n" , nim -> nbyper ) ;
6254
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " nvox = '%u'\n" , (unsigned )nim -> nvox ) ;
6255
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " nbyper = '%d'\n" , nim -> nbyper ) ;
6259
6256
6260
- sprintf ( buf + strlen (buf ) , " byteorder = '%s'\n" ,
6257
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " byteorder = '%s'\n" ,
6261
6258
(nim -> byteorder == MSB_FIRST ) ? "MSB_FIRST" : "LSB_FIRST" ) ;
6262
6259
6263
6260
if ( nim -> cal_min < nim -> cal_max ){
6264
- sprintf ( buf + strlen (buf ) , " cal_min = '%g'\n" , nim -> cal_min ) ;
6265
- sprintf ( buf + strlen (buf ) , " cal_max = '%g'\n" , nim -> cal_max ) ;
6261
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " cal_min = '%g'\n" , nim -> cal_min ) ;
6262
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " cal_max = '%g'\n" , nim -> cal_max ) ;
6266
6263
}
6267
6264
6268
6265
if ( nim -> scl_slope != 0.0 ){
6269
- sprintf ( buf + strlen (buf ) , " scl_slope = '%g'\n" , nim -> scl_slope ) ;
6270
- sprintf ( buf + strlen (buf ) , " scl_inter = '%g'\n" , nim -> scl_inter ) ;
6266
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " scl_slope = '%g'\n" , nim -> scl_slope ) ;
6267
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " scl_inter = '%g'\n" , nim -> scl_inter ) ;
6271
6268
}
6272
6269
6273
6270
if ( nim -> intent_code > 0 ){
6274
- sprintf ( buf + strlen (buf ) , " intent_code = '%d'\n" , nim -> intent_code ) ;
6275
- sprintf ( buf + strlen (buf ) , " intent_code_name = '%s'\n" ,
6271
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " intent_code = '%d'\n" , nim -> intent_code ) ;
6272
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " intent_code_name = '%s'\n" ,
6276
6273
nifti_intent_string (nim -> intent_code ) ) ;
6277
- sprintf ( buf + strlen (buf ) , " intent_p1 = '%g'\n" , nim -> intent_p1 ) ;
6278
- sprintf ( buf + strlen (buf ) , " intent_p2 = '%g'\n" , nim -> intent_p2 ) ;
6279
- sprintf ( buf + strlen (buf ) , " intent_p3 = '%g'\n" , nim -> intent_p3 ) ;
6274
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " intent_p1 = '%g'\n" , nim -> intent_p1 ) ;
6275
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " intent_p2 = '%g'\n" , nim -> intent_p2 ) ;
6276
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " intent_p3 = '%g'\n" , nim -> intent_p3 ) ;
6280
6277
6281
6278
if ( nim -> intent_name [0 ] != '\0' ){
6282
6279
ebuf = escapize_string (nim -> intent_name ) ;
6283
- sprintf ( buf + strlen (buf ) , " intent_name = %s\n" ,ebuf ) ;
6280
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " intent_name = %s\n" ,ebuf ) ;
6284
6281
free (ebuf ) ;
6285
6282
}
6286
6283
}
6287
6284
6288
6285
if ( nim -> toffset != 0.0 )
6289
- sprintf ( buf + strlen (buf ) , " toffset = '%g'\n" ,nim -> toffset ) ;
6286
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " toffset = '%g'\n" ,nim -> toffset ) ;
6290
6287
6291
6288
if ( nim -> xyz_units > 0 )
6292
- sprintf ( buf + strlen (buf ) ,
6289
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6293
6290
" xyz_units = '%d'\n"
6294
6291
" xyz_units_name = '%s'\n" ,
6295
6292
nim -> xyz_units , nifti_units_string (nim -> xyz_units ) ) ;
6296
6293
6297
6294
if ( nim -> time_units > 0 )
6298
- sprintf ( buf + strlen (buf ) ,
6295
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6299
6296
" time_units = '%d'\n"
6300
6297
" time_units_name = '%s'\n" ,
6301
6298
nim -> time_units , nifti_units_string (nim -> time_units ) ) ;
6302
6299
6303
6300
if ( nim -> freq_dim > 0 )
6304
- sprintf ( buf + strlen (buf ) , " freq_dim = '%d'\n" ,nim -> freq_dim ) ;
6301
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " freq_dim = '%d'\n" ,nim -> freq_dim ) ;
6305
6302
if ( nim -> phase_dim > 0 )
6306
- sprintf ( buf + strlen (buf ) , " phase_dim = '%d'\n" ,nim -> phase_dim ) ;
6303
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " phase_dim = '%d'\n" ,nim -> phase_dim ) ;
6307
6304
if ( nim -> slice_dim > 0 )
6308
- sprintf ( buf + strlen (buf ) , " slice_dim = '%d'\n" ,nim -> slice_dim ) ;
6305
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " slice_dim = '%d'\n" ,nim -> slice_dim ) ;
6309
6306
if ( nim -> slice_code > 0 )
6310
- sprintf ( buf + strlen (buf ) ,
6307
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6311
6308
" slice_code = '%d'\n"
6312
6309
" slice_code_name = '%s'\n" ,
6313
6310
nim -> slice_code , nifti_slice_string (nim -> slice_code ) ) ;
6314
6311
if ( nim -> slice_start >= 0 && nim -> slice_end > nim -> slice_start )
6315
- sprintf ( buf + strlen (buf ) ,
6312
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6316
6313
" slice_start = '%d'\n"
6317
6314
" slice_end = '%d'\n" , nim -> slice_start , nim -> slice_end ) ;
6318
6315
if ( nim -> slice_duration != 0.0 )
6319
- sprintf ( buf + strlen (buf ) , " slice_duration = '%g'\n" ,
6316
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " slice_duration = '%g'\n" ,
6320
6317
nim -> slice_duration ) ;
6321
6318
6322
6319
if ( nim -> descrip [0 ] != '\0' ){
6323
6320
ebuf = escapize_string (nim -> descrip ) ;
6324
- sprintf ( buf + strlen (buf ) , " descrip = %s\n" ,ebuf ) ;
6321
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " descrip = %s\n" ,ebuf ) ;
6325
6322
free (ebuf ) ;
6326
6323
}
6327
6324
6328
6325
if ( nim -> aux_file [0 ] != '\0' ){
6329
6326
ebuf = escapize_string (nim -> aux_file ) ;
6330
- sprintf ( buf + strlen (buf ) , " aux_file = %s\n" ,ebuf ) ;
6327
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " aux_file = %s\n" ,ebuf ) ;
6331
6328
free (ebuf ) ;
6332
6329
}
6333
6330
6334
6331
if ( nim -> qform_code > 0 ){
6335
6332
int i ,j ,k ;
6336
6333
6337
- sprintf ( buf + strlen (buf ) ,
6334
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6338
6335
" qform_code = '%d'\n"
6339
6336
" qform_code_name = '%s'\n"
6340
6337
" qto_xyz_matrix = '%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g'\n" ,
@@ -6348,7 +6345,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6348
6345
nim -> qto_xyz .m [3 ][0 ] , nim -> qto_xyz .m [3 ][1 ] ,
6349
6346
nim -> qto_xyz .m [3 ][2 ] , nim -> qto_xyz .m [3 ][3 ] ) ;
6350
6347
6351
- sprintf ( buf + strlen (buf ) ,
6348
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6352
6349
" qto_ijk_matrix = '%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g'\n" ,
6353
6350
nim -> qto_ijk .m [0 ][0 ] , nim -> qto_ijk .m [0 ][1 ] ,
6354
6351
nim -> qto_ijk .m [0 ][2 ] , nim -> qto_ijk .m [0 ][3 ] ,
@@ -6359,7 +6356,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6359
6356
nim -> qto_ijk .m [3 ][0 ] , nim -> qto_ijk .m [3 ][1 ] ,
6360
6357
nim -> qto_ijk .m [3 ][2 ] , nim -> qto_ijk .m [3 ][3 ] ) ;
6361
6358
6362
- sprintf ( buf + strlen (buf ) ,
6359
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6363
6360
" quatern_b = '%g'\n"
6364
6361
" quatern_c = '%g'\n"
6365
6362
" quatern_d = '%g'\n"
@@ -6372,7 +6369,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6372
6369
6373
6370
nifti_mat44_to_orientation ( nim -> qto_xyz , & i ,& j ,& k ) ;
6374
6371
if ( i > 0 && j > 0 && k > 0 )
6375
- sprintf ( buf + strlen (buf ) ,
6372
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6376
6373
" qform_i_orientation = '%s'\n"
6377
6374
" qform_j_orientation = '%s'\n"
6378
6375
" qform_k_orientation = '%s'\n" ,
@@ -6384,7 +6381,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6384
6381
if ( nim -> sform_code > 0 ){
6385
6382
int i ,j ,k ;
6386
6383
6387
- sprintf ( buf + strlen (buf ) ,
6384
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6388
6385
" sform_code = '%d'\n"
6389
6386
" sform_code_name = '%s'\n"
6390
6387
" sto_xyz_matrix = '%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g'\n" ,
@@ -6398,7 +6395,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6398
6395
nim -> sto_xyz .m [3 ][0 ] , nim -> sto_xyz .m [3 ][1 ] ,
6399
6396
nim -> sto_xyz .m [3 ][2 ] , nim -> sto_xyz .m [3 ][3 ] ) ;
6400
6397
6401
- sprintf ( buf + strlen (buf ) ,
6398
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6402
6399
" sto_ijk matrix = '%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g'\n" ,
6403
6400
nim -> sto_ijk .m [0 ][0 ] , nim -> sto_ijk .m [0 ][1 ] ,
6404
6401
nim -> sto_ijk .m [0 ][2 ] , nim -> sto_ijk .m [0 ][3 ] ,
@@ -6411,7 +6408,7 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6411
6408
6412
6409
nifti_mat44_to_orientation ( nim -> sto_xyz , & i ,& j ,& k ) ;
6413
6410
if ( i > 0 && j > 0 && k > 0 )
6414
- sprintf ( buf + strlen (buf ) ,
6411
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) ,
6415
6412
" sform_i_orientation = '%s'\n"
6416
6413
" sform_j_orientation = '%s'\n"
6417
6414
" sform_k_orientation = '%s'\n" ,
@@ -6420,9 +6417,9 @@ char *nifti_image_to_ascii( const nifti_image *nim )
6420
6417
nifti_orientation_string (k ) ) ;
6421
6418
}
6422
6419
6423
- sprintf ( buf + strlen (buf ) , " num_ext = '%d'\n" , nim -> num_ext ) ;
6420
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , " num_ext = '%d'\n" , nim -> num_ext ) ;
6424
6421
6425
- sprintf ( buf + strlen (buf ) , "/>\n" ) ; /* XML-ish closer */
6422
+ snprintf ( buf + strlen ( buf ) , bufLen - strlen (buf ) , "/>\n" ) ; /* XML-ish closer */
6426
6423
6427
6424
nbuf = (int )strlen (buf ) ;
6428
6425
buf = (char * )realloc ((void * )buf , nbuf + 1 ); /* cut back to proper length */
@@ -6457,7 +6454,7 @@ int nifti_short_order(void) /* determine this CPU's byte order */
6457
6454
/* macro to check lhs string against "n1"; if it matches,
6458
6455
interpret rhs string as a number, and put it into nim->"n2" */
6459
6456
6460
- #define QQNUM (n1 ,n2 ,tt ) if( strcmp(lhs,#n1)==0 ) nim->n2=(tt)strtod(rhs,NULL)
6457
+ #define QQNUM (n1 ,n2 ,tt ) if( strcmp(lhs,#n1)==0 ) nim->n2=(tt)( strtod(rhs,NULL) )
6461
6458
6462
6459
/* same, but where "n1" == "n2" */
6463
6460
@@ -6959,7 +6956,7 @@ compute_strides(int *strides,const int *size,int nbyper)
6959
6956
speed and possibly repeated calls to this function.
6960
6957
\return
6961
6958
- the total number of bytes read, or < 0 on failure
6962
- - the read and byte-swapped data, in 'data' </pre>
6959
+ - the read and byte-swapped data, in 'data'
6963
6960
6964
6961
\sa nifti_image_read, nifti_image_free, nifti_image_read_bricks
6965
6962
nifti_image_load, nifti_read_collapsed_image
0 commit comments