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