This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA-v2] Avoid invalid parameter warnings in C runtime function for mingw built GDB
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Tom Tromey'" <tromey at redhat dot com>
- Cc: "'Eli Zaretskii'" <eliz at gnu dot org>, <gdb-patches at sourceware dot org>
- Date: Wed, 14 Aug 2013 13:38:18 +0200
- Subject: [RFA-v2] Avoid invalid parameter warnings in C runtime function for mingw built GDB
- References: <"002201ce9414$7e0d7130$7a285390$ at muller"@ics-cnrs.unistra.fr> <83bo57rm59 dot fsf at gnu dot org> <41630 dot 7793967009$1376385245 at news dot gmane dot org> <874natr48x dot fsf at fleche dot redhat dot com>
I followed Eli's advice to go with Tom's suggestion.
> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Tom Tromey
> Envoyé : mardi 13 août 2013 17:38
> À : Pierre Muller
> Cc : 'Eli Zaretskii'; gdb-patches@sourceware.org
> Objet : Re: [RFC] Avoid invalid parameter warnings in C runtime function
for
> mingw builtr GDB
>
> >>>>> "Pierre" == Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
writes:
>
> Pierre> Once again, my insufficient C knowledge is to blame...
> Pierre> Would that be correct?
>
> Pierre> #if O_CLOEXEC
> Pierre> static int fopen_e_ever_failed = 0;
> Pierre> #else
> Pierre> static int fopen_e_ever_failed = 1;
> Pierre> #endif
>
> O_CLOEXEC is unconditionally defined earlier.
> But you can just write:
>
> /* If we provide a fake O_CLOEXEC, then don't ever try "e". */
> static int fopen_e_ever_failed = O_CLOEXEC == 0;
Is this OK to commit?
Maybe some comments on the ChangeLog entry?
Pierre Muller
2013-08-14 Pierre Muller <muller@sourceware.org>
Tom Tromey <tromey@redhat.com>
* common/filestuff.c (gdb_fopen_cloexec): Do not try to use "e"
mode if operating system doesn't know O_CLOEXEC, this allows to
avoid getting a output debug string warning for mingw hosted
GDB executables.
Index: src/gdb/common/filestuff.c
===================================================================
RCS file: /cvs/src/src/gdb/common/filestuff.c,v
retrieving revision 1.7
diff -u -p -r1.7 filestuff.c
--- src/gdb/common/filestuff.c 26 Jun 2013 08:01:55 -0000 1.7
+++ src/gdb/common/filestuff.c 14 Aug 2013 09:44:40 -0000
@@ -311,7 +311,9 @@ FILE *
gdb_fopen_cloexec (const char *filename, const char *opentype)
{
FILE *result = NULL;
- static int fopen_e_ever_failed;
+ /* If O_CLOEXEC is zero, the operating system doesn't
+ know about close on exec mode "e", so don't even try to use it. */
+ static int fopen_e_ever_failed = O_CLOEXEC == 0;
if (!fopen_e_ever_failed)
{