From JHolland at FASTSOFT.COM Mon Jan 12 11:44:05 2009 From: JHolland at FASTSOFT.COM (Jake Holland) Date: Mon, 12 Jan 2009 11:44:05 -0800 Subject: [splint-discuss] Running Splint on entire project (util script) References: <7c1ab96d0812201852r45fe4f6ct9402a89b88892711@mail.gmail.com> Message-ID: I did it in the makefile. We had an extra couple of system includes, which was kind of a hassle, and I suspect could be done better than what I've got, but it works for gmake. But thanks for posting, and I'd be interested to hear more ways people folded splint into their process. (Especially if anybody's done it with scons, which I'd love to switch to.) And here's a working makefile that's a little bit like my real ones: ALL_DEFS := -DWHATEVER SYSTEM_INC := dir1 dir2 INCLUDE := dir3 dir4 SRC := prog.c x.c #some multi-platform if clauses that do INCLUDE += xx #(inside a if clause to optionally set it to empty) SPLINT_CMD = splint -f splint.opt $(ALL_DEFS) $(ALL_SPLINT_INC) -I$( $(@:%.o=%.d) $(SPLINT_CMD) gcc -c -o $@ $(ALL_CFLAGS) $(ALL_DEFS) $(ALL_GCC_INC) -I$( When I run splint on programs using Glib data structures , I get these sort of warnings: test-glib-splint.c:29:5: Fresh storage list (type GList *) not released before assignment: list = g_list_delete_link(list, g_list_last(list)) test-glib-splint.c:26:5: Fresh storage list created The offending line is: list = g_list_delete_link(list, g_list_last(list)); I think it is normal Glib idiom. According to the documentation, g_list_delete_link() frees the removed element (here, at the end of the list). But how to explain it to splint? I noticed in the manual the use of /*@releases X@*/ but I did not write glib and I prefer not to modify its source. From n3npq at mac.com Tue Jan 13 14:22:53 2009 From: n3npq at mac.com (Jeff Johnson) Date: Tue, 13 Jan 2009 17:22:53 -0500 Subject: [splint-discuss] [Beginner] Glib data structures not detected as freed In-Reply-To: <20090113220014.GA17856@sources.org> References: <20090113220014.GA17856@sources.org> Message-ID: <73AF1155-A00C-4CFF-984C-C0DC5A285EFA@mac.com> On Jan 13, 2009, at 5:00 PM, Stephane Bortzmeyer wrote: > > I noticed in the manual the use of /*@releases X@*/ but I did not > write glib and I prefer not to modify its source. You won't succeed using splint with glib unless glib methods are annotated consistently. Whether you consider adding C comments (aka splint annotations) to glib prototypes as "modifying source" is all in the eye of the beholder. You won't succeed using splint with glib unless glib methods are annotated consistently. 73 de Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4664 bytes Desc: not available Url : http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20090113/3113377e/attachment-0001.bin From bortz at users.sourceforge.net Wed Jan 14 01:25:44 2009 From: bortz at users.sourceforge.net (Stephane Bortzmeyer) Date: Wed, 14 Jan 2009 10:25:44 +0100 Subject: [splint-discuss] [Beginner] Glib data structures not detected as freed In-Reply-To: <73AF1155-A00C-4CFF-984C-C0DC5A285EFA@mac.com> References: <20090113220014.GA17856@sources.org> <73AF1155-A00C-4CFF-984C-C0DC5A285EFA@mac.com> Message-ID: <20090114092544.GD18459@nic.fr> On Tue, Jan 13, 2009 at 05:22:53PM -0500, Jeff Johnson wrote a message of 135 lines which said: > Whether you consider adding C comments (aka splint annotations) to > glib prototypes as "modifying source" is all in the eye of the > beholder. Well, I tried the following in my source code: /* Repeat the prototype with annotations */ GList *g_list_delete_link(GList * list, GList * link_) /* @releases list@ */ ; And I get the same warning: test-glib-splint.c:32:5: Fresh storage list (type GList *) not released before assignment: list = g_list_delete_link(list, g_list_last(list)) test-glib-splint.c:29:5: Fresh storage list created From n3npq at mac.com Wed Jan 14 05:15:14 2009 From: n3npq at mac.com (Jeff Johnson) Date: Wed, 14 Jan 2009 08:15:14 -0500 Subject: [splint-discuss] [Beginner] Glib data structures not detected as freed In-Reply-To: <20090114092544.GD18459@nic.fr> References: <20090113220014.GA17856@sources.org> <73AF1155-A00C-4CFF-984C-C0DC5A285EFA@mac.com> <20090114092544.GD18459@nic.fr> Message-ID: <50CF65F3-9E9A-4B02-BCCB-C4D03266EEF8@mac.com> On Jan 14, 2009, at 4:25 AM, Stephane Bortzmeyer wrote: > On Tue, Jan 13, 2009 at 05:22:53PM -0500, > Jeff Johnson wrote > a message of 135 lines which said: > >> Whether you consider adding C comments (aka splint annotations) to >> glib prototypes as "modifying source" is all in the eye of the >> beholder. > > Well, I tried the following in my source code: > > /* Repeat the prototype with annotations */ > GList *g_list_delete_link(GList * list, > GList * link_) > /* @releases list@ */ ; > > And I get the same warning: > > test-glib-splint.c:32:5: Fresh storage list (type GList *) not > released before > assignment: list = g_list_delete_link(list, g_list_last(list)) > test-glib-splint.c:29:5: Fresh storage list created Without context its a bit hard to tell. Try this /* Repeat the prototype with annotations */ GList *g_list_delete_link(/*@only@*/ GList * list, GList * link_) /*@modifies list @*/ ; The @only@ annotation should mark "list" as being released. Note that link list memory annotations are often hard to get right in my experience using splint as well. hth 73 de Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4664 bytes Desc: not available Url : http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20090114/b31a660b/attachment.bin From bortz at users.sourceforge.net Sat Jan 24 05:50:08 2009 From: bortz at users.sourceforge.net (Stephane Bortzmeyer) Date: Sat, 24 Jan 2009 14:50:08 +0100 Subject: [splint-discuss] [Beginner] Glib data structures not detected as freed In-Reply-To: <50CF65F3-9E9A-4B02-BCCB-C4D03266EEF8@mac.com> References: <20090113220014.GA17856@sources.org> <73AF1155-A00C-4CFF-984C-C0DC5A285EFA@mac.com> <20090114092544.GD18459@nic.fr> <50CF65F3-9E9A-4B02-BCCB-C4D03266EEF8@mac.com> Message-ID: <20090124135008.GA20382@sources.org> On Wed, Jan 14, 2009 at 08:15:14AM -0500, Jeff Johnson wrote a message of 158 lines which said: > Try this > /* Repeat the prototype with annotations */ > GList *g_list_delete_link(/*@only@*/ GList * list, > GList * link_) > /*@modifies list @*/ ; Hmmm, no, sorry, splint is not happy: test-glib-splint.c:21:39: Parameter list inconsistently redeclared as only storage, previously declared as implicitly temp storage A function, variable or constant is redefined with a different type. (Use -incondefs to inhibit warning) /usr/include/glib-2.0/glib/glist.h:74:60: Declaration of list The glist.h contains: GList* g_list_delete_link (GList *list, GList *link_) G_GNUC_WARN_UNUSED_RESULT; For a full context, I attached the C source I use. It compiles without gcc warnings and runs fine but I would like to be able to check it with splint. -------------- next part -------------- A non-text attachment was scrubbed... Name: test-glib-splint.c Type: text/x-csrc Size: 1692 bytes Desc: not available Url : http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20090124/748defa2/attachment.bin From n3npq at mac.com Sat Jan 24 06:18:02 2009 From: n3npq at mac.com (Jeff Johnson) Date: Sat, 24 Jan 2009 09:18:02 -0500 Subject: [splint-discuss] [Beginner] Glib data structures not detected as freed In-Reply-To: <20090124135008.GA20382@sources.org> References: <20090113220014.GA17856@sources.org> <73AF1155-A00C-4CFF-984C-C0DC5A285EFA@mac.com> <20090114092544.GD18459@nic.fr> <50CF65F3-9E9A-4B02-BCCB-C4D03266EEF8@mac.com> <20090124135008.GA20382@sources.org> Message-ID: <8FB20C25-2D61-486C-BE84-175CBD6EAB33@mac.com> On Jan 24, 2009, at 8:50 AM, Stephane Bortzmeyer wrote: > On Wed, Jan 14, 2009 at 08:15:14AM -0500, > Jeff Johnson wrote > a message of 158 lines which said: > >> Try this >> /* Repeat the prototype with annotations */ >> GList *g_list_delete_link(/*@only@*/ GList * list, >> GList * link_) >> /*@modifies list @*/ ; > > Hmmm, no, sorry, splint is not happy: > > test-glib-splint.c:21:39: Parameter list inconsistently redeclared > as only > storage, previously declared as implicitly temp storage > A function, variable or constant is redefined with a different > type. (Use > -incondefs to inhibit warning) > /usr/include/glib-2.0/glib/glist.h:74:60: Declaration of list > Retrofitting annotations onto existing system prototypes usually requires /*@-incondefs@*/ ... /*@=incondefs@*/ around the retrofitted prototype. The other approach is to disable -incondefs globally when running splint. In my experience, splint warnings about inconsistently defined prototypes are more "stuff" than I'm usually interested in. > The glist.h contains: > > GList* g_list_delete_link (GList *list, > GList *link_) G_GNUC_WARN_UNUSED_RESULT; > > For a full context, I attached the C source I use. It compiles without > gcc warnings and runs fine but I would like to be able to check it > with splint. If you want "real world" examples of how to deal with many splint issues, try looking at RPM sources from @rpm5.org. I've been using splint for years with RPM, and there are various retrofits to many splint issues. 73 de Jeff > > _______________________________________________ > splint-discuss mailing list > splint-discuss at mail.cs.virginia.edu > http://www.cs.virginia.edu/mailman/listinfo/splint-discuss -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4664 bytes Desc: not available Url : http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20090124/8e119e63/attachment.bin