Repository navigation
sprandom: Fix several issues found in the sprandom implementation - #1976
Conversation
Move the sprandom_init() call to occur before total_io_size is computed, in order to ensure correctly compute statitics. Signed-off-by: Tomas Winkler <tomas.winkler@sandisk.com>
Fix a lefover bug, after code changes. Use 'offset' instead of *b pointer. Signed-off-by: Tomas Winkler <tomas.winkler@sandisk.com>
Free invalid_pct, fix a memory leak. Signed-off-by: Tomas Winkler <tomas.winkler@sandisk.com>
There was a problem hiding this comment.
Let's please not add a silly helper that does nothing but call free. The existing code is perfectly readable and you know what it does by looking at it. Conversely, after your change, I'd have to find the function to see exactly what it frees.
There was a problem hiding this comment.
I see your point about pcb_free() being just a wrapper around free(). My thinking was mainly about API symmetry and code readability. We already have pcb_alloc(), so a natural instinct is to search for a matching pcb_free().
If the consensus is to stick with direct free(cb), I’m fine with that as well.
The validity_dist buffer is only needed to compute the invalid_pct array. Once that is done, we can free it instead of keeping it around unnecessarily. Signed-off-by: Tomas Winkler <tomas.winkler@sandisk.com>
fc9e6e9 to
8c8e705
Compare
|
@tomas-winkler-sndk "sprandom: drop validity_dist after use" frees Would you like to add some tests for |
|
I've tested and probably moved the lines after. My bad. Strangely -Wuse-after-free doesn't catch it. |
Fix several issues found in the sprandom implementation, including a memory leak and incorrect eta() computation.
sprandom: drop validity_dist after use
sprandom: add pcb_free() function
sprandom: free invalid_pct buffer
sprandom: fix debug printout for offset
sprandom: setup SPRandom before total_io_size is computed