Merge remote-tracking branch 'whot/for-keith'

This commit is contained in:
Keith Packard 2011-10-30 16:57:58 -07:00
commit 132545ff57
7 changed files with 60 additions and 19 deletions

View File

@ -985,6 +985,8 @@ CloseDownDevices(void)
{ {
DeviceIntPtr dev; DeviceIntPtr dev;
OsBlockSignals();
/* Float all SDs before closing them. Note that at this point resources /* Float all SDs before closing them. Note that at this point resources
* (e.g. cursors) have been freed already, so we can't just call * (e.g. cursors) have been freed already, so we can't just call
* AttachDevice(NULL, dev, NULL). Instead, we have to forcibly set master * AttachDevice(NULL, dev, NULL). Instead, we have to forcibly set master
@ -1007,6 +1009,8 @@ CloseDownDevices(void)
inputInfo.keyboard = NULL; inputInfo.keyboard = NULL;
inputInfo.pointer = NULL; inputInfo.pointer = NULL;
XkbDeleteRulesDflts(); XkbDeleteRulesDflts();
OsReleaseSignals();
} }
/** /**

View File

@ -910,35 +910,38 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
return BadAlloc; return BadAlloc;
nt_list_for_each_entry(option, options, list.next) { nt_list_for_each_entry(option, options, list.next) {
if (strcasecmp(input_option_get_key(option), "driver") == 0) { const char *key = input_option_get_key(option);
const char *value = input_option_get_value(option);
if (strcasecmp(key, "driver") == 0) {
if (pInfo->driver) { if (pInfo->driver) {
rval = BadRequest; rval = BadRequest;
goto unwind; goto unwind;
} }
pInfo->driver = xstrdup(input_option_get_value(option)); pInfo->driver = xstrdup(value);
if (!pInfo->driver) { if (!pInfo->driver) {
rval = BadAlloc; rval = BadAlloc;
goto unwind; goto unwind;
} }
} }
if (strcasecmp(input_option_get_key(option), "name") == 0 || if (strcasecmp(key, "name") == 0 ||
strcasecmp(input_option_get_key(option), "identifier") == 0) { strcasecmp(key, "identifier") == 0) {
if (pInfo->name) { if (pInfo->name) {
rval = BadRequest; rval = BadRequest;
goto unwind; goto unwind;
} }
pInfo->name = xstrdup(input_option_get_value(option)); pInfo->name = xstrdup(value);
if (!pInfo->name) { if (!pInfo->name) {
rval = BadAlloc; rval = BadAlloc;
goto unwind; goto unwind;
} }
} }
if (strcmp(input_option_get_key(option), "_source") == 0 && if (strcmp(key, "_source") == 0 &&
(strcmp(input_option_get_value(option), "server/hal") == 0 || (strcmp(value, "server/hal") == 0 ||
strcmp(input_option_get_value(option), "server/udev") == 0 || strcmp(value, "server/udev") == 0 ||
strcmp(input_option_get_value(option), "server/wscons") == 0)) { strcmp(value, "server/wscons") == 0)) {
is_auto = 1; is_auto = 1;
if (!xf86Info.autoAddDevices) { if (!xf86Info.autoAddDevices) {
rval = BadMatch; rval = BadMatch;

View File

@ -1093,7 +1093,7 @@ char *
xf86addComment(char *cur, char *add) xf86addComment(char *cur, char *add)
{ {
char *str; char *str;
int len, curlen, iscomment, hasnewline = 0, endnewline; int len, curlen, iscomment, hasnewline = 0, insnewline, endnewline;
if (add == NULL || add[0] == '\0') if (add == NULL || add[0] == '\0')
return cur; return cur;
@ -1118,14 +1118,23 @@ xf86addComment(char *cur, char *add)
len = strlen(add); len = strlen(add);
endnewline = add[len - 1] == '\n'; endnewline = add[len - 1] == '\n';
len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen;
if ((str = realloc(cur, len + curlen)) == NULL) insnewline = eol_seen || (curlen && !hasnewline);
if (insnewline)
len++;
if (!iscomment)
len++;
if (!endnewline)
len++;
/* Allocate + 1 char for '\0' terminator. */
str = realloc(cur, curlen + len + 1);
if (!str)
return cur; return cur;
cur = str; cur = str;
if (eol_seen || (curlen && !hasnewline)) if (insnewline)
cur[curlen++] = '\n'; cur[curlen++] = '\n';
if (!iscomment) if (!iscomment)
cur[curlen++] = '#'; cur[curlen++] = '#';

View File

@ -29,6 +29,7 @@
#include "xf86.h" #include "xf86.h"
#include "xf86Parser.h"
static void static void
xfree86_option_list_duplicate(void) xfree86_option_list_duplicate(void)
@ -73,9 +74,34 @@ xfree86_option_list_duplicate(void)
assert(a && b); assert(a && b);
} }
static void
xfree86_add_comment(void)
{
char *current = NULL, *comment;
char compare[1024] = {0};
comment = "# foo";
current = xf86addComment(current, comment);
strcpy(compare, comment);
strcat(compare, "\n");
assert(!strcmp(current, compare));
/* this used to overflow */
strcpy(current, "\n");
comment = "foobar\n";
current = xf86addComment(current, comment);
strcpy(compare, "\n#");
strcat(compare, comment);
assert(!strcmp(current, compare));
free(current);
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
xfree86_option_list_duplicate(); xfree86_option_list_duplicate();
xfree86_add_comment();
return 0; return 0;
} }

View File

@ -108,6 +108,7 @@ TestPointerProc(DeviceIntPtr pDev, int what)
pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2; pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
pDev->last.valuators[1] = pDev->valuator->axisVal[1]; pDev->last.valuators[1] = pDev->valuator->axisVal[1];
/* protocol-xiquerydevice.c relies on these increment */
SetScrollValuator(pDev, 2, SCROLL_TYPE_VERTICAL, 2.4, SCROLL_FLAG_NONE); SetScrollValuator(pDev, 2, SCROLL_TYPE_VERTICAL, 2.4, SCROLL_FLAG_NONE);
SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5, SCROLL_FLAG_PREFERRED); SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5, SCROLL_FLAG_PREFERRED);
break; break;

View File

@ -389,9 +389,7 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
{ {
FP3232 vi, vo; FP3232 vi, vo;
vi.integral = trunc(in->valuators.data[i]); vi = double_to_fp3232(in->valuators.data[i]);
vi.frac = (in->valuators.data[i] - vi.integral) * (1UL << 32);
vo = *values; vo = *values;
if (swap) if (swap)

View File

@ -213,9 +213,9 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void
} }
assert(si->increment.integral == si->number); assert(si->increment.integral == si->number);
/* FIXME: frac testing with float/FP issues? */ /* protocol-common.c sets up increments of 2.4 and 3.5 */
assert(si->increment.frac > 0.3 * (1UL << 32)); assert(si->increment.frac > 0.3 * (1ULL << 32));
assert(si->increment.frac < 0.6 * (1UL << 32)); assert(si->increment.frac < 0.6 * (1ULL << 32));
} }
} }