From c15eae30c37719cd7eb192cb2bed37bb036d4ccb Mon Sep 17 00:00:00 2001 From: Paul Guyot Date: Wed, 23 Oct 2024 21:23:59 +0200 Subject: [PATCH] Fix nif declarations in esp_adc module Use proper `erlang:nif_error(undefined)` so that dialyzer doesn't consider the functions never return. Signed-off-by: Paul Guyot --- libs/eavmlib/src/esp_adc.erl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/eavmlib/src/esp_adc.erl b/libs/eavmlib/src/esp_adc.erl index d50948453..8b6d23de9 100644 --- a/libs/eavmlib/src/esp_adc.erl +++ b/libs/eavmlib/src/esp_adc.erl @@ -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 @@ -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 @@ -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 @@ -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 @@ -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}