[Patch xserver] (percent) option parsing fixes
Peter Hutterer
peter.hutterer at who-t.net
Wed Feb 16 16:14:21 PST 2011
On Tue, Feb 15, 2011 at 12:51:19AM +0100, Simon Thum wrote:
> The attached patches allow to not just parse, but use percent options as
> double. It seems this has been the intent, as only one function was
> returning int. This makes sense mainly to adjust the newly-added
> synaptics noise cancellation in the low percent range.
>
> Next, don't emit warnings when not marking as used. This lets drivers
> check option syntax more flexibly without scaring users.
both merged into my -next, thanks.
Cheers,
Peter
> From a0261fb459f9715c075bc479ba841968ef199450 Mon Sep 17 00:00:00 2001
> From: Simon Thum <simon.thum at gmx.de>
> Date: Sun, 6 Feb 2011 19:07:19 +0100
> Subject: [PATCH 1/2] fix percent options parsing
>
> Signed-off-by: Simon Thum <simon.thum at gmx.de>
> ---
> hw/xfree86/common/xf86Option.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
> index 16c27e5..455cafa 100644
> --- a/hw/xfree86/common/xf86Option.c
> +++ b/hw/xfree86/common/xf86Option.c
> @@ -212,7 +212,7 @@ LookupBoolOption(pointer optlist, const char *name, int deflt, Bool markUsed)
> return deflt;
> }
>
> -static int
> +static double
> LookupPercentOption(pointer optlist, const char *name, double deflt, Bool markUsed)
> {
> OptionInfoRec o;
> --
> 1.7.3.4
>
> From 9c4a8e6dc68c6f5293460e4dba52a2da3148d256 Mon Sep 17 00:00:00 2001
> From: Simon Thum <simon.thum at gmx.de>
> Date: Sun, 6 Feb 2011 19:13:00 +0100
> Subject: [PATCH 2/2] xfree86: allow to check for options without warnings in the log
>
> This allows set_percent_option in synaptics to work as described,
> and should generally enable to check option syntax without log spam.
>
> Signed-off-by: Simon Thum <simon.thum at gmx.de>
> ---
> hw/xfree86/common/xf86Option.c | 75 +++++++++++++++++++++++++--------------
> 1 files changed, 48 insertions(+), 27 deletions(-)
>
> diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
> index 455cafa..480f386 100644
> --- a/hw/xfree86/common/xf86Option.c
> +++ b/hw/xfree86/common/xf86Option.c
> @@ -496,27 +496,33 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
> switch (p->type) {
> case OPTV_INTEGER:
> if (*s == '\0') {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires an integer value\n",
> - p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires an integer value\n",
> + p->name);
> + }
> p->found = FALSE;
> } else {
> p->value.num = strtoul(s, &end, 0);
> if (*end == '\0') {
> p->found = TRUE;
> } else {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires an integer value\n",
> - p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires an integer value\n",
> + p->name);
> + }
> p->found = FALSE;
> }
> }
> break;
> case OPTV_STRING:
> if (*s == '\0') {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires an string value\n",
> - p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires an string value\n",
> + p->name);
> + }
> p->found = FALSE;
> } else {
> p->value.str = s;
> @@ -529,18 +535,22 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
> break;
> case OPTV_REAL:
> if (*s == '\0') {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires a floating point value\n",
> - p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires a floating point "
> + "value\n", p->name);
> + }
> p->found = FALSE;
> } else {
> p->value.realnum = strtod(s, &end);
> if (*end == '\0') {
> p->found = TRUE;
> } else {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires a floating point value\n",
> - p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires a floating point "
> + "value\n", p->name);
> + }
> p->found = FALSE;
> }
> }
> @@ -549,8 +559,11 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
> if (GetBoolValue(p, s)) {
> p->found = TRUE;
> } else {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires a boolean value\n", p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires a boolean value\n",
> + p->name);
> + }
> p->found = FALSE;
> }
> break;
> @@ -561,8 +574,10 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
> * hence 100 looks the same as 100% to the caller of sccanf
> */
> if (sscanf(s, "%lf%c", &p->value.realnum, &tmp) != 2 || tmp != '%') {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> "Option \"%s\" requires a percent value\n", p->name);
> + }
> p->found = FALSE;
> } else {
> p->found = TRUE;
> @@ -571,9 +586,11 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
> break;
> case OPTV_FREQ:
> if (*s == '\0') {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires a frequency value\n",
> - p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires a frequency value\n",
> + p->name);
> + }
> p->found = FALSE;
> } else {
> double freq = strtod(s, &end);
> @@ -590,17 +607,21 @@ ParseOptionValue(int scrnIndex, pointer options, OptionInfoPtr p,
> !xf86NameCmp(end, "M"))
> units = 1000000;
> else {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires a frequency value\n",
> - p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires a frequency value\n",
> + p->name);
> + }
> p->found = FALSE;
> }
> if (p->found)
> freq *= (double)units;
> } else {
> - xf86DrvMsg(scrnIndex, X_WARNING,
> - "Option \"%s\" requires a frequency value\n",
> - p->name);
> + if (markUsed) {
> + xf86DrvMsg(scrnIndex, X_WARNING,
> + "Option \"%s\" requires a frequency value\n",
> + p->name);
> + }
> p->found = FALSE;
> }
> if (p->found) {
> --
> 1.7.3.4
>
More information about the xorg-devel
mailing list