GNOME Bugzilla – Bug 589930
Vala adds extra NULL argument to sscanf
Last modified: 2009-08-01 16:18:15 UTC
Please describe the problem: Vala adds an extra argument to sscanf (NULL), which makes the C compiler generate a warning with -Wall. This is valac 0.7.4. ongardie@lappy:~$ cat scanf.vala public static int main (string[] args) { int number; ("123").scanf ("%d", out number); return number; } ongardie@lappy:~$ valac -X -Wall scanf.vala /tmp/scanf.vala.c: In function ‘_main’: /tmp/scanf.vala.c:19: warning: too many arguments for format ongardie@lappy:~$ valac -C scanf.vala ongardie@lappy:~$ cat scanf.c | nl -b a 1 2 #include <glib.h> 3 #include <glib-object.h> 4 #include <stdio.h> 5 #include <stdlib.h> 6 #include <string.h> 7 8 9 10 11 gint _main (char** args, int args_length1); 12 13 14 15 gint _main (char** args, int args_length1) { 16 gint result; 17 gint number; 18 number = 0; 19 sscanf ("123", "%d", &number, NULL); 20 result = number; 21 return result; 22 } 23 24 25 int main (int argc, char ** argv) { 26 g_type_init (); 27 return _main (argv, argc); 28 } 29 30 31 32 Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
We need an attribute [ScanfFormat] similar to [PrintfFormat] that would enable argument checks for scanf-like functions. As part of that we could also drop the extra NULL, we already do this for printf as well.
commit 7d5a61e38664ceabfe6a903af38d057bdf831a4b Author: Jürg Billeter <j@bitron.ch> Date: Sat Aug 1 18:17:29 2009 +0200 Support [ScanfFormat] attribute Fixes bug 589930.