Menu

#8 Thinks C99 'hh' length modifier in printf is invalid format

v3.1.3
closed-fixed
nobody
None
5
2010-07-24
2009-01-05
No

From the printf(3) man page:

The length modifier
Here, "integer conversion" stands for d, i, o, u, x, or X conversion.

hh A following integer conversion corresponds to a signed char or unsigned char argument,
or a following n conversion corresponds to a pointer to a signed char argument.

$ cat foo.c
#include <stdio.h>

int main()
{
int a = 3;
printf("%hhx\n", a);
return 0;
}

$ splint foo.c
Splint 3.1.2 --- 23 Aug 2008

foo.c: (in function main)
foo.c:6:17: Unrecognized format code: %02hhx\n
Format code in a format string is not valid. (Use -formatcode to inhibit
warning)

Finished checking --- 1 code warning

Bug based on http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=510821

Discussion

  • Y Giridhar Appaji Nag

    test-case

     
  • Bill Pringlemeir

    This is fixed in CVS. The warning is now,

    foo.c: (in function main)
    foo.c:6:22: Format argument 1 to printf (%hhx) expects unsigned int gets int: a
    To ignore signs in type comparisons use +ignoresigns
    foo.c:6:16: Corresponding format code

    Changing 'int a =3' to 'unsigned int a =3' gives no warnings with default arguments.

     
  • Bill Pringlemeir

    • status: open --> pending-fixed
     
  • Bill Pringlemeir

    • milestone: --> v3.1.3
     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB