All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre Vittet <piervit@pvittet.com>
To: grub-devel@gnu.org
Cc: Alexandre Lissy <alexandre.lissy@etu.univ-tours.fr>,
	Basile Starynkevitch <basile@starynkevitch.net>
Subject: GCC plugin to add warnings: testing on grub
Date: Thu, 11 Aug 2011 14:34:28 +0200	[thread overview]
Message-ID: <4E43CC54.30107@pvittet.com> (raw)

Hello,

My name is Pierre Vittet, I am working on a GCC plugin (for a GSOC),
named Talpo, which allows the user to add specific compiler warnings,
adapted to a project.

I had an interesting talk with Vladimir Serbinenko during the LSM
(http://2011.rmll.info/?lang=en) which encouraged me to run some tests
on grub.

For the moment there is 3 kind of possible tests in Talpo:

-test_null : Test that a call to a given function is followed by a test
on his returned pointer, else return a warning.

-test_followed_by : Test that in a same function body, when we have a
call to a given function, we also have a call to another given function,
else return a warning.

-test_immediately_followed_by : Test that a call to a given function, is
immediately followed by a call to another given function, else, return a
warning.

I have launched the following tests when compiling grub:

(testNull "grub_malloc")
(testNull "grub_strdup")
(testNull "grub_bufio_open")
(testFollowedBy "grub_bufio_open" 0 "grub_bufio_close" 1)

You can found compilation log at :
http://pvittet.com/GSOC/log_grub_talpo.txt (too big to be in attachment).

The 3 first tests, means that we want to check that the pointer returned
by grub_malloc, grub_strdup, grub_bufio_open are tested to be (not)
null. They return quite a lot of warnings which looks pertinent to me
(even if a few are not).

Test 4 means that when we have a call to grub_bufio_open, we want in the
same function to have a grub_bufio_close on the variable returned by
grub_bufio_open. The 0 means that we focus on the returned variable of
grub_bufio_open and the 1 means that we want this variable to be first
argument of a grub_bufio_close. I got two warnings, one is a false one
(in term of logical, in function grub_buffile_open we do not want to
close buffer after opening it). The second one is more interesting (in
grub_net_fs_open in grub-core/net/net.c). We don't call
grub_buffile_close but directly free file, so we might not correctly
free field file->data.

Talpo is not made to be "false warnings free" but should be right in
most case, I am still improving it to restrict as much as possible false
positives. What I need is to find useful tests, so if you have an idea
of what would be pertinent to test in grub, I would like to launch the
tests. Talpo is available under GPL here: https://gitorious.org/talpo.
However it needs MELT (http://gcc-melt.org/) to works. MELT is actually
in an unstable state and should wait until the end of the month before
the 0.9 release go out. So I cannot advise you to have a try now except
if you have time to spend for MELT.

I hope this project sounds interesting to you!
Thanks!

Pierre Vittet

PS: I runned my test on revision 3398 of grub. I had to disable -g flags
when compiling (because it adds informations in GCC intermediate
representation) which interfered with my plugin.



                 reply	other threads:[~2011-08-11 12:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E43CC54.30107@pvittet.com \
    --to=piervit@pvittet.com \
    --cc=alexandre.lissy@etu.univ-tours.fr \
    --cc=basile@starynkevitch.net \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.