This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/2]: Refactor relocate_path to also check if the relocated file/directory exists


> Date: Fri, 21 Sep 2012 20:46:23 +0200
> From: Jan Kratochvil <jan.kratochvil@redhat.com>
> Cc: khooyp@cs.umd.edu, gdb-patches@sourceware.org
> 
> On Fri, 21 Sep 2012 20:35:39 +0200, Eli Zaretskii wrote:
> > > Date: Fri, 21 Sep 2012 20:26:37 +0200
> > > From: Jan Kratochvil <jan.kratochvil@redhat.com>
> > > Cc: GDB Patches <gdb-patches@sourceware.org>
> > > 
> > > 	  if (stat (path, &s) != 0 || (isdir && !S_ISDIR (s.st_mode))
> > > 	      || (!isdir && S_ISDIR (s.st_mode)))
> > 
> > a.k.a.
> > 
> > 	  if (stat (path, &s) != 0 || isdir != S_ISDIR (s.st_mode))
> 
> It is not POSIX compliant:
> 	The macro evaluates to a non-zero value if the test is true

Then

	if (stat (path, &s) != 0 
	    || (isdir != 0) != (S_ISDIR (s.st_mode) != 0))

will do.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]