acassis opened a new pull request, #21909:
URL: https://github.com/apache/nuttx/pull/21909

   ## Summary
   
   gran_reserve() rounded the last byte of the range up to the start of the 
next granule, and then counted that granule too.  It reserved one granule more 
than the range needs:
   
   * A reservation of one granule marked two granules as used.
   * A reservation of the last granule of the heap failed, because the next 
granule is outside the heap.
   * gran_free() of the reserved range left the extra granule reserved.
   
   Round the last byte down to its granule, as for the first byte.
   
   ## Impact
   
   Improvement
   
   ## Testing
   
   ```
     Tested on sim:nsh with CONFIG_GRAN, CONFIG_TESTING_GRANTEST and 
CONFIG_DEBUG_ASSERTIONS.
     On upstream/master:
     grantest: reserve one granule:               FAIL (expected 1, got 2)
     grantest: reserve the last granule:          FAIL (expected 15, got -1)
     grantest: reserve, free, allocate the heap:  FAIL (expected 0, got -1)
     grantest: align 0, two granules:             FAIL (expected 2, got 0)
     grantest: align 0, one granule:              FAIL (expected 0, got -1)
     grantest: align 3 granules:                  FAIL (expected -1, got 1)
     grantest: align 4 granules:                  PASS (expected 4, got 4)
     grantest: 6 failed
   
   ```
   After the fix the reset passes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to