Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gdb-patches <gdb-patches@sourceware.org>, Eli Zaretskii <eliz@gnu.org>
Subject: Re: [PATCH 3/3] Don't use unportable macros
Date: Wed, 20 Mar 2013 15:17:00 -0000	[thread overview]
Message-ID: <CADPb22TpALWVMwrPwFj=1M=XuUtD7hCACp9Xin=X0frEzN3XCA@mail.gmail.com> (raw)
In-Reply-To: <51492077.30307@codesourcery.com>

On Tue, Mar 19, 2013 at 7:35 PM, Yao Qi <yao@codesourcery.com> wrote:
> On 03/20/2013 12:31 AM, Doug Evans wrote:
>>>     /* Create DIRNAME.  */
>>> -  if (mkdir (dirname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
>>> -      && errno != EEXIST)
>>> +  if (mkdir (dirname, S_IRUSR | S_IWUSR | S_IXUSR) && errno != EEXIST)
>>>       error (_("Unable to open directory '%s' for saving trace data (%s)"),
>>>             dirname, safe_strerror (errno));
>>
>> It feels like one would want to use mode 0755 by default on *nix.
>> Why not store the mode in a local, and have a sequence of #ifdef's
>> like remote-fileio.c?
>
> OK.  Done.  The directory mode now is 755.

Thanks.
I would have done it differently, e.g.,

#ifdef S_IRGRP
  hmode |= S_IRGRP;
#endif
...

but this way is ok.

> On 03/20/2013 01:19 AM, Eli Zaretskii wrote:
>>
>> This is why I suggested an alternative and much smaller and more
>> elegant solution.
>
> Also define a macro 'mkdir' in this patch, as Eli suggested before.  Is
> it OK?

fwiw, I don't mind all the crap gnulib dragged in.  Kinda depressing,
but whatever.
I just wanted to make sure it was correct.

I also don't mind Eli's suggestion.
One can argue the details belong elsewhere (if other parts of gdb want
mkdir it doesn't make sense to cut-n-paste that to every place -
unlikely, but still ...).

The "right" answer is probably to go with gnulib, but I'm happy to
defer judgement on this.

> --
> Yao (齐尧)
>
> gdb:
>
> 2013-03-20  Yao Qi  <yao@codesourcery.com>
>
>         * ctf.c: Include "gdb_stat.h".
>         [USE_WIN32API]: New macro 'mkdir'.
>         (ctf_start): Use permission bits macros if they are defined.
> ---
>  gdb/ctf.c |   20 ++++++++++++++++++--
>  1 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/ctf.c b/gdb/ctf.c
> index 455bfde..f058dc9 100644
> --- a/gdb/ctf.c
> +++ b/gdb/ctf.c
> @@ -24,6 +24,7 @@
>  #include "tracepoint.h"
>  #include "regcache.h"
>  #include "exec.h"
> +#include "gdb_stat.h"
>
>  #include <ctype.h>
>
> @@ -294,6 +295,10 @@ ctf_target_save (struct trace_file_writer *self,
>    return 0;
>  }
>
> +#ifdef USE_WIN32API
> +#define mkdir(pathname, mode) _mkdir (pathname)
> +#endif
> +
>  /* This is the implementation of trace_file_write_ops method
>     start.  It creates the directory DIRNAME, metadata and datastream
>     in the directory.  */
> @@ -306,10 +311,21 @@ ctf_start (struct trace_file_writer *self, const char *dirname)
>    struct ctf_trace_file_writer *writer
>      = (struct ctf_trace_file_writer *) self;
>    int i;
> +  mode_t hmode = S_IRUSR | S_IWUSR | S_IXUSR
> +#ifdef S_IRGRP
> +    | S_IRGRP
> +#endif
> +#ifdef S_IXGRP
> +    | S_IXGRP
> +#endif
> +    | S_IROTH /* Defined in common/gdb_stat.h if not defined.  */
> +#ifdef S_IXOTH
> +    | S_IXOTH
> +#endif
> +    ;
>
>    /* Create DIRNAME.  */
> -  if (mkdir (dirname, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
> -      && errno != EEXIST)
> +  if (mkdir (dirname, hmode) && errno != EEXIST)
>      error (_("Unable to open directory '%s' for saving trace data (%s)"),
>            dirname, safe_strerror (errno));
>
> --
> 1.7.7.6


  reply	other threads:[~2013-03-20 15:03 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15  2:02 New ARI warning Fri Mar 15 02:02:12 UTC 2013 in -D 2013-03-15-gmt GDB Administrator
2013-03-15  9:05 ` Yao Qi
2013-03-15  9:48   ` Compilation failure for mingw64 target (was New ARI warning Fri Mar 15 02:02:12 UTC 2013 in -D 2013-03-15-gmt) Pierre Muller
2013-03-15 11:06     ` Yao Qi
2013-03-15 11:24       ` Pierre Muller
2013-03-15 14:05       ` Yao Qi
2013-03-15 14:43       ` Yao Qi
2013-03-15 16:52         ` Tom Tromey
2013-03-15 16:55           ` Pierre Muller
     [not found]           ` <20313.4872871034$1363366373@news.gmane.org>
2013-03-15 17:01             ` Tom Tromey
2013-03-15 18:22               ` Eli Zaretskii
2013-03-15 18:24                 ` Tom Tromey
2013-03-15 18:33                   ` Eli Zaretskii
2013-03-15 18:53                     ` Mike Frysinger
2013-03-15 18:58                       ` Eli Zaretskii
2013-03-15 19:45                         ` Mike Frysinger
2013-03-16  4:23                     ` [PATCH 0/3] Fix build failure caused by ctf.c Yao Qi
2013-03-16  4:23                       ` [PATCH 2/3] Write CTF in host byte order Yao Qi
2013-03-19 21:26                         ` Joel Brobecker
2013-03-20  3:48                           ` Yao Qi
2013-03-16  4:23                       ` [PATCH 3/3] Don't use unportable macros Yao Qi
2013-03-19 17:12                         ` Doug Evans
2013-03-20  2:48                           ` Yao Qi
2013-03-20 15:17                             ` Doug Evans [this message]
2013-03-21  1:58                               ` Yao Qi
2013-03-20 17:36                             ` Eli Zaretskii
2013-03-20 17:40                               ` Tom Tromey
2013-03-25  4:08                                 ` [MinGW-w64]Build gdb/ctf.c failed asmwarrior
2013-03-25  6:41                                   ` asmwarrior
2013-03-25  8:28                                   ` Yao Qi
2013-03-25  8:39                                     ` Eli Zaretskii
2013-03-25  8:40                                   ` Eli Zaretskii
2013-03-25  9:15                                     ` Kai Tietz
2013-03-25  9:42                                       ` Yao Qi
2013-03-25 10:12                                         ` Kai Tietz
2013-03-25 12:43                                         ` Eli Zaretskii
2013-03-25 14:40                                           ` Yao Qi
2013-03-25  9:54                                       ` Eli Zaretskii
2013-03-25 10:50                                         ` Kai Tietz
2013-03-25 13:12                                           ` Eli Zaretskii
2013-03-25 13:21                                             ` Kai Tietz
2013-03-25 14:25                                               ` Eli Zaretskii
2013-03-25 15:18                                                 ` Kai Tietz
2013-03-25 15:44                                                   ` Eli Zaretskii
2013-03-25 16:14                                                     ` Kai Tietz
2013-03-25 16:25                                                       ` Eli Zaretskii
2013-03-16  7:35                       ` [PATCH 1/3] Import mkdir module Yao Qi
2013-03-19 16:32                         ` Doug Evans
2013-03-19 17:20                           ` Eli Zaretskii
2013-03-19 21:23                           ` Joel Brobecker
2013-03-15 16:22   ` New ARI warning Fri Mar 15 02:02:12 UTC 2013 in -D 2013-03-15-gmt Pedro Alves

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='CADPb22TpALWVMwrPwFj=1M=XuUtD7hCACp9Xin=X0frEzN3XCA@mail.gmail.com' \
    --to=dje@google.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=yao@codesourcery.com \
    /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