summaryrefslogtreecommitdiff
path: root/hw/xfree86/parser
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2016-04-17 20:30:46 +0100
committerAdam Jackson <ajax@redhat.com>2016-04-18 11:36:46 -0400
commit577bebe2067293bb154068e99a2ef085b066cb67 (patch)
tree894c59cc6975f5c446aa3c7a8e2e6d995018376b /hw/xfree86/parser
parent537276a5b86b7341169ea4eb36d479a503ba5d84 (diff)
xfree86/parser: simplify #ifdef ladder
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.velikov@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'hw/xfree86/parser')
-rw-r--r--hw/xfree86/parser/write.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/hw/xfree86/parser/write.c b/hw/xfree86/parser/write.c
index 8792783ef..9a24dd6cf 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 */