xkb: use new macros for byte swapping in network buffers
Use the new macros for doing byte-swapping in network buffer structs which aren't requests or reply structs. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
1425d94daa
commit
f1c658e581
145
xkb/xkb.c
145
xkb/xkb.c
|
@ -2102,11 +2102,7 @@ SetKeySyms(ClientPtr client,
|
|||
for (s = 0; s < wire->nSyms; s++) {
|
||||
newSyms[s] = pSyms[s];
|
||||
}
|
||||
if (client->swapped) {
|
||||
for (s = 0; s < wire->nSyms; s++) {
|
||||
swapl(&newSyms[s]);
|
||||
}
|
||||
}
|
||||
REQUEST_BUF_CARD32(newSyms, wire->nSyms);
|
||||
}
|
||||
if (XkbKeyHasActions(xkb, i + req->firstKeySym))
|
||||
XkbResizeKeyActions(xkb, i + req->firstKeySym,
|
||||
|
@ -2835,9 +2831,7 @@ XkbAssembleCompatMap(ClientPtr client,
|
|||
wire->flags = sym->flags;
|
||||
memcpy((char *) &wire->act, (char *) &sym->act,
|
||||
sz_xkbActionWireDesc);
|
||||
if (client->swapped) {
|
||||
swapl(&wire->sym);
|
||||
}
|
||||
CLIENT_STRUCT_CARD32_1(wire, sym);
|
||||
}
|
||||
if (rep.groups) {
|
||||
grp = (xkbModsWireDesc *) wire;
|
||||
|
@ -2846,9 +2840,7 @@ XkbAssembleCompatMap(ClientPtr client,
|
|||
grp->mask = compat->groups[i].mask;
|
||||
grp->realMods = compat->groups[i].real_mods;
|
||||
grp->virtualMods = compat->groups[i].vmods;
|
||||
if (client->swapped) {
|
||||
swaps(&grp->virtualMods);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_1(grp, virtualMods);
|
||||
grp++;
|
||||
}
|
||||
}
|
||||
|
@ -2978,9 +2970,7 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev,
|
|||
}
|
||||
sym = &compat->sym_interpret[req->firstSI];
|
||||
for (i = 0; i < req->nSI; i++, wire++) {
|
||||
if (client->swapped) {
|
||||
swapl(&wire->sym);
|
||||
}
|
||||
CLIENT_STRUCT_CARD32_1(wire, sym);
|
||||
if (wire->sym == NoSymbol && wire->match == XkbSI_AnyOfOrNone &&
|
||||
(wire->mods & 0xff) == 0xff &&
|
||||
wire->act.type == XkbSA_XFree86Private) {
|
||||
|
@ -3200,10 +3190,8 @@ XkbAssembleIndicatorMap(ClientPtr client,
|
|||
wire->realMods = indicators->maps[i].mods.real_mods;
|
||||
wire->virtualMods = indicators->maps[i].mods.vmods;
|
||||
wire->ctrls = indicators->maps[i].ctrls;
|
||||
if (client->swapped) {
|
||||
swaps(&wire->virtualMods);
|
||||
swapl(&wire->ctrls);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_1(wire, virtualMods);
|
||||
CLIENT_STRUCT_CARD32_1(wire, ctrls);
|
||||
wire++;
|
||||
}
|
||||
}
|
||||
|
@ -3329,10 +3317,8 @@ ProcXkbSetIndicatorMap(ClientPtr client)
|
|||
from = (xkbIndicatorMapWireDesc *) &stuff[1];
|
||||
for (i = 0, bit = 1; i < XkbNumIndicators; i++, bit <<= 1) {
|
||||
if (stuff->which & bit) {
|
||||
if (client->swapped) {
|
||||
swaps(&from->virtualMods);
|
||||
swapl(&from->ctrls);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_1(from, virtualMods);
|
||||
CLIENT_STRUCT_CARD32_1(from, ctrls);
|
||||
CHK_MASK_LEGAL(i, from->whichGroups, XkbIM_UseAnyGroup);
|
||||
CHK_MASK_LEGAL(i, from->whichMods, XkbIM_UseAnyMods);
|
||||
from++;
|
||||
|
@ -5042,12 +5028,8 @@ _CheckSetDoodad(char **wire_inout, xkbSetGeometryReq *req,
|
|||
|
||||
any = dWire->any;
|
||||
wire = (char *) &dWire[1];
|
||||
if (client->swapped) {
|
||||
swapl(&any.name);
|
||||
swaps(&any.top);
|
||||
swaps(&any.left);
|
||||
swaps(&any.angle);
|
||||
}
|
||||
CLIENT_STRUCT_CARD32_1(&any, name);
|
||||
CLIENT_STRUCT_CARD16_3(&any, top, left, angle);
|
||||
CHK_ATOM_ONLY(dWire->any.name);
|
||||
doodad = XkbAddGeomDoodad(geom, section, any.name);
|
||||
if (!doodad)
|
||||
|
@ -5156,9 +5138,8 @@ _CheckSetOverlay(char **wire_inout, xkbSetGeometryReq *req,
|
|||
if (!_XkbCheckRequestBounds(client, req, olWire, olWire + 1))
|
||||
return BadLength;
|
||||
|
||||
if (client->swapped) {
|
||||
swapl(&olWire->name);
|
||||
}
|
||||
CLIENT_STRUCT_CARD32_1(olWire, name);
|
||||
|
||||
CHK_ATOM_ONLY(olWire->name);
|
||||
ol = XkbAddGeomOverlay(section, olWire->name, olWire->nRows);
|
||||
rWire = (xkbOverlayRowWireDesc *) &olWire[1];
|
||||
|
@ -5217,14 +5198,9 @@ _CheckSetSections(XkbGeometryPtr geom,
|
|||
if (!_XkbCheckRequestBounds(client, req, sWire, sWire + 1))
|
||||
return BadLength;
|
||||
|
||||
if (client->swapped) {
|
||||
swapl(&sWire->name);
|
||||
swaps(&sWire->top);
|
||||
swaps(&sWire->left);
|
||||
swaps(&sWire->width);
|
||||
swaps(&sWire->height);
|
||||
swaps(&sWire->angle);
|
||||
}
|
||||
CLIENT_STRUCT_CARD32_1(sWire, name);
|
||||
CLIENT_STRUCT_CARD16_5(sWire, top, left, width, height, angle);
|
||||
|
||||
CHK_ATOM_ONLY(sWire->name);
|
||||
section = XkbAddGeomSection(geom, sWire->name, sWire->nRows,
|
||||
sWire->nDoodads, sWire->nOverlays);
|
||||
|
@ -6043,13 +6019,11 @@ ProcXkbGetKbdByName(ClientPtr client)
|
|||
char *buf = payload_walk + sizeof(mrep);
|
||||
XkbAssembleMap(client, xkb, mrep, buf);
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&mrep.sequenceNumber);
|
||||
swapl(&mrep.length);
|
||||
swaps(&mrep.present);
|
||||
swaps(&mrep.totalSyms);
|
||||
swaps(&mrep.totalActs);
|
||||
}
|
||||
// note: we must set payload size and swap the standard header fields ourselves
|
||||
CLIENT_STRUCT_CARD32_1(&mrep, length);
|
||||
CLIENT_STRUCT_CARD16_1(&mrep, sequenceNumber);
|
||||
|
||||
CLIENT_STRUCT_CARD16_3(&mrep, present, totalSyms, totalActs);
|
||||
|
||||
memcpy(payload_walk, &mrep, sizeof(mrep));
|
||||
payload_walk = buf + (mrep.length * 4) - (sizeof(mrep) - sizeof(xGenericReply));
|
||||
|
@ -6059,13 +6033,11 @@ ProcXkbGetKbdByName(ClientPtr client)
|
|||
char *buf = payload_walk + sizeof(crep);
|
||||
XkbAssembleCompatMap(client, new->compat, crep, buf);
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&crep.sequenceNumber);
|
||||
swapl(&crep.length);
|
||||
swaps(&crep.firstSI);
|
||||
swaps(&crep.nSI);
|
||||
swaps(&crep.nTotalSI);
|
||||
}
|
||||
// note: we must set payload size and swap the standard header fields ourselves
|
||||
CLIENT_STRUCT_CARD32_1(&crep, length);
|
||||
CLIENT_STRUCT_CARD16_1(&crep, sequenceNumber);
|
||||
|
||||
CLIENT_STRUCT_CARD16_3(&crep, firstSI, nSI, nTotalSI);
|
||||
|
||||
memcpy(payload_walk, &crep, sizeof(crep));
|
||||
payload_walk = buf + (crep.length * 4) - (sizeof(crep) - sizeof(xGenericReply));
|
||||
|
@ -6075,12 +6047,11 @@ ProcXkbGetKbdByName(ClientPtr client)
|
|||
char *buf = payload_walk + sizeof(irep);
|
||||
XkbAssembleIndicatorMap(client, new->indicators, irep, buf);
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&irep.sequenceNumber);
|
||||
swapl(&irep.length);
|
||||
swapl(&irep.which);
|
||||
swapl(&irep.realIndicators);
|
||||
}
|
||||
// note: we must set payload size and swap the standard header fields ourselves
|
||||
CLIENT_STRUCT_CARD32_1(&irep, length);
|
||||
CLIENT_STRUCT_CARD16_1(&irep, sequenceNumber);
|
||||
|
||||
CLIENT_STRUCT_CARD32_2(&irep, which, realIndicators);
|
||||
|
||||
memcpy(payload_walk, &irep, sizeof(irep));
|
||||
payload_walk = buf + (irep.length * 4) - (sizeof(irep) - sizeof(xGenericReply));
|
||||
|
@ -6090,13 +6061,12 @@ ProcXkbGetKbdByName(ClientPtr client)
|
|||
char *buf = payload_walk + sizeof(nrep);
|
||||
XkbAssembleNames(client, new, nrep, buf);
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&nrep.sequenceNumber);
|
||||
swapl(&nrep.length);
|
||||
swapl(&nrep.which);
|
||||
swaps(&nrep.virtualMods);
|
||||
swapl(&nrep.indicators);
|
||||
}
|
||||
// note: we must set payload size and swap the standard header fields ourselves
|
||||
CLIENT_STRUCT_CARD32_1(&nrep, length);
|
||||
CLIENT_STRUCT_CARD16_1(&nrep, sequenceNumber);
|
||||
CLIENT_STRUCT_CARD32_2(&nrep, which, indicators);
|
||||
|
||||
CLIENT_STRUCT_CARD16_1(&nrep, virtualMods);
|
||||
|
||||
memcpy(payload_walk, &nrep, sizeof(nrep));
|
||||
payload_walk = buf + (nrep.length * 4) - (sizeof(nrep) - sizeof(xGenericReply));
|
||||
|
@ -6106,19 +6076,13 @@ ProcXkbGetKbdByName(ClientPtr client)
|
|||
char *buf = payload_walk + sizeof(grep);
|
||||
XkbAssembleGeometry(client, new->geom, grep, buf);
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&grep.sequenceNumber);
|
||||
swapl(&grep.length);
|
||||
swapl(&grep.name);
|
||||
swaps(&grep.widthMM);
|
||||
swaps(&grep.heightMM);
|
||||
swaps(&grep.nProperties);
|
||||
swaps(&grep.nColors);
|
||||
swaps(&grep.nShapes);
|
||||
swaps(&grep.nSections);
|
||||
swaps(&grep.nDoodads);
|
||||
swaps(&grep.nKeyAliases);
|
||||
}
|
||||
// note: we must set payload size and swap the standard header fields ourselves
|
||||
CLIENT_STRUCT_CARD32_1(&grep, length);
|
||||
CLIENT_STRUCT_CARD16_1(&grep, sequenceNumber);
|
||||
|
||||
CLIENT_STRUCT_CARD32_1(&grep, name);
|
||||
CLIENT_STRUCT_CARD16_4(&grep, widthMM, heightMM, nProperties, nColors);
|
||||
CLIENT_STRUCT_CARD16_4(&grep, nShapes, nSections, nDoodads, nKeyAliases);
|
||||
|
||||
memcpy(payload_walk, &grep, sizeof(grep));
|
||||
payload_walk = buf + (grep.length * 4) - (sizeof(grep) - sizeof(xGenericReply));
|
||||
|
@ -6343,10 +6307,8 @@ FillDeviceLedInfo(XkbSrvLedInfoPtr sli, char *buffer, ClientPtr client)
|
|||
.virtualMods = sli->maps[i].mods.vmods,
|
||||
.ctrls = sli->maps[i].ctrls,
|
||||
};
|
||||
if (client->swapped) {
|
||||
swaps(&iwire.virtualMods);
|
||||
swapl(&iwire.ctrls);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_1(&iwire, virtualMods);
|
||||
CLIENT_STRUCT_CARD32_1(&iwire, ctrls);
|
||||
memcpy(buffer, &iwire, sizeof(iwire));
|
||||
buffer += sizeof(iwire);
|
||||
length += sizeof(iwire);
|
||||
|
@ -6563,13 +6525,8 @@ CheckSetDeviceIndicators(char *wire,
|
|||
return (char *) ledWire;
|
||||
}
|
||||
|
||||
if (client->swapped) {
|
||||
swaps(&ledWire->ledClass);
|
||||
swaps(&ledWire->ledID);
|
||||
swapl(&ledWire->namesPresent);
|
||||
swapl(&ledWire->mapsPresent);
|
||||
swapl(&ledWire->physIndicators);
|
||||
}
|
||||
CLIENT_STRUCT_CARD16_2(ledWire, ledClass, ledID);
|
||||
CLIENT_STRUCT_CARD32_3(ledWire, namesPresent, mapsPresent, physIndicators);
|
||||
|
||||
sli = XkbFindSrvLedInfo(dev, ledWire->ledClass, ledWire->ledID,
|
||||
XkbXI_IndicatorsMask);
|
||||
|
@ -6609,10 +6566,10 @@ CheckSetDeviceIndicators(char *wire,
|
|||
*status_rtrn = BadLength;
|
||||
return (char *) mapWire;
|
||||
}
|
||||
if (client->swapped) {
|
||||
swaps(&mapWire->virtualMods);
|
||||
swapl(&mapWire->ctrls);
|
||||
}
|
||||
|
||||
CLIENT_STRUCT_CARD16_1(mapWire, virtualMods);
|
||||
CLIENT_STRUCT_CARD32_1(mapWire, ctrls);
|
||||
|
||||
CHK_MASK_LEGAL3(0x21, mapWire->whichGroups,
|
||||
XkbIM_UseAnyGroup,
|
||||
client->errorValue, *status_rtrn, NULL);
|
||||
|
|
Loading…
Reference in New Issue