[MINC-development] warning from volume_io/alloc.h

Sean McBride sean at rogue-research.com
Tue Dec 11 20:10:51 EST 2012


On Tue, 11 Dec 2012 18:49:24 -0500, Claude LEPAGE said:

>#define  _ALLOC_SOURCE_LINE    , (char*)__FILE__, __LINE__
>#define  _ALLOC_SOURCE_LINE_ARG_DEF   , char  filename[], int line_number
>#define  _ALLOC_SOURCE_LINE_ARGUMENTS   , filename, line_number
>#define  PRINT_ALLOC_SOURCE_LINE   \
>         print_alloc_source_line( filename, line_number );
>#endif
>
>
>Note the cast (char*) on __FILE__, which is consistent with the 
>definition on the next line char filename[]. By default, the compiler 
>assumes const char * and writes out a warning. Unless we change
>_ALLOC_SOURCE_LINE_ARG_DEF to const char filename[]...

The latter sounds preferable.  Casting away const is a big enough code smell to be listed in places like this:

<https://www.securecoding.cert.org/confluence/display/seccode/EXP05-C.+Do+not+cast+away+a+const+qualification>

Cheers,

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean at rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada




More information about the MINC-development mailing list