This looks great, Thanks.

Couple of things:

- If you specify an include file using "-include" option, sparse opens it in
handle_switch_i()  but does not close it cleanly so for the next time the
read does not return anything but EOF. I think we should close the fd in
sparse_file once the tokenize is done. So here is the diff that I am
suggesting.

-----------------------------------
$ cg-diff
diff --git a/lib.c b/lib.c
--- a/lib.c
+++ b/lib.c
@@ -463,8 +463,10 @@ struct symbol_list *sparse_file(const ch
        close(fd);

        // Prepend any "include" file to the stream.
-       if (include_fd >= 0)
+       if (include_fd >= 0) {
                token = tokenize(include, include_fd, token, includepath);
+               close(include_fd);
+       }

        // Prepend the initial built-in stream
        token = tokenize_buffer(pre_buffer, pre_buffer_size, token);
-------------------------------------


- Now how do I get the symbol_list per file after sparsing? Just checking
the scope enough? For example, if I want to generate intermediate files per
source file.


Thanks,

-Mitesh




>
> On Tue, 2 Aug 2005, Linus Torvalds wrote:
> >
> >     [EMAIL PROTECTED] sparse]$ cat -n test.c
> >          1  void f(unsigned int arg)
> >          2  {
> >          3  }
> >     [EMAIL PROTECTED] sparse]$ cat -n test.c
> >          1  void f(unsigned int arg)
> >          2  {
> >          3  }
>
> That should have been
>
>       [EMAIL PROTECTED] sparse]$ cat -n test2.c
>            1  void f(void)
>            2  {
>            3  }
>
> of course, for this to maek any sense:
>
> >     [EMAIL PROTECTED] sparse]$ ./check test.c test2.c
> >     test.c:1:6: warning: symbol 'f' was not declared. Should it
> be static?
> >     test.c:1:6: warning: symbol 'f' was not declared. Should it
> be static?
> >     test2.c:1:6: warning: symbol 'f' redeclared with different
> type (originally declared at test.c:1) - incompatible argument 1
> (different types)
>
> Duh.
>



-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to