[v2,1/7] common: add scoped_fd

Message ID A78C989F6D9628469189715575E55B236964A45F@IRSMSX104.ger.corp.intel.com
State New, archived
Headers

Commit Message

Metzger, Markus T Feb. 20, 2018, 10:46 a.m. UTC
  Hello Yao, Eli,

> > How about checking for mkstemp and, if not available, falling back to tmpnam.
> 
> Can we unconditionally use tmpnam+open which are more portable?  I know it is
> racy, but mkstemp is only used in a test case.  It is overkill to me to do the configure
> check or import gnulib module.
> 
> If we use mkstemp in gdb source (not test case) one day in the future, I prefer
> importing gnulib module.  What do you think?

I'd rather not use tmpnam.  This is really only a fallback for old systems.


I added mkstemp to update-gnulib.sh ...
 
---
---

... cloned gnulib, updated my automake, ran that script, and ended up with:

#       modified:   gdb/gnulib/aclocal.m4
#       modified:   gdb/gnulib/config.in
#       modified:   gdb/gnulib/configure
#       modified:   gdb/gnulib/import/Makefile.am
#       modified:   gdb/gnulib/import/Makefile.in
#       modified:   gdb/gnulib/import/m4/gnulib-cache.m4
#       modified:   gdb/gnulib/import/m4/gnulib-comp.m4
#       new file:   gdb/gnulib/import/m4/mkstemp.m4
#       new file:   gdb/gnulib/import/m4/secure_getenv.m4
#       new file:   gdb/gnulib/import/m4/tempname.m4
#       new file:   gdb/gnulib/import/mkstemp.c
#       new file:   gdb/gnulib/import/secure_getenv.c
#       new file:   gdb/gnulib/import/tempname.c
#       new file:   gdb/gnulib/import/tempname.h
#       modified:   gdb/gnulib/update-gnulib.sh


If I did everything correctly, it looks like gnulib would only provide mkstemp as a fall-back.  On
my system, it would still use the glibc version.  Good.  I wouldn't want to replace a standard
glibc function.

I have not tried building GDB with mingw cross tools, yet.  Would you be able to test whether
this solves your build problem, Yao?

thanks,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  

Comments

Yao Qi Feb. 20, 2018, 11:09 a.m. UTC | #1
On Tue, Feb 20, 2018 at 10:46 AM, Metzger, Markus T
<markus.t.metzger@intel.com> wrote:
> ---
> diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
> index 55cd6e0..d026536 100755
> --- a/gdb/gnulib/update-gnulib.sh
> +++ b/gdb/gnulib/update-gnulib.sh
> @@ -59,6 +59,7 @@ IMPORTED_GNULIB_MODULES="\
>      update-copyright \
>      wchar \
>      wctype-h \
> +    mkstemp \
>  "
>

We should keep IMPORTED_GNULIB_MODULES in alphabetical order.
Otherwise, patch is good to me.

>
> I have not tried building GDB with mingw cross tools, yet.  Would you be able to test whether
> this solves your build problem, Yao?
>

Yes, it fixed my build problem.
  
Metzger, Markus T Feb. 20, 2018, 1:16 p.m. UTC | #2
> -----Original Message-----

> From: Yao Qi [mailto:qiyaoltc@gmail.com]

> Sent: 20 February 2018 12:10

> To: Metzger, Markus T <markus.t.metzger@intel.com>

> Cc: Eli Zaretskii (eliz@gnu.org) <eliz@gnu.org>; GDB Patches <gdb-

> patches@sourceware.org>

> Subject: Re: [PATCH v2 1/7] common: add scoped_fd

> 

> On Tue, Feb 20, 2018 at 10:46 AM, Metzger, Markus T

> <markus.t.metzger@intel.com> wrote:

> > ---

> > diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh

> > index 55cd6e0..d026536 100755

> > --- a/gdb/gnulib/update-gnulib.sh

> > +++ b/gdb/gnulib/update-gnulib.sh

> > @@ -59,6 +59,7 @@ IMPORTED_GNULIB_MODULES="\

> >      update-copyright \

> >      wchar \

> >      wctype-h \

> > +    mkstemp \

> >  "

> >

> 

> We should keep IMPORTED_GNULIB_MODULES in alphabetical order.

> Otherwise, patch is good to me.


Pushed.

Thanks,
Markus.
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
  

Patch

diff --git a/gdb/gnulib/update-gnulib.sh b/gdb/gnulib/update-gnulib.sh
index 55cd6e0..d026536 100755
--- a/gdb/gnulib/update-gnulib.sh
+++ b/gdb/gnulib/update-gnulib.sh
@@ -59,6 +59,7 @@  IMPORTED_GNULIB_MODULES="\
     update-copyright \
     wchar \
     wctype-h \
+    mkstemp \
 "
 
 # The gnulib commit ID to use for the update.