[previous] 3122 [next] Hard-coded 'magic' string literal, %s.
Constants

A string literal has been used.

It may be better to define this string with a macro or a static constant (e.g. "static const char *"). Message 3122 will not be generated in these contexts and the definition can be located where it can more easily be reviewed and maintained - rather than buried within executable code. This is particularly important for maintainability if the same constant is reused in several places. Giving the constant a name may also improve readability.

For example:


/*PRQA S 2017,3218,3232,3408,3447,3602,3625,3627 ++*/

extern void func( const char * s );

#define WELCOME_MSG "hello"
static const char * agenda = "Today's agenda";

extern void foo( void )
{
    func( "Start-up procedure" );               /* Message 3122 */

    func( WELCOME_MSG );                        /* OK           */

    func( agenda );                             /* OK           */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents