mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1194721: Add PDU_ prefix to daemon PDU constants, r=shuang
Something defines HEADER_SIZE when including the PDU headers from hal/gonk. This break the HEADER_SIZE constant in |DaemonSocketPDU|. This patch adds the prefix PDU_ to all PDU constants.
This commit is contained in:
parent
487582fbe5
commit
5945b1b215
@ -103,7 +103,7 @@ DaemonSocketIO::QueryReceiveBuffer(UnixSocketIOBuffer** aBuffer)
|
||||
|
||||
if (!mPDU) {
|
||||
/* There's only one PDU for receiving. We reuse it every time. */
|
||||
mPDU = new DaemonSocketPDU(DaemonSocketPDU::MAX_PAYLOAD_LENGTH);
|
||||
mPDU = new DaemonSocketPDU(DaemonSocketPDU::PDU_MAX_PAYLOAD_LENGTH);
|
||||
}
|
||||
*aBuffer = mPDU.get();
|
||||
|
||||
|
@ -35,17 +35,17 @@ DaemonSocketPDU::DaemonSocketPDU(uint8_t aService, uint8_t aOpcode,
|
||||
MOZ_COUNT_CTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
|
||||
|
||||
// Allocate memory
|
||||
size_t availableSpace = HEADER_SIZE + aPayloadSize;
|
||||
size_t availableSpace = PDU_HEADER_SIZE + aPayloadSize;
|
||||
ResetBuffer(new uint8_t[availableSpace], 0, 0, availableSpace);
|
||||
|
||||
// Reserve PDU header
|
||||
uint8_t* data = Append(HEADER_SIZE);
|
||||
uint8_t* data = Append(PDU_HEADER_SIZE);
|
||||
MOZ_ASSERT(data);
|
||||
|
||||
// Setup PDU header
|
||||
data[OFF_SERVICE] = aService;
|
||||
data[OFF_OPCODE] = aOpcode;
|
||||
memcpy(data + OFF_LENGTH, &aPayloadSize, sizeof(aPayloadSize));
|
||||
data[PDU_OFF_SERVICE] = aService;
|
||||
data[PDU_OFF_OPCODE] = aOpcode;
|
||||
memcpy(data + PDU_OFF_LENGTH, &aPayloadSize, sizeof(aPayloadSize));
|
||||
}
|
||||
|
||||
DaemonSocketPDU::DaemonSocketPDU(size_t aPayloadSize)
|
||||
@ -53,7 +53,7 @@ DaemonSocketPDU::DaemonSocketPDU(size_t aPayloadSize)
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
|
||||
|
||||
size_t availableSpace = HEADER_SIZE + aPayloadSize;
|
||||
size_t availableSpace = PDU_HEADER_SIZE + aPayloadSize;
|
||||
ResetBuffer(new uint8_t[availableSpace], 0, 0, availableSpace);
|
||||
}
|
||||
|
||||
@ -69,9 +69,9 @@ void
|
||||
DaemonSocketPDU::GetHeader(uint8_t& aService, uint8_t& aOpcode,
|
||||
uint16_t& aPayloadSize)
|
||||
{
|
||||
memcpy(&aService, GetData(OFF_SERVICE), sizeof(aService));
|
||||
memcpy(&aOpcode, GetData(OFF_OPCODE), sizeof(aOpcode));
|
||||
memcpy(&aPayloadSize, GetData(OFF_LENGTH), sizeof(aPayloadSize));
|
||||
memcpy(&aService, GetData(PDU_OFF_SERVICE), sizeof(aService));
|
||||
memcpy(&aOpcode, GetData(PDU_OFF_OPCODE), sizeof(aOpcode));
|
||||
memcpy(&aPayloadSize, GetData(PDU_OFF_LENGTH), sizeof(aPayloadSize));
|
||||
}
|
||||
|
||||
ssize_t
|
||||
@ -164,12 +164,12 @@ nsresult
|
||||
DaemonSocketPDU::UpdateHeader()
|
||||
{
|
||||
size_t len = GetPayloadSize();
|
||||
if (len >= MAX_PAYLOAD_LENGTH) {
|
||||
if (len >= PDU_MAX_PAYLOAD_LENGTH) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
uint16_t len16 = static_cast<uint16_t>(len);
|
||||
|
||||
memcpy(GetData(OFF_LENGTH), &len16, sizeof(len16));
|
||||
memcpy(GetData(PDU_OFF_LENGTH), &len16, sizeof(len16));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -177,9 +177,9 @@ DaemonSocketPDU::UpdateHeader()
|
||||
size_t
|
||||
DaemonSocketPDU::GetPayloadSize() const
|
||||
{
|
||||
MOZ_ASSERT(GetSize() >= HEADER_SIZE);
|
||||
MOZ_ASSERT(GetSize() >= PDU_HEADER_SIZE);
|
||||
|
||||
return GetSize() - HEADER_SIZE;
|
||||
return GetSize() - PDU_HEADER_SIZE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -39,12 +39,12 @@ class DaemonSocketPDU final : public UnixSocketIOBuffer
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
OFF_SERVICE = 0,
|
||||
OFF_OPCODE = 1,
|
||||
OFF_LENGTH = 2,
|
||||
OFF_PAYLOAD = 4,
|
||||
HEADER_SIZE = OFF_PAYLOAD,
|
||||
MAX_PAYLOAD_LENGTH = 1 << 16
|
||||
PDU_OFF_SERVICE = 0,
|
||||
PDU_OFF_OPCODE = 1,
|
||||
PDU_OFF_LENGTH = 2,
|
||||
PDU_OFF_PAYLOAD = 4,
|
||||
PDU_HEADER_SIZE = PDU_OFF_PAYLOAD,
|
||||
PDU_MAX_PAYLOAD_LENGTH = 1 << 16
|
||||
};
|
||||
|
||||
DaemonSocketPDU(uint8_t aService, uint8_t aOpcode, uint16_t aPayloadSize);
|
||||
|
Loading…
Reference in New Issue
Block a user