diff --git a/Xi/extinit.c b/Xi/extinit.c index 9ebd733ab..26c628cbd 100644 --- a/Xi/extinit.c +++ b/Xi/extinit.c @@ -1169,8 +1169,8 @@ IResetProc(ExtensionEntry * unused) EventSwapVector[DevicePropertyNotify] = NotImplemented; RestoreExtensionEvents(); - free((void *) xi_all_devices.name); - free((void *) xi_all_master_devices.name); + free(xi_all_devices.name); + free(xi_all_master_devices.name); XIBarrierReset(); } diff --git a/Xi/listdev.c b/Xi/listdev.c index 470fb52ee..6a10091d0 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -121,7 +121,7 @@ SizeDeviceInfo(DeviceIntPtr d, int *namesize, int *size) static void CopyDeviceName(char **namebuf, const char *name) { - char *nameptr = (char *) *namebuf; + char *nameptr = *namebuf; if (name) { *nameptr++ = strlen(name); diff --git a/config/udev.c b/config/udev.c index 436b8f038..68ed34843 100644 --- a/config/udev.c +++ b/config/udev.c @@ -242,16 +242,16 @@ device_added(struct udev_device *udev_device) free(config_info); input_option_free_list(&input_options); - free((void *) attrs.usb_id); - free((void *) attrs.pnp_id); - free((void *) attrs.product); - free((void *) attrs.device); - free((void *) attrs.vendor); + free(attrs.usb_id); + free(attrs.pnp_id); + free(attrs.product); + free(attrs.device); + free(attrs.vendor); if (attrs.tags) { - const char **tag = attrs.tags; + char **tag = attrs.tags; while (*tag) { - free((void *) *tag); + free(*tag); tag++; } free(attrs.tags); diff --git a/dix/devices.c b/dix/devices.c index 45de713ce..1c86d5242 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -955,7 +955,7 @@ CloseDevice(DeviceIntPtr dev) while (dev->xkb_interest) XkbRemoveResourceClient((DevicePtr) dev, dev->xkb_interest->resource); - free((void *) dev->name); + free(dev->name); classes = (ClassesPtr) &dev->key; FreeAllDeviceClasses(classes); @@ -1279,6 +1279,7 @@ InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom *labels, BUG_RETURN_VAL(dev == NULL, FALSE); BUG_RETURN_VAL(dev->button != NULL, FALSE); + BUG_RETURN_VAL(numButtons >= MAX_BUTTONS, FALSE); butc = calloc(1, sizeof(ButtonClassRec)); if (!butc) diff --git a/dix/dispatch.c b/dix/dispatch.c index 9a5658db0..4f830f7f4 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -478,9 +478,9 @@ SetVendorRelease(int release) } void -SetVendorString(const char *string) +SetVendorString(const char *vendor) { - VendorString = string; + VendorString = vendor; } Bool diff --git a/dix/getevents.c b/dix/getevents.c index 646c723ea..ffa89fad2 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -1655,6 +1655,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, } #endif + BUG_RETURN_VAL(buttons >= MAX_BUTTONS, 0); + /* refuse events from disabled devices */ if (!pDev->enabled) return 0; diff --git a/dix/inpututils.c b/dix/inpututils.c index 3e1d75fec..e5bcc31f7 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -60,7 +60,8 @@ check_butmap_change(DeviceIntPtr dev, CARD8 *map, int len, CARD32 *errval_out, } for (i = 0; i < len; i++) { - if (dev->button->map[i + 1] != map[i] && dev->button->down[i + 1]) + if (dev->button->map[i + 1] != map[i] && + button_is_down(dev, i + 1, BUTTON_PROCESSED)) return MappingBusy; } @@ -351,7 +352,7 @@ DuplicateInputAttributes(InputAttributes * attrs) { InputAttributes *new_attr; int ntags = 0; - const char **tags, **new_tags; + char **tags, **new_tags; if (!attrs) return NULL; @@ -403,20 +404,20 @@ DuplicateInputAttributes(InputAttributes * attrs) void FreeInputAttributes(InputAttributes * attrs) { - const char **tags; + char **tags; if (!attrs) return; - free((void *) attrs->product); - free((void *) attrs->vendor); - free((void *) attrs->device); - free((void *) attrs->pnp_id); - free((void *) attrs->usb_id); + free(attrs->product); + free(attrs->vendor); + free(attrs->device); + free(attrs->pnp_id); + free(attrs->usb_id); if ((tags = attrs->tags)) while (*tags) - free((void *) *tags++); + free(*tags++); free(attrs->tags); free(attrs); diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 258b22bfe..542d5abf6 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -777,13 +777,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) MessageType from; const char *s; XkbRMLVOSet set; - - /* Default options. */ - set.rules = "base"; - set.model = "pc105"; - set.layout = "us"; - set.variant = NULL; - set.options = NULL; + const char *rules; /* * Merge the ServerLayout and ServerFlags options. The former have @@ -963,9 +957,15 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) * evdev rules set. */ #if defined(linux) if (!xf86Info.forceInputDevices) - set.rules = "evdev"; + rules = "evdev"; + else #endif + rules = "base"; + + /* Xkb default options. */ + XkbInitRules(&set, rules, "pc105", "us", NULL, NULL); XkbSetRulesDflts(&set); + XkbFreeRMLVOSet(&set, FALSE); xf86Info.useDefaultFontPath = TRUE; xf86Info.useDefaultFontPathFrom = X_DEFAULT; diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c index 30dc5505c..967bfbc93 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c @@ -159,8 +159,8 @@ configureInputSection(void) parsePrologue(XF86ConfInputPtr, XF86ConfInputRec) - ptr->inp_identifier = "Keyboard0"; - ptr->inp_driver = "kbd"; + ptr->inp_identifier = xnfstrdup("Keyboard0"); + ptr->inp_driver = xnfstrdup("kbd"); ptr->list.next = NULL; /* Crude mechanism to auto-detect mouse (os dependent) */ @@ -175,17 +175,17 @@ configureInputSection(void) } mouse = calloc(1, sizeof(XF86ConfInputRec)); - mouse->inp_identifier = "Mouse0"; - mouse->inp_driver = "mouse"; + mouse->inp_identifier = xnfstrdup("Mouse0"); + mouse->inp_driver = xnfstrdup("mouse"); mouse->inp_option_lst = - xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"), - strdup(DFLT_MOUSE_PROTO)); + xf86addNewOption(mouse->inp_option_lst, xnfstrdup("Protocol"), + xnfstrdup(DFLT_MOUSE_PROTO)); mouse->inp_option_lst = - xf86addNewOption(mouse->inp_option_lst, strdup("Device"), - strdup(DFLT_MOUSE_DEV)); + xf86addNewOption(mouse->inp_option_lst, xnfstrdup("Device"), + xnfstrdup(DFLT_MOUSE_DEV)); mouse->inp_option_lst = - xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"), - strdup("4 5 6 7")); + xf86addNewOption(mouse->inp_option_lst, xnfstrdup("ZAxisMapping"), + xnfstrdup("4 5 6 7")); ptr = (XF86ConfInputPtr) xf86addListItem((glp) ptr, (glp) mouse); return ptr; } @@ -290,7 +290,7 @@ configureDeviceSection(int screennum) " ### : \"String\", : \" Hz/kHz/MHz\",\n" " ### : \"%\"\n" " ### [arg]: arg optional\n"; - ptr->dev_comment = strdup(descrip); + ptr->dev_comment = xnfstrdup(descrip); if (ptr->dev_comment) { for (p = DevToConfig[screennum].GDev.options; p->name != NULL; p++) { char *p_e; @@ -337,9 +337,9 @@ configureLayoutSection(void) iptr = malloc(sizeof(XF86ConfInputrefRec)); iptr->list.next = NULL; iptr->iref_option_lst = NULL; - iptr->iref_inputdev_str = "Mouse0"; + iptr->iref_inputdev_str = xnfstrdup("Mouse0"); iptr->iref_option_lst = - xf86addNewOption(iptr->iref_option_lst, strdup("CorePointer"), + xf86addNewOption(iptr->iref_option_lst, xnfstrdup("CorePointer"), NULL); ptr->lay_input_lst = (XF86ConfInputrefPtr) xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr); @@ -351,9 +351,9 @@ configureLayoutSection(void) iptr = malloc(sizeof(XF86ConfInputrefRec)); iptr->list.next = NULL; iptr->iref_option_lst = NULL; - iptr->iref_inputdev_str = "Keyboard0"; + iptr->iref_inputdev_str = xnfstrdup("Keyboard0"); iptr->iref_option_lst = - xf86addNewOption(iptr->iref_option_lst, strdup("CoreKeyboard"), + xf86addNewOption(iptr->iref_option_lst, xnfstrdup("CoreKeyboard"), NULL); ptr->lay_input_lst = (XF86ConfInputrefPtr) xf86addListItem((glp) ptr->lay_input_lst, (glp) iptr); @@ -431,9 +431,9 @@ configureFilesSection(void) parsePrologue(XF86ConfFilesPtr, XF86ConfFilesRec) if (xf86ModulePath) - ptr->file_modulepath = strdup(xf86ModulePath); + ptr->file_modulepath = xnfstrdup(xf86ModulePath); if (defaultFontPath) - ptr->file_fontpath = strdup(defaultFontPath); + ptr->file_fontpath = xnfstrdup(defaultFontPath); return ptr; } @@ -446,8 +446,8 @@ configureMonitorSection(int screennum) XNFasprintf(&tmp, "Monitor%d", screennum); ptr->mon_identifier = tmp; - ptr->mon_vendor = strdup("Monitor Vendor"); - ptr->mon_modelname = strdup("Monitor Model"); + ptr->mon_vendor = xnfstrdup("Monitor Vendor"); + ptr->mon_modelname = xnfstrdup("Monitor Model"); return ptr; } @@ -491,7 +491,7 @@ configureDDCMonitorSection(int screennum) XNFasprintf(&tmp, "Monitor%d", screennum); ptr->mon_identifier = tmp; - ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name); + ptr->mon_vendor = xnfstrdup(ConfiguredMonitor->vendor.name); XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id); /* features in centimetres, we want millimetres */ @@ -529,7 +529,7 @@ configureDDCMonitorSection(int screennum) if (ConfiguredMonitor->features.dpms) { ptr->mon_option_lst = - xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL); + xf86addNewOption(ptr->mon_option_lst, xnfstrdup("DPMS"), NULL); } return ptr; diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 3a0151374..f6f2b90dd 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -539,7 +539,7 @@ MatchAttrToken(const char *attr, struct xorg_list *patterns, * match. Each list entry is a separate Match line of the same type. */ xorg_list_for_each_entry(group, patterns, entry) { - const char *const *cur; + char *const *cur; Bool match = FALSE; for (cur = group->values; *cur; cur++) @@ -598,7 +598,7 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev, * See if any of the device's tags match any of the MatchTag tokens. */ if (!xorg_list_is_empty(&iclass->match_tag)) { - const char *const *tag; + char *const *tag; Bool match; if (!attrs->tags) diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h index f94261a01..b6d125128 100644 --- a/hw/xfree86/common/xf86Xinput.h +++ b/hw/xfree86/common/xf86Xinput.h @@ -82,8 +82,8 @@ typedef struct _InputDriverRec { typedef struct _InputInfoRec { struct _InputInfoRec *next; - const char *name; - const char *driver; + char *name; + char *driver; int flags; diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c index 24a124691..c2fbd22a7 100644 --- a/hw/xfree86/parser/InputClass.c +++ b/hw/xfree86/parser/InputClass.c @@ -63,7 +63,7 @@ xf86ConfigSymTabRec InputClassTab[] = { #define TOKEN_SEP "|" static void -add_group_entry(struct xorg_list *head, const char **values) +add_group_entry(struct xorg_list *head, char **values) { xf86MatchGroup *group; @@ -256,7 +256,7 @@ void xf86printInputClassSection(FILE * cf, XF86ConfInputClassPtr ptr) { const xf86MatchGroup *group; - const char *const *cur; + char *const *cur; while (ptr) { fprintf(cf, "Section \"InputClass\"\n"); @@ -362,7 +362,7 @@ xf86freeInputClassList(XF86ConfInputClassPtr ptr) while (ptr) { xf86MatchGroup *group, *next; - const char **list; + char **list; TestFree(ptr->identifier); TestFree(ptr->driver); @@ -370,55 +370,55 @@ xf86freeInputClassList(XF86ConfInputClassPtr ptr) xorg_list_for_each_entry_safe(group, next, &ptr->match_product, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } xorg_list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } xorg_list_for_each_entry_safe(group, next, &ptr->match_device, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } xorg_list_for_each_entry_safe(group, next, &ptr->match_os, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } xorg_list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } xorg_list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } xorg_list_for_each_entry_safe(group, next, &ptr->match_driver, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } xorg_list_for_each_entry_safe(group, next, &ptr->match_tag, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } xorg_list_for_each_entry_safe(group, next, &ptr->match_layout, entry) { xorg_list_del(&group->entry); for (list = group->values; *list; list++) - free((void *) *list); + free(*list); free(group); } diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h index 83607f26c..8f855ac09 100644 --- a/hw/xfree86/parser/xf86Parser.h +++ b/hw/xfree86/parser/xf86Parser.h @@ -279,8 +279,8 @@ typedef struct { typedef struct { GenericListRec list; - const char *inp_identifier; - const char *inp_driver; + char *inp_identifier; + char *inp_driver; XF86OptionPtr inp_option_lst; char *inp_comment; } XF86ConfInputRec, *XF86ConfInputPtr; @@ -288,7 +288,7 @@ typedef struct { typedef struct { GenericListRec list; XF86ConfInputPtr iref_inputdev; - const char *iref_inputdev_str; + char *iref_inputdev_str; XF86OptionPtr iref_option_lst; } XF86ConfInputrefRec, *XF86ConfInputrefPtr; @@ -299,13 +299,13 @@ typedef struct { typedef struct { struct xorg_list entry; - const char **values; + char **values; } xf86MatchGroup; typedef struct { GenericListRec list; char *identifier; - const char *driver; + char *driver; struct xorg_list match_product; struct xorg_list match_vendor; struct xorg_list match_device; diff --git a/include/input.h b/include/input.h index 455963f6a..93c45107d 100644 --- a/include/input.h +++ b/include/input.h @@ -95,8 +95,8 @@ SOFTWARE. #define NO_AXIS_LIMITS -1 -#define MAP_LENGTH 256 -#define DOWN_LENGTH 32 /* 256/8 => number of bytes to hold 256 bits */ +#define MAP_LENGTH MAX_BUTTONS +#define DOWN_LENGTH (MAX_BUTTONS/8) /* 256/8 => number of bytes to hold 256 bits */ #define NullGrab ((GrabPtr)NULL) #define PointerRootWin ((WindowPtr)PointerRoot) #define NoneWin ((WindowPtr)None) @@ -221,12 +221,12 @@ typedef struct _InputOption InputOption; typedef struct _XI2Mask XI2Mask; typedef struct _InputAttributes { - const char *product; - const char *vendor; - const char *device; - const char *pnp_id; - const char *usb_id; - const char **tags; /* null-terminated */ + char *product; + char *vendor; + char *device; + char *pnp_id; + char *usb_id; + char **tags; /* null-terminated */ uint32_t flags; } InputAttributes; diff --git a/include/inputstr.h b/include/inputstr.h index dfcf7c383..f6cfb049d 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -542,7 +542,7 @@ typedef struct _DeviceIntRec { GrabInfoRec deviceGrab; /* grab on the device */ int type; /* MASTER_POINTER, MASTER_KEYBOARD, SLAVE */ Atom xinput_type; - const char *name; + char *name; int id; KeyClassPtr key; ValuatorClassPtr valuator; diff --git a/include/misc.h b/include/misc.h index 165d42e85..17de71041 100644 --- a/include/misc.h +++ b/include/misc.h @@ -246,7 +246,7 @@ padding_for_int32(const int bytes) } -extern const char **xstrtokenize(const char *str, const char *separators); +extern char **xstrtokenize(const char *str, const char *separators); extern void FormatInt64(int64_t num, char *string); extern void FormatUInt64(uint64_t num, char *string); extern void FormatUInt64Hex(uint64_t num, char *string); diff --git a/include/xkbrules.h b/include/xkbrules.h index 956eade0b..ab5b4b266 100644 --- a/include/xkbrules.h +++ b/include/xkbrules.h @@ -30,11 +30,11 @@ /***====================================================================***/ typedef struct _XkbRMLVOSet { - const char *rules; - const char *model; - const char *layout; - const char *variant; - const char *options; + char *rules; + char *model; + char *layout; + char *variant; + char *options; } XkbRMLVOSet; typedef struct _XkbRF_VarDefs { diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 0b9ca06d9..e79979927 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -738,6 +738,14 @@ extern _X_EXPORT void XkbClearAllLatchesAndLocks(DeviceIntPtr /* dev */ , XkbEventCausePtr /* cause */ ); +extern _X_EXPORT void XkbInitRules(XkbRMLVOSet * /* rmlvo */, + const char * /* rules */, + const char * /* model */, + const char * /* layout */, + const char * /* variant */, + const char * /* options */ + ) ; + extern _X_EXPORT void XkbGetRulesDflts(XkbRMLVOSet * /* rmlvo */ ); diff --git a/mi/mieq.c b/mi/mieq.c index bc7f94523..36aa21357 100644 --- a/mi/mieq.c +++ b/mi/mieq.c @@ -286,7 +286,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e) else if (miEventQueue.dropped % QUEUE_DROP_BACKTRACE_FREQUENCY == 0 && miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY <= QUEUE_DROP_BACKTRACE_MAX) { - ErrorFSigSafe("[mi] EQ overflow continuing. %u events have been " + ErrorFSigSafe("[mi] EQ overflow continuing. %zu events have been " "dropped.\n", miEventQueue.dropped); if (miEventQueue.dropped / QUEUE_DROP_BACKTRACE_FREQUENCY == QUEUE_DROP_BACKTRACE_MAX) { diff --git a/os/utils.c b/os/utils.c index dc18a67b1..497779b52 100644 --- a/os/utils.c +++ b/os/utils.c @@ -1973,10 +1973,10 @@ CheckUserAuthorization(void) * Tokenize a string into a NULL terminated array of strings. Always returns * an allocated array unless an error occurs. */ -const char ** +char ** xstrtokenize(const char *str, const char *separators) { - const char **list, **nlist; + char **list, **nlist; char *tok, *tmp; unsigned num = 0, n; @@ -2004,7 +2004,7 @@ xstrtokenize(const char *str, const char *separators) error: free(tmp); for (n = 0; n < num; n++) - free((void *) list[n]); + free(list[n]); free(list); return NULL; } diff --git a/test/input.c b/test/input.c index aaa7a69d3..5813e6dc9 100644 --- a/test/input.c +++ b/test/input.c @@ -1101,7 +1101,7 @@ xi_unregister_handlers(void) static void cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2) { - const char **tags1, **tags2; + char **tags1, **tags2; assert(attr1 && attr2); assert(attr1 != attr2); @@ -1180,50 +1180,54 @@ cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2) static void dix_input_attributes(void) { - InputAttributes orig = { 0 }; + InputAttributes *orig; InputAttributes *new; - const char *tags[4] = { "tag1", "tag2", "tag2", NULL }; new = DuplicateInputAttributes(NULL); assert(!new); - new = DuplicateInputAttributes(&orig); - assert(memcmp(&orig, new, sizeof(InputAttributes)) == 0); + orig = calloc(1, sizeof(InputAttributes)); + assert(orig); - orig.product = "product name"; - new = DuplicateInputAttributes(&orig); - cmp_attr_fields(&orig, new); + new = DuplicateInputAttributes(orig); + assert(memcmp(orig, new, sizeof(InputAttributes)) == 0); + + orig->product = xnfstrdup("product name"); + new = DuplicateInputAttributes(orig); + cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig.vendor = "vendor name"; - new = DuplicateInputAttributes(&orig); - cmp_attr_fields(&orig, new); + orig->vendor = xnfstrdup("vendor name"); + new = DuplicateInputAttributes(orig); + cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig.device = "device path"; - new = DuplicateInputAttributes(&orig); - cmp_attr_fields(&orig, new); + orig->device = xnfstrdup("device path"); + new = DuplicateInputAttributes(orig); + cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig.pnp_id = "PnPID"; - new = DuplicateInputAttributes(&orig); - cmp_attr_fields(&orig, new); + orig->pnp_id = xnfstrdup("PnPID"); + new = DuplicateInputAttributes(orig); + cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig.usb_id = "USBID"; - new = DuplicateInputAttributes(&orig); - cmp_attr_fields(&orig, new); + orig->usb_id = xnfstrdup("USBID"); + new = DuplicateInputAttributes(orig); + cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig.flags = 0xF0; - new = DuplicateInputAttributes(&orig); - cmp_attr_fields(&orig, new); + orig->flags = 0xF0; + new = DuplicateInputAttributes(orig); + cmp_attr_fields(orig, new); FreeInputAttributes(new); - orig.tags = tags; - new = DuplicateInputAttributes(&orig); - cmp_attr_fields(&orig, new); + orig->tags = xstrtokenize("tag1 tag2 tag3", " "); + new = DuplicateInputAttributes(orig); + cmp_attr_fields(orig, new); FreeInputAttributes(new); + + FreeInputAttributes(orig); } static void diff --git a/test/touch.c b/test/touch.c index df1db11de..981c694b6 100644 --- a/test/touch.c +++ b/test/touch.c @@ -40,7 +40,7 @@ touch_grow_queue(void) int i; memset(&dev, 0, sizeof(dev)); - dev.name = "test device"; + dev.name = xnfstrdup("test device"); dev.id = 2; dev.valuator = &val; val.numAxes = 5; @@ -82,6 +82,8 @@ touch_grow_queue(void) assert(t->client_id == 0); assert(t->ddx_id == 0); } + + free(dev.name); } static void @@ -95,7 +97,7 @@ touch_find_ddxid(void) int i; memset(&dev, 0, sizeof(dev)); - dev.name = "test device"; + dev.name = xnfstrdup("test device"); dev.id = 2; dev.valuator = &val; val.numAxes = 5; @@ -150,6 +152,8 @@ touch_find_ddxid(void) ProcessWorkQueue(); ti = TouchFindByDDXID(&dev, 40, TRUE); assert(ti == &dev.last.touches[size]); + + free(dev.name); } static void @@ -164,7 +168,7 @@ touch_begin_ddxtouch(void) int size = 5; memset(&dev, 0, sizeof(dev)); - dev.name = "test device"; + dev.name = xnfstrdup("test device"); dev.id = 2; dev.valuator = &val; val.numAxes = 5; @@ -195,6 +199,8 @@ touch_begin_ddxtouch(void) assert(ti->client_id > last_client_id); assert(!ti->emulate_pointer); last_client_id = ti->client_id; + + free(dev.name); } static void @@ -212,7 +218,7 @@ touch_begin_touch(void) screenInfo.screens[0] = &screen; memset(&dev, 0, sizeof(dev)); - dev.name = "test device"; + dev.name = xnfstrdup("test device"); dev.id = 2; memset(&sprite, 0, sizeof(sprite)); @@ -237,6 +243,8 @@ touch_begin_touch(void) assert(ti->emulate_pointer); assert(touch.num_touches == 1); + + free(dev.name); } static void @@ -251,7 +259,7 @@ touch_init(void) screenInfo.screens[0] = &screen; memset(&dev, 0, sizeof(dev)); - dev.name = "test device"; + dev.name = xnfstrdup("test device"); memset(&sprite, 0, sizeof(sprite)); dev.spriteInfo = &sprite; @@ -264,6 +272,8 @@ touch_init(void) rc = InitTouchClassDeviceStruct(&dev, 1, XIDirectTouch, 2); assert(rc == TRUE); assert(dev.touch); + + free(dev.name); } int diff --git a/test/xkb.c b/test/xkb.c index 955e72dff..9047f594c 100644 --- a/test/xkb.c +++ b/test/xkb.c @@ -82,15 +82,17 @@ xkb_get_rules_test(void) static void xkb_set_rules_test(void) { - XkbRMLVOSet rmlvo = { - .rules = "test-rules", - .model = "test-model", - .layout = "test-layout", - .variant = "test-variant", - .options = "test-options" - }; + XkbRMLVOSet rmlvo; XkbRMLVOSet rmlvo_new = { NULL }; + XkbInitRules(&rmlvo, "test-rules", "test-model", "test-layout", + "test-variant", "test-options"); + assert(rmlvo.rules); + assert(rmlvo.model); + assert(rmlvo.layout); + assert(rmlvo.variant); + assert(rmlvo.options); + XkbSetRulesDflts(&rmlvo); XkbGetRulesDflts(&rmlvo_new); @@ -106,6 +108,8 @@ xkb_set_rules_test(void) assert(strcmp(rmlvo.layout, rmlvo_new.layout) == 0); assert(strcmp(rmlvo.variant, rmlvo_new.variant) == 0); assert(strcmp(rmlvo.options, rmlvo_new.options) == 0); + + XkbFreeRMLVOSet(&rmlvo, FALSE); } /** diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index 22b971fc6..33420b6b6 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -129,11 +129,11 @@ XkbFreeRMLVOSet(XkbRMLVOSet * rmlvo, Bool freeRMLVO) if (!rmlvo) return; - free((void *) rmlvo->rules); - free((void *) rmlvo->model); - free((void *) rmlvo->layout); - free((void *) rmlvo->variant); - free((void *) rmlvo->options); + free(rmlvo->rules); + free(rmlvo->model); + free(rmlvo->layout); + free(rmlvo->variant); + free(rmlvo->options); if (freeRMLVO) free(rmlvo); @@ -206,6 +206,21 @@ XkbWriteRulesProp(ClientPtr client, void *closure) return TRUE; } +void +XkbInitRules(XkbRMLVOSet *rmlvo, + const char *rules, + const char *model, + const char *layout, + const char *variant, + const char *options) +{ + rmlvo->rules = rules ? xnfstrdup(rules) : NULL; + rmlvo->model = model ? xnfstrdup(model) : NULL; + rmlvo->layout = layout ? xnfstrdup(layout) : NULL; + rmlvo->variant = variant ? xnfstrdup(variant) : NULL; + rmlvo->options = options ? xnfstrdup(options) : NULL; +} + static void XkbSetRulesUsed(XkbRMLVOSet * rmlvo) {