Rewrite all units and other logic to better use return values and added TRY() helper
This commit is contained in:
+12
-12
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user