Skip to content

Commit

Permalink
Merge pull request #1354 from pguyot/w43/fix-specs
Browse files Browse the repository at this point in the history
Fix nif declarations in esp_adc module

Use proper `erlang:nif_error(undefined)` so that dialyzer doesn't consider the
functions never return.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
  • Loading branch information
bettio committed Nov 3, 2024
2 parents 39de7e2 + bcde5f0 commit 4c45ca7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.6.6] - Unreleased

### Fixed

- Fixed specifications of nifs from `esp_adc` module

## [0.6.5] - 2024-10-15

### Added
Expand Down
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 4c45ca7

Please sign in to comment.