From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7946 invoked by alias); 21 Sep 2012 18:27:08 -0000 Received: (qmail 7934 invoked by uid 22791); 21 Sep 2012 18:27:07 -0000 X-SWARE-Spam-Status: No, hits=-6.6 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Sep 2012 18:26:44 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8LIQgUS008954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Sep 2012 14:26:42 -0400 Received: from host2.jankratochvil.net (ovpn-113-58.phx2.redhat.com [10.3.113.58]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q8LIQcSu002669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 21 Sep 2012 14:26:40 -0400 Date: Fri, 21 Sep 2012 18:27:00 -0000 From: Jan Kratochvil To: Khoo Yit Phang Cc: GDB Patches Subject: Re: [PATCH 1/2]: Refactor relocate_path to also check if the relocated file/directory exists Message-ID: <20120921182637.GA8747@host2.jankratochvil.net> References: <21ACC598-F6B4-4117-BA7B-B316414DE9E3@cs.umd.edu> <20120919130040.GA20442@host2.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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-09/txt/msg00446.txt.bz2 On Wed, 19 Sep 2012 21:53:16 +0200, Khoo Yit Phang wrote: > -relocate_path (const char *progname, const char *initial, int flag) > +relocate_path (const char *progname, const char *initial, int isdir, > + int flag) > { > if (flag) > - return make_relative_prefix (progname, BINDIR, initial); > + { > + char *path; > + path = make_relative_prefix (progname, BINDIR, initial); > + if (path) > + { > + struct stat s; > + > + if (stat (path, &s) != 0 || (isdir && !S_ISDIR (s.st_mode))) OK just you could also check if !isdir, therefore: if (stat (path, &s) != 0 || (isdir && !S_ISDIR (s.st_mode)) || (!isdir && S_ISDIR (s.st_mode))) (I would write it differently but reviews here point to this style.) Thanks, Jan