From: Anthony Liguori <anthony@codemonkey.ws>
To: Michael Tokarev <mjt@tls.msk.ru>, Blue Swirl <blauwirbel@gmail.com>
Cc: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 0/3] Purge the silly GLib Basic Types
Date: Sat, 19 Jan 2013 10:47:42 -0600 [thread overview]
Message-ID: <87622tazm9.fsf@codemonkey.ws> (raw)
In-Reply-To: <50FA7706.5000008@msgid.tls.msk.ru>
Michael Tokarev <mjt@tls.msk.ru> writes:
> 19.01.2013 13:33, Blue Swirl wrote:
>> On Fri, Jan 18, 2013 at 4:17 PM, Anthony Liguori <anthony@codemonkey.ws> wrote:
>>> Markus Armbruster <armbru@redhat.com> 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
prev parent reply other threads:[~2013-01-19 16:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-18 16:04 [Qemu-devel] [PATCH 0/3] Purge the silly GLib Basic Types Markus Armbruster
2013-01-18 16:04 ` [Qemu-devel] [PATCH 1/3] Purge the silly GLib "Basic Types", except for gboolean Markus Armbruster
2013-01-18 16:04 ` [Qemu-devel] [PATCH 2/3] Purge GLib's gboolean, it's a trap for the unwary Markus Armbruster
2013-01-18 16:04 ` [Qemu-devel] [PATCH 3/3] checkpatch: Keep out the GLib silliness we just purged Markus Armbruster
2013-01-18 16:17 ` [Qemu-devel] [PATCH 0/3] Purge the silly GLib Basic Types Anthony Liguori
2013-01-19 9:33 ` Blue Swirl
2013-01-19 10:35 ` Michael Tokarev
2013-01-19 11:20 ` Blue Swirl
2013-01-19 16:47 ` Anthony Liguori [this message]
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=87622tazm9.fsf@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).