USB: Properly set and reset fFragmented for both SetVector and SetData.

Now that we are not setting fFragmented in VectorLength(), we can
reset it in SetVector based purely on the length of the newly set vectors.

We also need to set it in SetData, as SetVector does not call this.
This fixes an oversight in bc7fd43358.
This commit is contained in:
Augustin Cavalier
2021-09-20 12:37:39 -04:00
parent 8d046e2689
commit cc455ef461
@@ -70,6 +70,8 @@ Transfer::SetData(uint8 *data, size_t dataLength)
if (data && dataLength > 0)
fVectorCount = 1;
fFragmented = dataLength > USB_MAX_FRAGMENT_SIZE;
// Calculate the bandwidth (only if it is not a bulk transfer)
if (!(fPipe->Type() & USB_OBJECT_BULK_PIPE)) {
if (_CalculateBandwidth() < B_OK)
@@ -97,10 +99,7 @@ Transfer::SetVector(iovec *vector, size_t vectorCount)
for (size_t i = 0; i < fVectorCount && length < USB_MAX_FRAGMENT_SIZE; i++)
length += fVector[i].iov_len;
if (length > USB_MAX_FRAGMENT_SIZE) {
// the data is too large and would overflow the allocator
fFragmented = true;
}
fFragmented = length > USB_MAX_FRAGMENT_SIZE;
}