Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@donmr
Copy link
Contributor

@donmr donmr commented Jul 27, 2018

Here is the first fix to mem_write() again. This is simply to have it return when len == 0 and that solves my issues with reading at the end of a file when the remaining data is not an even multiple of 4 bytes.

I have also recognized that this function will overwrite target data that is shouldn't if it is ever called with a non-zero length and either the address or length is not a multiple of 4. I don't know if that situation will ever occur, it does not happen in my limited uses (so far :-) ). I have added some comments with possible ways to address that issue.

donmr and others added 9 commits July 26, 2018 09:02
of a file.  fread (on stm32) get them (say 3 bytes), then askes for
more.  do_semihosting gets a read return of 0 and tries to write that.
mem_write alters the address to be aligned and overwrites then 3 bytes
from the last read.

This change simply tells mem_write to do nothing if len is 0.
Add more comments on further possible issues and ways to handle them.
Using a branch to separate this change from others as it may need
more discussion and go on for a while...
Fixes to SYS_READ changes in PR stlink-org#727 per review. (stlink-org#729)
and the compiler should be fine with that without any cast.
@xor-gate
Copy link
Member

xor-gate commented Aug 1, 2018

This is a good fix, checking before calculation is always a good idea to not go beyond boundaries. Thanks!

@xor-gate xor-gate merged commit 27ce268 into stlink-org:master Aug 1, 2018
@xor-gate xor-gate added this to the Next milestone Aug 1, 2018
@Nightwalker-87 Nightwalker-87 linked an issue Mar 18, 2020 that may be closed by this pull request
6 tasks
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Apr 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Semihosting SYS_READ returns incorrect value on EOF

3 participants