Skip to content

Commit

Permalink
Fix nif declarations in esp_adc module
Browse files Browse the repository at this point in the history
Use proper `erlang:nif_error(undefined)` so that dialyzer doesn't consider
the functions never return.

Signed-off-by: Paul Guyot <[email protected]>
  • Loading branch information
pguyot committed Oct 23, 2024
1 parent 24084c5 commit c15eae3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libs/eavmlib/src/esp_adc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
%%-----------------------------------------------------------------------------
-spec init() -> {ok, ADCUnit :: adc_rsrc()} | {error, Reason :: term()}.
init() ->
throw(nif_error).
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param UnitResource returned from init/0
Expand All @@ -134,7 +134,7 @@ init() ->
%%-----------------------------------------------------------------------------
-spec deinit(UnitResource :: adc_rsrc()) -> ok | {error, Reason :: term()}.
deinit(_UnitResource) ->
throw(nif_error).
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param Pin Pin to configure as ADC
Expand Down Expand Up @@ -185,7 +185,7 @@ acquire(Pin, UnitHandle) ->
Attenuation :: attenuation()
) -> {ok, Channel :: adc_rsrc()} | {error, Reason :: term()}.
acquire(_Pin, _UnitHandle, _BitWidth, _Attenuation) ->
throw(nif_error).
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param ChannelResource of the pin returned from acquire/4
Expand All @@ -204,7 +204,7 @@ acquire(_Pin, _UnitHandle, _BitWidth, _Attenuation) ->
%%-----------------------------------------------------------------------------
-spec release_channel(ChannelResource :: adc_rsrc()) -> ok | {error, Reason :: term()}.
release_channel(_ChannelResource) ->
throw(nif_error).
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @param ChannelResource of the pin returned from acquire/4
Expand Down Expand Up @@ -256,7 +256,7 @@ sample(ChannelResource, UnitResource) ->
ChannelResource :: adc_rsrc(), UnitResource :: adc_rsrc(), ReadOptions :: read_options()
) -> {ok, Result :: reading()} | {error, Reason :: term()}.
sample(_ChannelResource, _UnitResource, _ReadOptions) ->
throw(nif_error).
erlang:nif_error(undefined).

%%-----------------------------------------------------------------------------
%% @returns {ok, Pid}
Expand Down

0 comments on commit c15eae3

Please sign in to comment.