CMSIS-Compiler icon indicating copy to clipboard operation
CMSIS-Compiler copied to clipboard

Arm runtime library _sys_read(): only error indicator is "-1"

Open andbararm opened this issue 1 year ago • 0 comments

For the Arm Compiler runtime library there is an issue with the error handling in the CMSIS-Compiler pack. In particular the code in retarget-io.c -> _sys_read():

  rval = rt_fs_read(fh, buf, len);
  if (rval < 0) {
    errno = rval;
  } ...

causes an endless loop of retries, when some other error value than -1 is returned. The Arm runtime library only supports -1 as error indicator as seen in the comments in rt_sys.h. So changing the code to:

  rval = rt_fs_read(fh, buf, len);
  if (rval < 0) {
    errno = rval;
    rval = -1 ;
  } ...

causes the code to exit in the error case.

andbararm avatar Oct 14 '24 14:10 andbararm