qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Stefan Weil <weil@mail.berlios.de>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH 01/14] Add new data type for fprintf like function pointers
Date: Fri, 2 Jul 2010 01:08:29 +0200	[thread overview]
Message-ID: <20100701230829.GE25251@ohm.aurel32.net> (raw)
In-Reply-To: <4C2C5B21.50306@mail.berlios.de>

On Thu, Jul 01, 2010 at 11:08:49AM +0200, Stefan Weil wrote:
> Am 09.04.2010 13:20, schrieb Stefan Weil:
> >Aurelien Jarno schrieb:
> >>On Mon, Mar 29, 2010 at 09:16:52PM +0200, Stefan Weil wrote:
> >>>The compiler should check the arguments for these functions.
> >>>
> >>>gcc can do this, but only if the function pointer's prototype
> >>>includes the __attribute__ flag.
> >>>
> >>>As the necessary declaration is a bit lengthy, we use a new
> >>>data type 'fprintf_function'.
> >>>
> >>>It is not easy to find a single header file which is included
> >>>everywhere, so fprint_function had to be declared in several
> >>>header files.
> >>
> >>I don't really think it is a good idea to duplicate that. It will only
> >>causes problem in the future. Are you sure there is no header for that?
> >>Worst case scenario it's probably better to create a new header.
> >
> >I had no better idea. As long as the duplicate declarations
> >always observe the same pattern, they should not really cause
> >problems. Anybody who knows this pattern (which is also quite
> >common in system include files) will know that there are duplicates.
> >
> >I did not want to create a new header because it is really a worst
> >case scenario with several disadvantages.
> >
> >In the meantime I noticed that dis-asm.h also uses fprintf like
> >function pointers, so there is one more header which needs
> >the same declaration.
> >
> >Maybe the best solution would be using qemu-common.h in
> >cpu-exec.c, *-dis.c, */translate.c, and more files.
> >That would involve a lot of modifications, for example
> >removing code which re-implements parts of stdio.h in
> >dyngen-exec.h. Some restrictions why qemu-common.h was
> >not used might be no longer valid (I think they came
> >from pre-tcg times). Nevertheless, cris-dis.c even says
> >that it cannot include qemu-common.h (without giving a
> >reason). Reordering include statements or adding new
> >includes can have unwanted side effects which are
> >difficult to detect.
> >
> >So this last solution needs a lot of discussion and time.
> >That's the reason why I did not choose it. Maybe I was wrong
> >and more developers want to clean up includes, so it can be done.
> 
> More files use qemu-common.h now, so it seems possible to declare
> the new data type only once (in qemu-common.h).
> 
> There are undetected format errors in current code. Without
> argument checking by the compiler, even new format errors
> are introduced from time to time. Therefore the motivation
> for these patches is still given.
> 
> Before I send updated patches, I'd like to ask a simple question:
> 
> There is already a data type named 'fprintf_type' (without __attribute__
> flag) which is only used in *-dis.c. So which name is preferred
> for the new data type with __attribute__ flag?
> 
> * fprintf_type (already used in *-dis.c)?

It is actually fprintf_ftype.

> * fprintf_function (which I used in my patches)
> * any other name (coding rules?)

I am personally fine with fprintf_function.

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  reply	other threads:[~2010-07-01 23:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-29 19:16 [Qemu-devel] Check format specifiers for fprintf like function pointers Stefan Weil
2010-03-29 19:16 ` [Qemu-devel] [PATCH 01/14] Add new data type " Stefan Weil
2010-04-08 19:29   ` Aurelien Jarno
2010-04-09 11:20     ` Stefan Weil
2010-07-01  9:08       ` Stefan Weil
2010-07-01 23:08         ` Aurelien Jarno [this message]
2010-07-02 15:37       ` [Qemu-devel] " Paolo Bonzini
2010-07-02 16:17         ` [Qemu-devel] [RFC] env stored in segment register for i386 Richard Henderson
2010-07-03  7:32         ` [Qemu-devel] Re: [PATCH 01/14] Add new data type for fprintf like function pointers Blue Swirl
2010-03-29 19:16 ` [Qemu-devel] [PATCH 02/14] Use fprint_function and fix wrong format specifiers Stefan Weil
2010-03-29 19:16 ` [Qemu-devel] [PATCH 03/14] target-alpha: Use fprintf_function Stefan Weil
2010-03-29 19:16 ` [Qemu-devel] [PATCH 04/14] target-arm: " Stefan Weil
2010-03-29 19:16 ` [Qemu-devel] [PATCH 05/14] target-cris: " Stefan Weil
2010-03-29 19:16 ` [Qemu-devel] [PATCH 06/14] target-i386: Use fprintf_function and fix dump of DR registers Stefan Weil
2010-03-29 19:16 ` [Qemu-devel] [PATCH 07/14] target-m68k: Use fprintf_function Stefan Weil
2010-03-29 19:16 ` [Qemu-devel] [PATCH 08/14] target-microblaze: " Stefan Weil
2010-03-29 19:17 ` [Qemu-devel] [PATCH 09/14] target-mips: Use fprintf_function and fix wrong format specifiers Stefan Weil
2010-04-01 21:05   ` [Qemu-devel] [PATCH] target-mips: Fix format specifiers for fpu_fprintf Stefan Weil
2010-04-09 19:54     ` Aurelien Jarno
2010-03-29 19:17 ` [Qemu-devel] [PATCH 10/14] target-ppc: Use fprintf_function and fix wrong format specifiers Stefan Weil
2010-03-29 19:17 ` [Qemu-devel] [PATCH 11/14] target-sh4: Use fprintf_function Stefan Weil
2010-03-29 19:17 ` [Qemu-devel] [PATCH 12/14] target-sparc: " Stefan Weil
2010-03-29 19:17 ` [Qemu-devel] [PATCH 13/14] target-s390: " Stefan Weil
2010-03-29 19:17 ` [Qemu-devel] [PATCH 14/14] tcg: " Stefan Weil
2010-03-29 19:27 ` [Qemu-devel] Check format specifiers for fprintf like function pointers Stefan Weil

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=20100701230829.GE25251@ohm.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=qemu-devel@nongnu.org \
    --cc=weil@mail.berlios.de \
    /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).