On Sun, Apr 17, 2016 at 3:30 PM, Emil Velikov <emil.l.veli...@gmail.com> wrote: > Rather than 'hacking' around symbol names and providing macros such as > 'Local' just fold things and make the code more readable. > > Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com>
Series is: Reviewed-by: Alex Deucher <alexander.deuc...@amd.com> > --- > > If people prefer we can split out the different implementations > (HAS_SAVED_IDS_AND_SETEUID vs not) to separate functions and call if > from xf86writeConfigFile(). I don't mind either way. > > -Emil > > hw/xfree86/parser/write.c | 31 +++++++++---------------------- > 1 file changed, 9 insertions(+), 22 deletions(-) > > diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c > index 8792783..9a24dd6 100644 > --- a/hw/xfree86/parser/write.c > +++ b/hw/xfree86/parser/write.c > @@ -73,14 +73,7 @@ > #define HAS_NO_UIDS > #endif > > -#ifdef HAS_NO_UIDS > -#define doWriteConfigFile xf86writeConfigFile > -#define Local /**/ > -#else > -#define Local static > -#endif > - > -Local int > +static int > doWriteConfigFile(const char *filename, XF86ConfigPtr cptr) > { > FILE *cf; > @@ -134,24 +127,19 @@ doWriteConfigFile(const char *filename, XF86ConfigPtr > cptr) > return 1; > } > > -#ifndef HAS_NO_UIDS > - > int > xf86writeConfigFile(const char *filename, XF86ConfigPtr cptr) > { > +#ifndef HAS_NO_UIDS > int ret; > > -#if !defined(HAS_SAVED_IDS_AND_SETEUID) > - int pid, p; > - int status; > - void (*csig) (int); > -#else > - int ruid, euid; > -#endif > - > if (getuid() != geteuid()) { > > #if !defined(HAS_SAVED_IDS_AND_SETEUID) > + int pid, p; > + int status; > + void (*csig) (int); > + > /* Need to fork to change ruid without loosing euid */ > csig = signal(SIGCHLD, SIG_DFL); > switch ((pid = fork())) { > @@ -178,6 +166,7 @@ xf86writeConfigFile(const char *filename, XF86ConfigPtr > cptr) > return 0; > > #else /* HAS_SAVED_IDS_AND_SETEUID */ > + int ruid, euid; > > ruid = getuid(); > euid = geteuid(); > @@ -198,9 +187,7 @@ xf86writeConfigFile(const char *filename, XF86ConfigPtr > cptr) > #endif /* HAS_SAVED_IDS_AND_SETEUID */ > > } > - else { > + else > +#endif /* !HAS_NO_UIDS */ > return doWriteConfigFile(filename, cptr); > - } > } > - > -#endif /* !HAS_NO_UIDS */ > -- > 2.8.0 > > _______________________________________________ > xorg-devel@lists.x.org: X.Org development > Archives: http://lists.x.org/archives/xorg-devel > Info: https://lists.x.org/mailman/listinfo/xorg-devel _______________________________________________ xorg-devel@lists.x.org: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel