xserver: Branch 'master' - 4 commits
Adam Jackson
ajax at kemper.freedesktop.org
Mon Apr 18 15:42:04 UTC 2016
hw/xfree86/parser/DRI.c | 2 -
hw/xfree86/parser/Device.c | 3 --
hw/xfree86/parser/Extensions.c | 2 -
hw/xfree86/parser/Files.c | 2 -
hw/xfree86/parser/Flags.c | 2 -
hw/xfree86/parser/Input.c | 3 --
hw/xfree86/parser/InputClass.c | 3 --
hw/xfree86/parser/Layout.c | 4 +--
hw/xfree86/parser/Module.c | 4 +--
hw/xfree86/parser/Monitor.c | 8 +++----
hw/xfree86/parser/OutputClass.c | 3 --
hw/xfree86/parser/Pointer.c | 4 +--
hw/xfree86/parser/Screen.c | 4 +--
hw/xfree86/parser/Vendor.c | 4 +--
hw/xfree86/parser/Video.c | 4 +--
hw/xfree86/parser/configProcs.h | 6 ++---
hw/xfree86/parser/read.c | 2 -
hw/xfree86/parser/scan.c | 42 ++++++++++++++++------------------------
hw/xfree86/parser/write.c | 31 ++++++++---------------------
19 files changed, 54 insertions(+), 79 deletions(-)
New commits:
commit 577bebe2067293bb154068e99a2ef085b066cb67
Author: Emil Velikov <emil.l.velikov at gmail.com>
Date: Sun Apr 17 20:30:46 2016 +0100
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 at gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
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 */
commit 537276a5b86b7341169ea4eb36d479a503ba5d84
Author: Emil Velikov <emil.l.velikov at gmail.com>
Date: Sun Apr 17 20:30:45 2016 +0100
xfree86/parser: reuse StringToToken() in xf86getToken()
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 5c2e4ae..81a454b 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -441,14 +441,8 @@ xf86getToken(const xf86ConfigSymTabRec * tab)
/*
* Joop, at last we have to lookup the token ...
*/
- if (tab) {
- i = 0;
- while (tab[i].token != -1)
- if (xf86nameCompare(configRBuf, tab[i].name) == 0)
- return tab[i].token;
- else
- i++;
- }
+ if (tab)
+ return StringToToken(configRBuf, tab);
return ERROR_TOKEN; /* Error catcher */
}
commit 944ea03d5be2ffe22a3f1c4c287760261c31235f
Author: Emil Velikov <emil.l.velikov at gmail.com>
Date: Sun Apr 17 20:30:44 2016 +0100
xfree86/parser: move StringToToken() definition further up
... so that we can use it without the forward declaration. Plus we're
doing to reuse it in the next commit ;-)
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 2760439..5c2e4ae 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -87,8 +87,6 @@
#define CONFIG_BUF_LEN 1024
#define CONFIG_MAX_FILES 64
-static int StringToToken(const char *, const xf86ConfigSymTabRec *);
-
static struct {
FILE *file;
char *path;
@@ -241,6 +239,18 @@ xf86getNextLine(void)
return ret;
}
+static int
+StringToToken(const char *str, const xf86ConfigSymTabRec * tab)
+{
+ int i;
+
+ for (i = 0; tab[i].token != -1; i++) {
+ if (!xf86nameCompare(tab[i].name, str))
+ return tab[i].token;
+ }
+ return ERROR_TOKEN;
+}
+
/*
* xf86getToken --
* Read next Token from the config file. Handle the global variable
@@ -1028,18 +1038,6 @@ xf86getStringToken(const xf86ConfigSymTabRec * tab)
return StringToToken(xf86_lex_val.str, tab);
}
-static int
-StringToToken(const char *str, const xf86ConfigSymTabRec * tab)
-{
- int i;
-
- for (i = 0; tab[i].token != -1; i++) {
- if (!xf86nameCompare(tab[i].name, str))
- return tab[i].token;
- }
- return ERROR_TOKEN;
-}
-
/*
* Compare two names. The characters '_', ' ', and '\t' are ignored
* in the comparison.
commit b93be14b7d339e4e46d941729dad853452fae8c0
Author: Emil Velikov <emil.l.velikov at gmail.com>
Date: Sun Apr 17 20:30:43 2016 +0100
xfree86/parser: annotate xf86ConfigSymTabRec as constant data
Add the const notation to all the static storage as well as the
functions that use it - xf86getToken(), xf86getSubTokenWithTab(),
StringToToken() and xf86getStringToken().
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
diff --git a/hw/xfree86/parser/DRI.c b/hw/xfree86/parser/DRI.c
index 9ed5b9e..31f447d 100644
--- a/hw/xfree86/parser/DRI.c
+++ b/hw/xfree86/parser/DRI.c
@@ -37,7 +37,7 @@
#include "Configint.h"
-static xf86ConfigSymTabRec DRITab[] = {
+static const xf86ConfigSymTabRec DRITab[] = {
{ENDSECTION, "endsection"},
{GROUP, "group"},
{MODE, "mode"},
diff --git a/hw/xfree86/parser/Device.c b/hw/xfree86/parser/Device.c
index 7e49843..353d48c 100644
--- a/hw/xfree86/parser/Device.c
+++ b/hw/xfree86/parser/Device.c
@@ -61,8 +61,7 @@
#include "Configint.h"
-static
-xf86ConfigSymTabRec DeviceTab[] = {
+static const xf86ConfigSymTabRec DeviceTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{VENDOR, "vendorname"},
diff --git a/hw/xfree86/parser/Extensions.c b/hw/xfree86/parser/Extensions.c
index a6fcb56..3a21959 100644
--- a/hw/xfree86/parser/Extensions.c
+++ b/hw/xfree86/parser/Extensions.c
@@ -41,7 +41,7 @@
#include "Configint.h"
-static xf86ConfigSymTabRec ExtensionsTab[] = {
+static const xf86ConfigSymTabRec ExtensionsTab[] = {
{ENDSECTION, "endsection"},
{OPTION, "option"},
{-1, ""},
diff --git a/hw/xfree86/parser/Files.c b/hw/xfree86/parser/Files.c
index 849bf92..c86ac7a 100644
--- a/hw/xfree86/parser/Files.c
+++ b/hw/xfree86/parser/Files.c
@@ -61,7 +61,7 @@
#include "Configint.h"
-static xf86ConfigSymTabRec FilesTab[] = {
+static const xf86ConfigSymTabRec FilesTab[] = {
{ENDSECTION, "endsection"},
{FONTPATH, "fontpath"},
{MODULEPATH, "modulepath"},
diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c
index 5169665..0f69734 100644
--- a/hw/xfree86/parser/Flags.c
+++ b/hw/xfree86/parser/Flags.c
@@ -63,7 +63,7 @@
#include "optionstr.h"
-static xf86ConfigSymTabRec ServerFlagsTab[] = {
+static const xf86ConfigSymTabRec ServerFlagsTab[] = {
{ENDSECTION, "endsection"},
{NOTRAPSIGNALS, "notrapsignals"},
{DONTZAP, "dontzap"},
diff --git a/hw/xfree86/parser/Input.c b/hw/xfree86/parser/Input.c
index cfacd4e..88d19b6 100644
--- a/hw/xfree86/parser/Input.c
+++ b/hw/xfree86/parser/Input.c
@@ -62,8 +62,7 @@
#include "Configint.h"
-static
-xf86ConfigSymTabRec InputTab[] = {
+static const xf86ConfigSymTabRec InputTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{OPTION, "option"},
diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c
index 5d3b59c..392aa28 100644
--- a/hw/xfree86/parser/InputClass.c
+++ b/hw/xfree86/parser/InputClass.c
@@ -34,8 +34,7 @@
#include "Configint.h"
-static
-xf86ConfigSymTabRec InputClassTab[] = {
+static const xf86ConfigSymTabRec InputClassTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{OPTION, "option"},
diff --git a/hw/xfree86/parser/Layout.c b/hw/xfree86/parser/Layout.c
index 0ace5da..2c829f4 100644
--- a/hw/xfree86/parser/Layout.c
+++ b/hw/xfree86/parser/Layout.c
@@ -66,7 +66,7 @@
extern int xf86CheckBoolOption(void *optlist, const char *name, int deflt);
-static xf86ConfigSymTabRec LayoutTab[] = {
+static const xf86ConfigSymTabRec LayoutTab[] = {
{ENDSECTION, "endsection"},
{SCREEN, "screen"},
{IDENTIFIER, "identifier"},
@@ -77,7 +77,7 @@ static xf86ConfigSymTabRec LayoutTab[] = {
{-1, ""},
};
-static xf86ConfigSymTabRec AdjTab[] = {
+static const xf86ConfigSymTabRec AdjTab[] = {
{RIGHTOF, "rightof"},
{LEFTOF, "leftof"},
{ABOVE, "above"},
diff --git a/hw/xfree86/parser/Module.c b/hw/xfree86/parser/Module.c
index 0dcf4ba..38bf777 100644
--- a/hw/xfree86/parser/Module.c
+++ b/hw/xfree86/parser/Module.c
@@ -61,13 +61,13 @@
#include "Configint.h"
-static xf86ConfigSymTabRec SubModuleTab[] = {
+static const xf86ConfigSymTabRec SubModuleTab[] = {
{ENDSUBSECTION, "endsubsection"},
{OPTION, "option"},
{-1, ""},
};
-static xf86ConfigSymTabRec ModuleTab[] = {
+static const xf86ConfigSymTabRec ModuleTab[] = {
{ENDSECTION, "endsection"},
{LOAD, "load"},
{DISABLE, "disable"},
diff --git a/hw/xfree86/parser/Monitor.c b/hw/xfree86/parser/Monitor.c
index 0a8c081..a33c968 100644
--- a/hw/xfree86/parser/Monitor.c
+++ b/hw/xfree86/parser/Monitor.c
@@ -61,7 +61,7 @@
#include "Configint.h"
-static xf86ConfigSymTabRec MonitorTab[] = {
+static const xf86ConfigSymTabRec MonitorTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{VENDOR, "vendorname"},
@@ -77,7 +77,7 @@ static xf86ConfigSymTabRec MonitorTab[] = {
{-1, ""},
};
-static xf86ConfigSymTabRec ModesTab[] = {
+static const xf86ConfigSymTabRec ModesTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{MODELINE, "modeline"},
@@ -85,7 +85,7 @@ static xf86ConfigSymTabRec ModesTab[] = {
{-1, ""},
};
-static xf86ConfigSymTabRec TimingTab[] = {
+static const xf86ConfigSymTabRec TimingTab[] = {
{TT_INTERLACE, "interlace"},
{TT_PHSYNC, "+hsync"},
{TT_NHSYNC, "-hsync"},
@@ -101,7 +101,7 @@ static xf86ConfigSymTabRec TimingTab[] = {
{-1, ""},
};
-static xf86ConfigSymTabRec ModeTab[] = {
+static const xf86ConfigSymTabRec ModeTab[] = {
{DOTCLOCK, "dotclock"},
{HTIMINGS, "htimings"},
{VTIMINGS, "vtimings"},
diff --git a/hw/xfree86/parser/OutputClass.c b/hw/xfree86/parser/OutputClass.c
index 3f2082e..8064e0c 100644
--- a/hw/xfree86/parser/OutputClass.c
+++ b/hw/xfree86/parser/OutputClass.c
@@ -32,8 +32,7 @@
#include "xf86tokens.h"
#include "Configint.h"
-static
-xf86ConfigSymTabRec OutputClassTab[] = {
+static const xf86ConfigSymTabRec OutputClassTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{DRIVER, "driver"},
diff --git a/hw/xfree86/parser/Pointer.c b/hw/xfree86/parser/Pointer.c
index 2f9d505..ff63deb 100644
--- a/hw/xfree86/parser/Pointer.c
+++ b/hw/xfree86/parser/Pointer.c
@@ -62,7 +62,7 @@
#include "Xprintf.h"
-static xf86ConfigSymTabRec PointerTab[] = {
+static const xf86ConfigSymTabRec PointerTab[] = {
{PROTOCOL, "protocol"},
{EMULATE3, "emulate3buttons"},
{EM3TIMEOUT, "emulate3timeout"},
@@ -83,7 +83,7 @@ static xf86ConfigSymTabRec PointerTab[] = {
{-1, ""},
};
-static xf86ConfigSymTabRec ZMapTab[] = {
+static const xf86ConfigSymTabRec ZMapTab[] = {
{XAXIS, "x"},
{YAXIS, "y"},
{-1, ""},
diff --git a/hw/xfree86/parser/Screen.c b/hw/xfree86/parser/Screen.c
index 4731970..a831c30 100644
--- a/hw/xfree86/parser/Screen.c
+++ b/hw/xfree86/parser/Screen.c
@@ -61,7 +61,7 @@
#include "Configint.h"
-static xf86ConfigSymTabRec DisplayTab[] = {
+static const xf86ConfigSymTabRec DisplayTab[] = {
{ENDSUBSECTION, "endsubsection"},
{MODES, "modes"},
{VIEWPORT, "viewport"},
@@ -222,7 +222,7 @@ xf86parseDisplaySubSection(void)
#undef CLEANUP
-static xf86ConfigSymTabRec ScreenTab[] = {
+static const xf86ConfigSymTabRec ScreenTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{MATCHSEAT, "matchseat"},
diff --git a/hw/xfree86/parser/Vendor.c b/hw/xfree86/parser/Vendor.c
index f137a4e..50ea689 100644
--- a/hw/xfree86/parser/Vendor.c
+++ b/hw/xfree86/parser/Vendor.c
@@ -61,7 +61,7 @@
#include "Configint.h"
-static xf86ConfigSymTabRec VendorSubTab[] = {
+static const xf86ConfigSymTabRec VendorSubTab[] = {
{ENDSUBSECTION, "endsubsection"},
{IDENTIFIER, "identifier"},
{OPTION, "option"},
@@ -129,7 +129,7 @@ xf86parseVendorSubSection(void)
#undef CLEANUP
-static xf86ConfigSymTabRec VendorTab[] = {
+static const xf86ConfigSymTabRec VendorTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{OPTION, "option"},
diff --git a/hw/xfree86/parser/Video.c b/hw/xfree86/parser/Video.c
index 666b0ab..4e8526f 100644
--- a/hw/xfree86/parser/Video.c
+++ b/hw/xfree86/parser/Video.c
@@ -61,7 +61,7 @@
#include "Configint.h"
-static xf86ConfigSymTabRec VideoPortTab[] = {
+static const xf86ConfigSymTabRec VideoPortTab[] = {
{ENDSUBSECTION, "endsubsection"},
{IDENTIFIER, "identifier"},
{OPTION, "option"},
@@ -128,7 +128,7 @@ xf86parseVideoPortSubSection(void)
#undef CLEANUP
-static xf86ConfigSymTabRec VideoAdaptorTab[] = {
+static const xf86ConfigSymTabRec VideoAdaptorTab[] = {
{ENDSECTION, "endsection"},
{IDENTIFIER, "identifier"},
{VENDOR, "vendorname"},
diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h
index 171f8e8..7a46e01 100644
--- a/hw/xfree86/parser/configProcs.h
+++ b/hw/xfree86/parser/configProcs.h
@@ -102,9 +102,9 @@ void xf86printVideoAdaptorSection(FILE * cf, XF86ConfVideoAdaptorPtr ptr);
void xf86freeVideoAdaptorList(XF86ConfVideoAdaptorPtr ptr);
/* scan.c */
-int xf86getToken(xf86ConfigSymTabRec * tab);
+int xf86getToken(const xf86ConfigSymTabRec * tab);
int xf86getSubToken(char **comment);
-int xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec * tab);
+int xf86getSubTokenWithTab(char **comment, const xf86ConfigSymTabRec * tab);
void xf86unGetToken(int token);
char *xf86tokenString(void);
void
@@ -116,7 +116,7 @@ _X_ATTRIBUTE_PRINTF(1, 2);
void
xf86setSection(const char *section);
int
-xf86getStringToken(xf86ConfigSymTabRec * tab);
+xf86getStringToken(const xf86ConfigSymTabRec * tab);
/* write.c */
/* DRI.c */
diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c
index 327c02a..ec038ae 100644
--- a/hw/xfree86/parser/read.c
+++ b/hw/xfree86/parser/read.c
@@ -61,7 +61,7 @@
#include "Configint.h"
-static xf86ConfigSymTabRec TopLevelTab[] = {
+static const xf86ConfigSymTabRec TopLevelTab[] = {
{SECTION, "section"},
{-1, ""},
};
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index b8a08cf..2760439 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -87,7 +87,7 @@
#define CONFIG_BUF_LEN 1024
#define CONFIG_MAX_FILES 64
-static int StringToToken(const char *, xf86ConfigSymTabRec *);
+static int StringToToken(const char *, const xf86ConfigSymTabRec *);
static struct {
FILE *file;
@@ -247,7 +247,7 @@ xf86getNextLine(void)
* pushToken.
*/
int
-xf86getToken(xf86ConfigSymTabRec * tab)
+xf86getToken(const xf86ConfigSymTabRec * tab)
{
int c, i;
@@ -460,7 +460,7 @@ xf86getSubToken(char **comment)
/*NOTREACHED*/}
int
-xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec * tab)
+xf86getSubTokenWithTab(char **comment, const xf86ConfigSymTabRec * tab)
{
int token;
@@ -1023,13 +1023,13 @@ xf86setSection(const char *section)
* Lookup a string if it is actually a token in disguise.
*/
int
-xf86getStringToken(xf86ConfigSymTabRec * tab)
+xf86getStringToken(const xf86ConfigSymTabRec * tab)
{
return StringToToken(xf86_lex_val.str, tab);
}
static int
-StringToToken(const char *str, xf86ConfigSymTabRec * tab)
+StringToToken(const char *str, const xf86ConfigSymTabRec * tab)
{
int i;
More information about the xorg-commit
mailing list