summaryrefslogtreecommitdiff
path: root/hw/xfree86/common
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2018-10-23 14:28:21 -0400
committerAdam Jackson <ajax@nwnk.net>2018-10-25 14:46:44 +0000
commit8d048a1fd3e3806c408192d33e62859f5bc5c343 (patch)
tree49e4a501d3039c3dbdaff68f6a9d02b25e1ccbeb /hw/xfree86/common
parentb45c74f0f2868689e7ed695b33e8c60cd378df0b (diff)
os: Factor out CHECK_FOR_REQUIRED_ARGUMENTS
Lifted from vfb. xfree86 had almost the same thing but unparameterized, port it to the vfb style. Signed-off-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'hw/xfree86/common')
-rw-r--r--hw/xfree86/common/xf86Init.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 0f57efa86..b148e1320 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -925,16 +925,9 @@ xf86CheckPrivs(const char *option, const char *arg)
int
ddxProcessArgument(int argc, char **argv, int i)
{
-#define CHECK_FOR_REQUIRED_ARGUMENT() \
- if (((i + 1) >= argc) || (!argv[i + 1])) { \
- ErrorF("Required argument to %s not specified\n", argv[i]); \
- UseMsg(); \
- FatalError("Required argument to %s not specified\n", argv[i]); \
- }
-
/* First the options that are not allowed with elevated privileges */
if (!strcmp(argv[i], "-modulepath")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
if (xf86PrivsElevated())
FatalError("\nInvalid argument -modulepath "
"with elevated privileges\n");
@@ -943,7 +936,7 @@ ddxProcessArgument(int argc, char **argv, int i)
return 2;
}
if (!strcmp(argv[i], "-logfile")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
if (xf86PrivsElevated())
FatalError("\nInvalid argument -logfile "
"with elevated privileges\n");
@@ -952,13 +945,13 @@ ddxProcessArgument(int argc, char **argv, int i)
return 2;
}
if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
xf86CheckPrivs(argv[i], argv[i + 1]);
xf86ConfigFile = argv[i + 1];
return 2;
}
if (!strcmp(argv[i], "-configdir")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
xf86CheckPrivs(argv[i], argv[i + 1]);
xf86ConfigDir = argv[i + 1];
return 2;
@@ -1052,7 +1045,7 @@ ddxProcessArgument(int argc, char **argv, int i)
if (!strcmp(argv[i], "-fbbpp")) {
int bpp;
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
if (sscanf(argv[++i], "%d", &bpp) == 1) {
xf86FbBpp = bpp;
return 2;
@@ -1065,7 +1058,7 @@ ddxProcessArgument(int argc, char **argv, int i)
if (!strcmp(argv[i], "-depth")) {
int depth;
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
if (sscanf(argv[++i], "%d", &depth) == 1) {
xf86Depth = depth;
return 2;
@@ -1078,7 +1071,7 @@ ddxProcessArgument(int argc, char **argv, int i)
if (!strcmp(argv[i], "-weight")) {
int red, green, blue;
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3) {
xf86Weight.red = red;
xf86Weight.green = green;
@@ -1094,7 +1087,7 @@ ddxProcessArgument(int argc, char **argv, int i)
!strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma")) {
double gamma;
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
if (sscanf(argv[++i], "%lf", &gamma) == 1) {
if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
@@ -1113,22 +1106,22 @@ ddxProcessArgument(int argc, char **argv, int i)
}
}
if (!strcmp(argv[i], "-layout")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
xf86LayoutName = argv[++i];
return 2;
}
if (!strcmp(argv[i], "-screen")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
xf86ScreenName = argv[++i];
return 2;
}
if (!strcmp(argv[i], "-pointer")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
xf86PointerName = argv[++i];
return 2;
}
if (!strcmp(argv[i], "-keyboard")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
xf86KeyboardName = argv[++i];
return 2;
}
@@ -1161,7 +1154,7 @@ ddxProcessArgument(int argc, char **argv, int i)
}
#ifdef XSERVER_LIBPCIACCESS
if (!strcmp(argv[i], "-isolateDevice")) {
- CHECK_FOR_REQUIRED_ARGUMENT();
+ CHECK_FOR_REQUIRED_ARGUMENTS(1);
if (strncmp(argv[++i], "PCI:", 4)) {
FatalError("Bus types other than PCI not yet isolable\n");
}