Simplify if to guard statement

This commit is contained in:
Willy-JL
2023-08-29 02:00:56 +02:00
parent d2baf3935e
commit 4b333b3767

View File

@@ -365,8 +365,10 @@ static void rpc_session_thread_state_callback(FuriThreadState thread_state, void
} }
RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) { RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) {
if(!furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock) || if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock) &&
XTREME_SETTINGS()->allow_locked_rpc_commands) { !XTREME_SETTINGS()->allow_locked_rpc_commands)
return NULL;
furi_assert(rpc); furi_assert(rpc);
RpcSession* session = malloc(sizeof(RpcSession)); RpcSession* session = malloc(sizeof(RpcSession));
@@ -394,8 +396,7 @@ RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) {
}; };
rpc_add_handler(session, PB_Main_stop_session_tag, &rpc_handler); rpc_add_handler(session, PB_Main_stop_session_tag, &rpc_handler);
session->thread = session->thread = furi_thread_alloc_ex("RpcSessionWorker", 3072, rpc_session_worker, session);
furi_thread_alloc_ex("RpcSessionWorker", 3072, rpc_session_worker, session);
furi_thread_set_state_context(session->thread, session); furi_thread_set_state_context(session->thread, session);
furi_thread_set_state_callback(session->thread, rpc_session_thread_state_callback); furi_thread_set_state_callback(session->thread, rpc_session_thread_state_callback);
@@ -403,9 +404,6 @@ RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) {
furi_thread_start(session->thread); furi_thread_start(session->thread);
return session; return session;
} else {
return NULL;
}
} }
void rpc_session_close(RpcSession* session) { void rpc_session_close(RpcSession* session) {