This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
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.