From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Twba7-00033e-5J for qemu-devel@nongnu.org; Sat, 19 Jan 2013 11:47:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Twba5-0000AG-LX for qemu-devel@nongnu.org; Sat, 19 Jan 2013 11:47:47 -0500 Received: from mail-ob0-f175.google.com ([209.85.214.175]:46961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Twba5-0000A9-GT for qemu-devel@nongnu.org; Sat, 19 Jan 2013 11:47:45 -0500 Received: by mail-ob0-f175.google.com with SMTP id tb18so67772obb.34 for ; Sat, 19 Jan 2013 08:47:44 -0800 (PST) From: Anthony Liguori In-Reply-To: <50FA7706.5000008@msgid.tls.msk.ru> References: <1358525049-31163-1-git-send-email-armbru@redhat.com> <87vcau5uuw.fsf@codemonkey.ws> <50FA7706.5000008@msgid.tls.msk.ru> Date: Sat, 19 Jan 2013 10:47:42 -0600 Message-ID: <87622tazm9.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 0/3] Purge the silly GLib Basic Types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev , Blue Swirl Cc: Markus Armbruster , qemu-devel@nongnu.org Michael Tokarev writes: > 19.01.2013 13:33, Blue Swirl wrote: >> On Fri, Jan 18, 2013 at 4:17 PM, Anthony Liguori wrote: >>> Markus Armbruster writes: >>> >>>> See PATCH 1/3 for rationale. >>>> >>>> Markus Armbruster (3): >>>> Purge the silly GLib "Basic Types", except for gboolean >>>> Purge GLib's gboolean, it's a trap for the unwary >>>> checkpatch: Keep out the GLib silliness we just purged >>> >>> Changing QEMU code to work around checkpatch's failing is insane. >>> >>> When interacting with glib, use glib types. Not using those types just >>> makes the code more difficult to understand. >> >> While the types are indeed useless and even cause problems (gboolean), >> I agree with Anthony. It's the same as using DWORD for Win32 APIs. > > Actually it is far from DWORD. DWORD is like uint32_t, where no > standard C type matches (since these depends on the word size etc). > So in Win32, these DWORDs are justified. > > With GLib, things are sillier than that, since they redefine _standard_ > C types, without gaining anything in portability. glib predates "standard C types". They were only introduced in C99 and weren't widely available until a few years later. There are reasons for all of it. For instance, there was a time when not all C compilers supported const so if you wanted to use it you had to #define around it. gconstpointer was a trick to make use of const while still supporting older compilers. Likewise, bool is a relatively new thing so gboolean made sense at the time. The lack of stdint led to g[u]int{8,16,32,64} and once you have all of that, gint and guint are pretty obvious. We should not use these types pervasively in QEMU, of course preferring more modern standard C99, but when glib takes a callback of: gboolean (*GSourceFunc)(gpointer data) Then the most readable thing to do is to write your callback following that signature. Regards, Anthony Liguori > > /mjt