After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 589930 - Vala adds extra NULL argument to sscanf
Vala adds extra NULL argument to sscanf
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings
0.7.x
Other All
: Low trivial
: ---
Assigned To: Jürg Billeter
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2009-07-27 19:46 UTC by Diego Ongaro
Modified: 2009-08-01 16:18 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Diego Ongaro 2009-07-27 19:46:50 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:
Comment 1 Jürg Billeter 2009-07-27 19:58:03 UTC
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.
Comment 2 Jürg Billeter 2009-08-01 16:18:15 UTC
commit 7d5a61e38664ceabfe6a903af38d057bdf831a4b
Author: Jürg Billeter <j@bitron.ch>
Date:   Sat Aug 1 18:17:29 2009 +0200

    Support [ScanfFormat] attribute
    
    Fixes bug 589930.