Rewrite all units and other logic to better use return values and added TRY() helper

This commit is contained in:
2018-01-04 11:50:05 +01:00
parent 465242a0f1
commit ab2dfe3a76
22 changed files with 369 additions and 362 deletions
+12 -12
View File
@@ -100,16 +100,16 @@ error_t stream_open(stream_type_t stream_type)
// Stream must not be open already
if (stream_state != STREAM_STATE_CLOSED) {
vfs_printf("!! Stream is not closed, cant open");
assert_param(0);
return E_INTERNAL;
trap("!! Stream is not closed, cant open");
// assert_param(0);
// return E_INTERNAL;
}
// Stream must be of a supported type
if (stream_type >= STREAM_TYPE_COUNT) {
vfs_printf("!! Stream bad type");
assert_param(0);
return E_INTERNAL;
trap("!! Stream bad type");
// assert_param(0);
// return E_INTERNAL;
}
Indicator_Effect(STATUS_DISK_BUSY);
@@ -136,9 +136,9 @@ error_t stream_write(const uint8_t *data, uint32_t size)
// Stream must be open already
if (stream_state != STREAM_STATE_OPEN) {
vfs_printf("!! Stream is not open, cant write");
assert_param(0);
return E_INTERNAL;
trap("!! Stream is not open, cant write");
// assert_param(0);
// return E_INTERNAL;
}
// Check thread after checking state since the stream thread is
@@ -169,9 +169,9 @@ error_t stream_close(void)
// Stream must not be closed already
if (STREAM_STATE_CLOSED == stream_state) {
vfs_printf("!! Stream already closed");
assert_param(0);
return E_INTERNAL;
trap("!! Stream already closed");
// assert_param(0);
// return E_INTERNAL;
}
// Check thread after checking state since the stream thread is
+2 -1
View File
@@ -941,7 +941,8 @@ static void transfer_update_state(error_t status)
// Set the fail reason
fail_reason = local_status;
vfs_printf(" Transfer finished, status: %i=%s\r\n", fail_reason, error_get_string(fail_reason));
vfs_printf(" Transfer finished, status: %i=%s\r\n", fail_reason,
error_get_message(fail_reason));
}
// If this state change is not from aborting a transfer