File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 32853285 <returnValue type="gchar*"/>
32863286 <arg nr="1" direction="out">
32873287 <not-null/>
3288- <not-uninit/>
3289- <strz/>
3288+ <minsize type="argvalue" arg="2"/>
32903289 </arg>
32913290 <arg nr="2" direction="in">
32923291 <not-bool/>
32993298 <strz/>
33003299 <formatstr/>
33013300 </arg>
3302- <arg nr="4 " direction="in">
3301+ <arg nr="variadic " direction="in">
33033302 <not-bool/>
33043303 <not-uninit/>
33053304 </arg>
Original file line number Diff line number Diff line change @@ -655,3 +655,35 @@ int g_return_val_if_reached_test(const char *s) {
655655
656656 return 0 ;
657657}
658+
659+ void g_ascii_formatd_test (double d )
660+ {
661+ // g_ascii_formatd() writes the buffer and formats exactly one double
662+ gchar buf [39 ];
663+ g_ascii_formatd (buf , sizeof (buf ), "%.2f" , d );
664+ g_print ("%s" , buf );
665+
666+ // cppcheck-suppress invalidPrintfArgType_sint
667+ g_ascii_formatd (buf , sizeof (buf ), "%d" , d );
668+ g_print ("%s" , buf );
669+
670+ gchar small [4 ];
671+ // cppcheck-suppress bufferAccessOutOfBounds
672+ g_ascii_formatd (small , sizeof (buf ), "%.2f" , d );
673+ g_print ("%s" , small );
674+ }
675+
676+ void g_ascii_formatd_format_test (const gchar * format , int i )
677+ {
678+ gchar buf [39 ];
679+ // cppcheck-suppress invalidFunctionArgBool
680+ g_ascii_formatd (buf , sizeof (buf ), format , i == 1 );
681+ g_print ("%s" , buf );
682+
683+ struct {
684+ double x ;
685+ } s ;
686+ // cppcheck-suppress [uninitvar, uninitStructMember]
687+ g_ascii_formatd (buf , sizeof (buf ), format , s .x );
688+ g_print ("%s" , buf );
689+ }
You can’t perform that action at this time.
0 commit comments