From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6348 invoked by alias); 14 Dec 2012 08:17:01 -0000 Received: (qmail 6336 invoked by uid 22791); 14 Dec 2012 08:16:59 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.155) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Dec 2012 08:16:54 +0000 Received: from md16.u-strasbg.fr (md16.u-strasbg.fr [130.79.200.206]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qBE8GmtU092883 ; Fri, 14 Dec 2012 09:16:48 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms15.u-strasbg.fr [130.79.204.115]) by md16.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qBE8GmBb027483 ; Fri, 14 Dec 2012 09:16:48 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qBE8GlS8019219 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Fri, 14 Dec 2012 09:16:47 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Tom Tromey'" Cc: References: <29503.7594777115$1354726985@news.gmane.org> <87sj7ks7g6.fsf@fleche.redhat.com> <434.327257289802$1354751122@news.gmane.org> <87d2ynxc6t.fsf@fleche.redhat.com> In-Reply-To: <87d2ynxc6t.fsf@fleche.redhat.com> Subject: RE: [RFA] Avoid calling stat with empty name in relocate_gdb_directory Date: Fri, 14 Dec 2012 08:17:00 -0000 Message-ID: <000601cdd9d3$5e3c7640$1ab562c0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 X-SW-Source: 2012-12/txt/msg00482.txt.bz2 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Tom Tromey > Envoy=E9=A0: jeudi 6 d=E9cembre 2012 19:34 > =C0=A0: Pierre Muller > Cc=A0: gdb-patches@sourceware.org > Objet=A0: Re: [RFA] Avoid calling stat with empty name in > relocate_gdb_directory >=20 > >>>>> "Pierre" =3D=3D Pierre Muller writes: >=20 > Pierre> Apparently it isn't used elsewhere... > Pierre> Should we modify the default value to NULL instead of ""? > Pierre> I do not master complicated autoconf things like > Pierre> GDB_AC_DEFINE_RELOCATABLE well enough to know if this is > Pierre> without problems... >=20 > Pierre> Tell me if you think we should modify it at configury level or > Pierre> if I should commit my patch, whatever you prefer! >=20 > Maybe we should just skip computing gdb_sysroot if TARGET_SYSTEM_ROOT is > "". What do you think? I looked at the different calls to relocate_gdb_directory: $ find . -iname "*.[chy]" |xargs grep -n gdb_directory ./charset.c:816: char *iconv_dir =3D relocate_gdb_directory (ICONV_BIN, ./defs.h:275:extern char *relocate_gdb_directory (const char *initial, int flag); ./jit.c:1402: jit_reader_dir =3D relocate_gdb_directory (JIT_READER_DIR, ./main.c:120:relocate_gdb_directory (const char *initial, int flag) ./main.c:391: gdb_sysroot =3D relocate_gdb_directory (TARGET_SYSTEM_ROOT, ./main.c:394: debug_file_directory =3D relocate_gdb_directory (DEBUGDIR, ./main.c:397: gdb_datadir =3D relocate_gdb_directory (GDB_DATADIR, ./main.c:405: python_libdir =3D relocate_gdb_directory (tmp, PYTHON_PATH_RELOCATABLE); Are we sure all other calls have non-empty first argument? Another problem is that currently the returned string is always allocated, which means that we should at least also use xstrdup ("") ... I still think that the approach of testing if *dir =3D=3D '\0' is safer... Pierre