[previous] 0174 [next] [U] Unknown length modifier used with 'n' conversion specifier, number %s.
Explicitly undefined REFERENCE - ISO:C90-7.9.6.1 Formatted input/output functions

An unknown length modifier is being used in conjunction with a '%n' conversion specifier in a printf format string.

Valid length modifiers for a '%n' conversion specifier are "h" and "l" - indicating that the corresponding argument is of type "pointer to short" or "pointer to long".

In the code example below "L" has been used; but "L" is only valid with %e, %f or %g.


/*PRQA S 184,185,336,602,1307,2017,3122,3200,3209,3227,3408,3602,3625 ++*/

#include <stdio.h>

extern void foo(char *pc)
{
    short sn;
    int   in;
    long  ln;

    printf("My name is %s %n",   pc, &in);           /* OK */
    printf("My name is %s %hn",  pc, &sn);           /* OK */
    printf("My name is %s %ln",  pc, &ln);           /* OK */

    printf("My name is %s %Ln",  pc, &in);           /* Message 0174 */
}


MISRA C:2012 Rules applicable to message 0174:

Rule-1.3  (Required) There shall be no occurrence of undefined or critical unspecified behaviour


QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents