Microchip-MPLAB-Harmony / core

Harmony 3 Core
https://onlinedocs.microchip.com/v2/keyword-lookup?keyword=MH3_core&redirect=true
Other
17 stars 12 forks source link

Missing break in drv_memory.c #9

Closed lucapascarella closed 4 years ago

lucapascarella commented 4 years ago

In _DRV_MEMORYHandleEraseWrite the _DRV_MEMORY_EWINIT case has a missing break when dObj->nBlocksToWrite == pagesPerSector

`case DRV_MEMORY_EW_INIT: default: { dObj->readState = DRV_MEMORY_READ_INIT; dObj->eraseState = DRV_MEMORY_ERASE_INIT; dObj->writeState = DRV_MEMORY_WRITE_INIT;

        /* Find the sector for the starting page */
        dObj->sectorNumber = bufferObj->blockStart / pagesPerSector;

        /* Find the number of sectors to be updated in this block. */
        dObj->blockOffsetInSector = (bufferObj->blockStart % pagesPerSector);
        dObj->nBlocksToWrite = (pagesPerSector - dObj->blockOffsetInSector);

        if (bufferObj->nBlocks < dObj->nBlocksToWrite)
        {
            dObj->nBlocksToWrite = bufferObj->nBlocks;
        }

        if (dObj->nBlocksToWrite != pagesPerSector)
        {
            dObj->writePtr = dObj->ewBuffer;
            dObj->ewState = DRV_MEMORY_EW_READ_SECTOR;
        }
        else
        {
            dObj->writePtr = bufferObj->buffer;
            dObj->ewState = DRV_MEMORY_EW_ERASE_SECTOR;

            transferStatus = MEMORY_DEVICE_TRANSFER_BUSY;
            // ==> Missing break <==
            break; // Here the flow must skip the next case because there is no need to read back the flash content
        }

        /* Fall through for read operation. */
    }

case DRV_MEMORY_EW_READ_SECTOR: {...`

amitraddi commented 4 years ago

@lucapascarella Good catch. It will be fixed as part of next release

dsettu commented 4 years ago

@lucapascarella , This issue is fixed now. Please check it out and close. thank you.