From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21225 invoked by alias); 20 Mar 2013 15:03:29 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 21190 invoked by uid 89); 20 Mar 2013 15:03:19 -0000 X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD autolearn=ham version=3.3.1 Received: from mail-wg0-f46.google.com (HELO mail-wg0-f46.google.com) (74.125.82.46) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 20 Mar 2013 15:03:16 +0000 Received: by mail-wg0-f46.google.com with SMTP id fg15so1380710wgb.1 for ; Wed, 20 Mar 2013 08:03:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding :x-gm-message-state; bh=w5l5qEPRG5OqDyDvJ0TSgpCh3QaE0Ka0FufG/80+Ufw=; b=JZqQjrbLy55C5u0P0HBNXADSxzPlRKSIZElM6UPM5oIQkbVqrKPg1hK8y1KEtqleFR PaR/FobGJbhvnRNt81xtpvOC5jBYlPV/YSSBAPP3ZFmNMiYXeIp5SCPieD1b1Umh8sJv Jmy4SWd6aYYk0jieHhAOGzp/0ot2K0JC/jJBWuS0N7vasuoanxmq68RjWVp6916rlnz+ pmCcP+NDz0hXKqyTo1u3UOBBspCMh+0u46Jqu63L/fo1OzZJxe+AP1hrNp2VVCwLFrDt aG2xtfuGQgN72/oOnd1+8gqKmJ5288dzNzag5pmNagEbYETyDWXdkM1go7zVb0f5ZIH8 Nnmw== MIME-Version: 1.0 X-Received: by 10.194.20.40 with SMTP id k8mr11304758wje.16.1363791794040; Wed, 20 Mar 2013 08:03:14 -0700 (PDT) Received: by 10.194.29.200 with HTTP; Wed, 20 Mar 2013 08:03:13 -0700 (PDT) In-Reply-To: <51492077.30307@codesourcery.com> References: <83ip4s4ixc.fsf@gnu.org> <1363407692-18959-1-git-send-email-yao@codesourcery.com> <1363407692-18959-4-git-send-email-yao@codesourcery.com> <51492077.30307@codesourcery.com> Date: Wed, 20 Mar 2013 15:17:00 -0000 Message-ID: Subject: Re: [PATCH 3/3] Don't use unportable macros From: Doug Evans To: Yao Qi Cc: gdb-patches , Eli Zaretskii Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQl1czQA0pzT2sLcUCEqYsL0gT9H+K2NoXG2rJV9oYMZpzs7y+j+72vQJ7cgetJU6E6813KRdmZ+L14aaAQEirRoVh506R01zURN9HlmLt+LSqVAUB/Qvo850j80rxrYXGf42nsEJTXHvKcrYKycP/9rnr9YdkxKECTX2yQt96n1ah25SsTfuo2yszWbJgf1Sq/pJuOibFeNq+7hvMkhcneZsdFHRA== X-SW-Source: 2013-03/txt/msg00737.txt.bz2 On Tue, Mar 19, 2013 at 7:35 PM, Yao Qi 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 !=3D EEXIST) >>> + if (mkdir (dirname, S_IRUSR | S_IWUSR | S_IXUSR) && errno !=3D EEXIS= T) >>> 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 |=3D 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 (=E9=BD=90=E5=B0=A7) > > gdb: > > 2013-03-20 Yao Qi > > * 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 > > @@ -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 ch= ar *dirname) > struct ctf_trace_file_writer *writer > =3D (struct ctf_trace_file_writer *) self; > int i; > + mode_t hmode =3D 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 !=3D EEXIST) > + if (mkdir (dirname, hmode) && errno !=3D EEXIST) > error (_("Unable to open directory '%s' for saving trace data (%s)"), > dirname, safe_strerror (errno)); > > -- > 1.7.7.6