From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9ujV-0005U3-W8 for qemu-devel@nongnu.org; Fri, 18 Dec 2015 08:06:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9ujQ-0001Gj-JV for qemu-devel@nongnu.org; Fri, 18 Dec 2015 08:06:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37506) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9ujQ-0001G3-4c for qemu-devel@nongnu.org; Fri, 18 Dec 2015 08:06:00 -0500 Date: Fri, 18 Dec 2015 13:05:55 +0000 From: "Daniel P. Berrange" Message-ID: <20151218130555.GB7228@redhat.com> References: <1450438575-21613-1-git-send-email-berrange@redhat.com> <5673FDB0.6040900@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5673FDB0.6040900@redhat.com> Subject: Re: [Qemu-devel] [PATCH] scripts: provide a script for checking glib symbol usage Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Peter Maydell , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , qemu-devel@nongnu.org, "Dr. David Alan Gilbert" On Fri, Dec 18, 2015 at 01:36:00PM +0100, Paolo Bonzini wrote: > > > On 18/12/2015 12:36, Daniel P. Berrange wrote: > > diff --git a/scripts/Makefile b/scripts/Makefile > > new file mode 100644 > > index 0000000..162e7e9 > > --- /dev/null > > +++ b/scripts/Makefile > > @@ -0,0 +1,24 @@ > > +# > > +# This makefile runs various style checks across the entire > > +# source tree. > > +# > > +# This is similar in concept of checkpatch.pl, but enforces > > +# rules across the entire codebase, not just new patches > > +# > > + > > +STYLE_CHECKS = \ > > + cs-glib-syms > > + > > +ALL_FILES = \ > > + $(shell git ls-tree -r HEAD . | awk '{print $$4}') > > + > > +C_CODE_FILES = $(filter %.c %.h, $(ALL_FILES)) > > + > > +check-style: $(STYLE_CHECKS) > > + > > +# Check that we only use glib symbols present in our > > +# minimum declared glib version > > +GLIB_SYMS_LIST = scripts/glib-syms.txt > > + > > +cs-glib-syms: > > + @perl scripts/glib-syms.pl $(GLIB_SYMS_LIST) $(C_CODE_FILES) > > > Does this need to be included, or could it be a separate Makefile > invoked with e.g. make -f scripts/Makefile.style? Any particular reason to favour that over include ? I did it this way because QEMU in general seems to be biased towards includes and not recursive make > > +# Symbols not present in the release that we depend > > +# on, but which have wrappers in include/glib-compat.h > > +my @compatsyms = qw( > > + g_get_monotonic_time > > + > > + g_assert_true > > + g_assert_false > > + g_assert_null > > + g_assert_nonnull > > + g_assert_cmpmem > > + > > + g_hash_table_add > > + > > + g_cond_clear > > + g_cond_init > > + g_cond_wait_until > > + > > + g_mutex_init > > + g_mutex_clear > > + > > + g_thread_new > > + > > + g_private_replace > > + G_PRIVATE_INIT > > + > > + G_TIME_SPAN_SECOND > > +); > > + > > + > > +# Functions defined inside QEMU which are using the > > +# the same "g_" function name prefix as glib, so > > +# get mis-detected as glib symbols > > +my @blacklist = qw( > > + g_to_float64 > > + g_assert_no_errno > > + g_cclosure_new_swap > > + g_free_rcu > > + g_test_trap_subprocess > > + g_poll_fixed > > + g_list_insert_sorted_merged > > + G_BYTE > > +); > > + > > +# GObject stuff used by gtk frontend > > +my @gobjectsums = qw( > > + g_object_ref > > + g_object_unref > > + g_object_set_data > > + g_signal_connect > > + G_CALLBACK > > +); > > + > > +# Functions defined by glib which are strangely > > +# missing from their docs header index > > +my @missingindex = qw( > > + g_assertion_message > > + g_assertion_message_expr > > + g_assertion_message_cmpstr > > + g_assertion_message_cmpnum > > + g_assertion_message_error > > +); > > + > > Can we "parse" #.* as comments, and put these in a glib-syms-extra.txt > file? Then we can hypothetically do the same tests in checkpatch.pl too. Yep, that works. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|