From 67338009a98bf84f4268beec6453e8ee36f1cd81 Mon Sep 17 00:00:00 2001 From: UENISHI Kota Date: Sat, 18 Jan 2014 01:14:53 +0900 Subject: [PATCH] fix some dialyzing --- Makefile | 2 +- dialyzer.ignore-warnings | 0 include/msgpack.hrl | 2 +- src/msgpack.erl | 3 ++- src/msgpack_term.erl | 8 +++++--- 5 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 dialyzer.ignore-warnings diff --git a/Makefile b/Makefile index 8e953d2..da20abf 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ dialyzer: xref @echo Use "'make build_plt'" to build PLT prior to using this target. @echo @sleep 1 - dialyzer -Wno_return --plt $(COMBO_PLT) | fgrep -v -f ./dialyzer.ignore-warnings + dialyzer -Wno_return --plt $(COMBO_PLT) ebin | fgrep -v -f ./dialyzer.ignore-warnings diff --git a/dialyzer.ignore-warnings b/dialyzer.ignore-warnings new file mode 100644 index 0000000..e69de29 diff --git a/include/msgpack.hrl b/include/msgpack.hrl index 6ef046d..2176e20 100644 --- a/include/msgpack.hrl +++ b/include/msgpack.hrl @@ -63,7 +63,7 @@ impl = erlang :: erlang | nif, allow_atom = none :: none | pack, %% allows atom when packing enable_str = false :: boolean(), %% true for new spec - ext_packer = undefined :: msgpack_ext_packer(), + ext_packer = undefined :: msgpack_ext_packer(), ext_unpacker = undefined :: msgpack_ext_unpacker(), original_list = [] :: msgpack_list_options() }). diff --git a/src/msgpack.erl b/src/msgpack.erl index 7e16581..84bce17 100644 --- a/src/msgpack.erl +++ b/src/msgpack.erl @@ -99,7 +99,7 @@ unpack(Bin, Opts) -> | {error, {badarg, term()}}. unpack_stream(Bin) -> unpack_stream(Bin, []). --spec unpack_stream(binary(), msgpack_option())-> {msgpack:object(), binary()} +-spec unpack_stream(binary(), msgpack:options())-> {msgpack:object(), binary()} | {error, incomplete} | {error, {badarg, term()}}. unpack_stream(Bin, Opts0) when is_binary(Bin) -> @@ -116,6 +116,7 @@ unpack_stream(Other, _) -> {error, {badarg, Other}}. parse_options(Opt) -> parse_options(Opt, ?OPTION{original_list=Opt}). %% @private +-spec parse_options(msgpack:options(), msgpack_option()) -> msgpack_option(). parse_options([], Opt) -> Opt; parse_options([jsx|TL], Opt0) -> Opt = Opt0?OPTION{interface=jsx, diff --git a/src/msgpack_term.erl b/src/msgpack_term.erl index 9b60baf..8311d3e 100644 --- a/src/msgpack_term.erl +++ b/src/msgpack_term.erl @@ -19,7 +19,7 @@ -export([to_binary/1, from_binary/2, pack_ext/2, unpack_ext/3]). --behabiour(msgpack_ext). +-behaviour(msgpack_ext). -define(ERLANG_TERM, 131). -define(TERM_OPTION, [{enable_str,true},{ext,?MODULE},{allow_atom,none}]). @@ -32,8 +32,10 @@ to_binary(Term) -> %% @doc experimental -spec from_binary(binary(), []|[safe]) -> term(). from_binary(Bin, Opt) -> - {ok, Term} = msgpack:unpack(Bin, Opt ++ ?TERM_OPTION), - Term. + case msgpack:unpack(Bin, Opt ++ ?TERM_OPTION) of + {ok, Term} -> Term; + Error -> error(Error) + end. -spec pack_ext(tuple(), msgpack:options()) -> {ok, {Type::byte(), Data::binary()}} |