Use macros where possible
Apply `constrain`, `NOMORE`, `NOLESS` and `CRITICAL_SECTION` macros wherever possible.
This commit is contained in:
@ -1049,9 +1049,8 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
|
||||
if (!isOpen() || !(flags_ & O_READ)) goto fail;
|
||||
|
||||
// max bytes left in file
|
||||
if (nbyte >= (fileSize_ - curPosition_)) {
|
||||
nbyte = fileSize_ - curPosition_;
|
||||
}
|
||||
NOMORE(nbyte, fileSize_ - curPosition_);
|
||||
|
||||
// amount left to read
|
||||
toRead = nbyte;
|
||||
while (toRead > 0) {
|
||||
@ -1077,7 +1076,7 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
|
||||
uint16_t n = toRead;
|
||||
|
||||
// amount to be read from current block
|
||||
if (n > (512 - offset)) n = 512 - offset;
|
||||
NOMORE(n, 512 - offset);
|
||||
|
||||
// no buffering needed if n == 512
|
||||
if (n == 512 && block != vol_->cacheBlockNumber()) {
|
||||
@ -1758,7 +1757,7 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
|
||||
uint16_t n = 512 - blockOffset;
|
||||
|
||||
// lesser of space and amount to write
|
||||
if (n > nToWrite) n = nToWrite;
|
||||
NOMORE(n, nToWrite);
|
||||
|
||||
// block for data write
|
||||
uint32_t block = vol_->clusterStartBlock(curCluster_) + blockOfCluster;
|
||||
|
Reference in New Issue
Block a user