From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1QrUT7-0006TW-33 for mharc-grub-devel@gnu.org; Thu, 11 Aug 2011 08:34:37 -0400 Received: from eggs.gnu.org ([140.186.70.92]:56078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrUT4-0006TA-Gk for grub-devel@gnu.org; Thu, 11 Aug 2011 08:34:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrUT3-00084I-AI for grub-devel@gnu.org; Thu, 11 Aug 2011 08:34:34 -0400 Received: from 19.mo5.mail-out.ovh.net ([46.105.35.78]:47519 helo=mo5.mail-out.ovh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrUT3-00084E-1G for grub-devel@gnu.org; Thu, 11 Aug 2011 08:34:33 -0400 Received: from mail414.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with SMTP id 6A8231024042 for ; Thu, 11 Aug 2011 14:34:41 +0200 (CEST) Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 11 Aug 2011 14:34:31 +0200 Received: from aannecy-651-1-65-169.w86-209.abo.wanadoo.fr (HELO ?192.168.1.6?) (piervit@pvittet.com@86.209.208.169) by ns0.ovh.net with SMTP; 11 Aug 2011 14:34:29 +0200 Message-ID: <4E43CC54.30107@pvittet.com> Date: Thu, 11 Aug 2011 14:34:28 +0200 From: Pierre Vittet User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110705 Thunderbird/3.1.11 MIME-Version: 1.0 To: grub-devel@gnu.org X-Ovh-Mailout: 178.32.228.5 (mo5.mail-out.ovh.net) Subject: GCC plugin to add warnings: testing on grub Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 14723674558188093582 X-Ovh-Remote: 86.209.208.169 (aannecy-651-1-65-169.w86-209.abo.wanadoo.fr) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -105 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfedvtddrtdejucetggdotefuucfrrhhofhhilhgvmecuqfggjfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdludehmdenshhouhhnugdjucdlqddvtddm X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 46.105.35.78 Cc: Alexandre Lissy , Basile Starynkevitch X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2011 12:34:35 -0000 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.