From 2d246f61dd75bcef3ca15dc30cbe0b399c9f6e2c Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Sun, 9 Sep 2018 09:59:08 +0300 Subject: [PATCH] Fix some dialyzer warnings --- src/ejabberd_acme.erl | 3 +-- src/ejabberd_auth.erl | 8 +------- src/ejabberd_auth_anonymous.erl | 5 +---- src/ejabberd_auth_ldap.erl | 5 +---- src/ejabberd_auth_pam.erl | 4 +--- src/ejabberd_auth_sql.erl | 3 +-- src/ejabberd_c2s.erl | 35 ++++----------------------------- src/ejabberd_captcha.erl | 5 +---- src/ejabberd_commands.erl | 4 +--- src/ejabberd_config.erl | 19 ++---------------- src/ejabberd_ctl.erl | 3 +-- src/ejabberd_http.erl | 21 ++------------------ src/ejabberd_oauth.erl | 9 +-------- src/ejabberd_oauth_rest.erl | 3 +-- src/ejabberd_pkix.erl | 6 +++--- src/ejabberd_rdbms.erl | 4 +--- src/ejabberd_redis_sup.erl | 9 +-------- src/ejabberd_riak_sup.erl | 9 +-------- src/ejabberd_router.erl | 13 ++---------- src/ejabberd_s2s.erl | 14 +------------ src/ejabberd_s2s_in.erl | 16 +-------------- src/ejabberd_s2s_out.erl | 8 +------- src/ejabberd_service.erl | 20 +------------------ src/ejabberd_shaper.erl | 3 +-- src/ejabberd_sm.erl | 9 ++------- src/ejabberd_sql.erl | 15 +------------- src/ejabberd_sql_sup.erl | 4 +--- src/ejabberd_web_admin.erl | 3 +-- src/eldap_utils.erl | 19 +----------------- src/ext_mod.erl | 3 +-- src/gen_iq_handler.erl | 3 +-- src/gen_mod.erl | 3 +-- src/mod_bosh.erl | 2 +- src/mod_carboncopy.erl | 2 +- src/mod_multicast.erl | 8 ++++---- src/mod_register.erl | 3 +-- src/rest.erl | 4 +--- 37 files changed, 49 insertions(+), 258 deletions(-) diff --git a/src/ejabberd_acme.erl b/src/ejabberd_acme.erl index 6c503f205..4145b0a4f 100644 --- a/src/ejabberd_acme.erl +++ b/src/ejabberd_acme.erl @@ -1222,8 +1222,7 @@ generate_key() -> %% Option Parsing Code %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec opt_type(acme) -> fun((acme_config()) -> (acme_config())); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(acme) -> fun(L) -> lists:map( diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl index 92c080259..5659ee389 100644 --- a/src/ejabberd_auth.erl +++ b/src/ejabberd_auth.erl @@ -851,13 +851,7 @@ import(Server, {sql, _}, riak, <<"users">>, Fields) -> import(_LServer, {sql, _}, sql, <<"users">>, _) -> ok. --spec opt_type(auth_method) -> fun((atom() | [atom()]) -> [atom()]); - (auth_password_format) -> fun((plain | scram) -> plain | scram); - (auth_use_cache) -> fun((boolean()) -> boolean()); - (auth_cache_missed) -> fun((boolean()) -> boolean()); - (auth_cache_life_time) -> fun((timeout()) -> timeout()); - (auth_cache_size) -> fun((timeout()) -> timeout()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(auth_method) -> fun (V) when is_list(V) -> lists:map(fun(M) -> ejabberd_config:v_db(?MODULE, M) end, V); diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index e3be79a43..3c4993cb0 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -177,10 +177,7 @@ plain_password_required(_) -> store_type(_) -> external. --spec opt_type(allow_multiple_connection) -> fun((boolean()) -> boolean()); - (anonymous_protocol) -> fun((sasl_anon | login_anon | both) -> - sasl_anon | login_anon | both); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(allow_multiple_connections) -> fun (V) when is_boolean(V) -> V end; opt_type(anonymous_protocol) -> diff --git a/src/ejabberd_auth_ldap.erl b/src/ejabberd_auth_ldap.erl index 5f5fad3fb..b23b1c340 100644 --- a/src/ejabberd_auth_ldap.erl +++ b/src/ejabberd_auth_ldap.erl @@ -362,10 +362,7 @@ parse_options(Host) -> sfilter = SearchFilter, lfilter = LocalFilter, dn_filter = DNFilter, dn_filter_attrs = DNFilterAttrs}. --spec opt_type(ldap_dn_filter) -> fun(([{binary(), binary()}]) -> - [{binary(), binary()}]); - (ldap_local_filter) -> fun((any()) -> any()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(ldap_dn_filter) -> fun ([{DNF, DNFA}]) -> NewDNFA = case DNFA of diff --git a/src/ejabberd_auth_pam.erl b/src/ejabberd_auth_pam.erl index bc5a0ea25..71b745df0 100644 --- a/src/ejabberd_auth_pam.erl +++ b/src/ejabberd_auth_pam.erl @@ -82,9 +82,7 @@ get_pam_service(Host) -> get_pam_userinfotype(Host) -> ejabberd_config:get_option({pam_userinfotype, Host}, username). --spec opt_type(pam_service) -> fun((binary()) -> binary()); - (pam_userinfotype) -> fun((username | jid) -> username | jid); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(pam_service) -> fun iolist_to_binary/1; opt_type(pam_userinfotype) -> fun (username) -> username; diff --git a/src/ejabberd_auth_sql.erl b/src/ejabberd_auth_sql.erl index 4d1cf0667..4b774642a 100644 --- a/src/ejabberd_auth_sql.erl +++ b/src/ejabberd_auth_sql.erl @@ -324,8 +324,7 @@ export(_Server) -> [] end}]. --spec opt_type(pgsql_users_number_estimate) -> fun((boolean()) -> boolean()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(pgsql_users_number_estimate) -> fun (V) when is_boolean(V) -> V end; opt_type(_) -> [pgsql_users_number_estimate]. diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index c782cb290..76166db9e 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -104,7 +104,7 @@ get_presence(Ref) -> set_presence(Ref, Pres) -> call(Ref, {set_presence, Pres}, 1000). --spec resend_presence(pid()) -> ok. +-spec resend_presence(pid()) -> boolean(). resend_presence(Pid) -> resend_presence(Pid, undefined). @@ -946,7 +946,7 @@ format_reason(_, {shutdown, _}) -> format_reason(_, _) -> <<"internal server error">>. --spec get_certfile(binary()) -> file:filename_all(). +-spec get_certfile(binary()) -> file:filename_all() | undefined. get_certfile(LServer) -> case ejabberd_pkix:get_certfile(LServer) of {ok, CertFile} -> @@ -960,15 +960,7 @@ get_certfile(LServer) -> transform_listen_option(Opt, Opts) -> [Opt|Opts]. --type resource_conflict() :: setresource | closeold | closenew | acceptnew. --spec opt_type(c2s_ciphers) -> fun((binary()) -> binary()); - (c2s_dhfile) -> fun((binary()) -> binary()); - (c2s_cafile) -> fun((binary()) -> binary()); - (c2s_protocol_options) -> fun(([binary()]) -> binary()); - (c2s_tls_compression) -> fun((boolean()) -> boolean()); - (resource_conflict) -> fun((resource_conflict()) -> resource_conflict()); - (disable_sasl_mechanisms) -> fun((binary() | [binary()]) -> [binary()]); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(c2s_ciphers) -> fun iolist_to_binary/1; opt_type(c2s_dhfile) -> fun misc:try_read_file/1; opt_type(c2s_cafile) -> fun misc:try_read_file/1; @@ -994,26 +986,7 @@ opt_type(_) -> c2s_protocol_options, c2s_tls_compression, resource_conflict, disable_sasl_mechanisms]. --spec listen_opt_type(access) -> fun((any()) -> any()); - (shaper) -> fun((any()) -> any()); - (certfile) -> fun((binary()) -> binary()); - (ciphers) -> fun((binary()) -> binary()); - (dhfile) -> fun((binary()) -> binary()); - (cafile) -> fun((binary()) -> binary()); - (protocol_options) -> fun(([binary()]) -> binary()); - (tls_compression) -> fun((boolean()) -> boolean()); - (tls) -> fun((boolean()) -> boolean()); - (starttls) -> fun((boolean()) -> boolean()); - (tls_verify) -> fun((boolean()) -> boolean()); - (zlib) -> fun((boolean()) -> boolean()); - (supervisor) -> fun((boolean()) -> boolean()); - (max_stanza_size) -> fun((timeout()) -> timeout()); - (max_fsm_queue) -> fun((timeout()) -> timeout()); - (stream_management) -> fun((boolean()) -> boolean()); - (inet) -> fun((boolean()) -> boolean()); - (inet6) -> fun((boolean()) -> boolean()); - (backlog) -> fun((timeout()) -> timeout()); - (atom()) -> [atom()]. +-spec listen_opt_type(atom()) -> fun((any()) -> any()) | [atom()]. listen_opt_type(access) -> fun acl:access_rules_validator/1; listen_opt_type(shaper) -> fun acl:shaper_rules_validator/1; listen_opt_type(certfile = Opt) -> diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index f366b4175..209c68fa4 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -591,10 +591,7 @@ callback(_, _, _) -> now_priority() -> -p1_time_compat:system_time(micro_seconds). --spec opt_type(captcha_cmd) -> fun((binary()) -> binary()); - (captcha_host) -> fun((binary()) -> binary()); - (captcha_limit) -> fun((pos_integer()) -> pos_integer()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(captcha_cmd) -> fun (FileName) -> F = iolist_to_binary(FileName), if F /= <<"">> -> F end diff --git a/src/ejabberd_commands.erl b/src/ejabberd_commands.erl index 7a3bd98d0..56a1518e4 100644 --- a/src/ejabberd_commands.erl +++ b/src/ejabberd_commands.erl @@ -619,9 +619,7 @@ permission_addon() -> [{access, ejabberd_config:get_option(commands_admin_access, none)}], {get_exposed_commands(), []}}}]. --spec opt_type(commands_admin_access) -> fun((any()) -> any()); - (commands) -> fun((list()) -> list()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(commands_admin_access) -> fun acl:access_rules_validator/1; opt_type(commands) -> fun(V) when is_list(V) -> V end; diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index f34c876eb..6146695c2 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -60,7 +60,7 @@ -include_lib("kernel/include/inet.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). --callback opt_type(atom()) -> function() | [atom()]. +-callback opt_type(atom()) -> fun((any()) -> any()) | [atom()]. -type bad_option() :: invalid_option | unknown_option. -spec start() -> ok | {error, bad_option()}. @@ -1439,22 +1439,7 @@ emit_deprecation_warning(Module, NewModule) -> now_to_seconds({MegaSecs, Secs, _MicroSecs}) -> MegaSecs * 1000000 + Secs. --spec opt_type(hide_sensitive_log_data) -> fun((boolean()) -> boolean()); - (hosts) -> fun(([binary()]) -> [binary()]); - (language) -> fun((binary()) -> binary()); - (max_fsm_queue) -> fun((pos_integer()) -> pos_integer()); - (default_db) -> fun((atom()) -> atom()); - (default_ram_db) -> fun((atom()) -> atom()); - (loglevel) -> fun((0..5) -> 0..5); - (queue_dir) -> fun((binary()) -> binary()); - (queue_type) -> fun((ram | file) -> ram | file); - (use_cache) -> fun((boolean()) -> boolean()); - (cache_size) -> fun((timeout()) -> timeout()); - (cache_missed) -> fun((boolean()) -> boolean()); - (cache_life_time) -> fun((timeout()) -> timeout()); - (shared_key) -> fun((binary()) -> binary()); - (node_start) -> fun((non_neg_integer()) -> non_neg_integer()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(hide_sensitive_log_data) -> fun (H) when is_boolean(H) -> H end; opt_type(hosts) -> diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index f5d51036e..c71649562 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -874,8 +874,7 @@ print(Format, Args) -> %% ["aaaa bbb ccc"]. --spec opt_type(ejabberdctl_access_commands) -> fun((list()) -> list()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(ejabberdctl_access_commands) -> fun (V) when is_list(V) -> V end; opt_type(_) -> [ejabberdctl_access_commands]. diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl index 7ce936d15..db9182cd8 100644 --- a/src/ejabberd_http.erl +++ b/src/ejabberd_http.erl @@ -949,8 +949,7 @@ transform_listen_option({request_handlers, Hs}, Opts) -> transform_listen_option(Opt, Opts) -> [Opt|Opts]. --spec opt_type(trusted_proxies) -> fun((all | [binary()]) -> all | [binary()]); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(trusted_proxies) -> fun (all) -> all; (TPs) -> lists:filtermap( @@ -963,23 +962,7 @@ opt_type(trusted_proxies) -> end; opt_type(_) -> [trusted_proxies]. --spec listen_opt_type(tls) -> fun((boolean()) -> boolean()); - (certfile) -> fun((binary()) -> binary()); - (ciphers) -> fun((binary()) -> binary()); - (dhfile) -> fun((binary()) -> binary()); - (protocol_options) -> fun(([binary()]) -> binary()); - (tls_compression) -> fun((boolean()) -> boolean()); - (captcha) -> fun((boolean()) -> boolean()); - (register) -> fun((boolean()) -> boolean()); - (web_admin) -> fun((boolean()) -> boolean()); - (http_bind) -> fun((boolean()) -> boolean()); - (xmlrpc) -> fun((boolean()) -> boolean()); - (request_handlers) -> fun(([{binary(), atom()}]) -> - [{binary(), atom()}]); - (default_host) -> fun((binary()) -> binary()); - (custom_headers) -> fun(([{binary(), binary()}]) -> - [{binary(), binary()}]); - (atom()) -> [atom()]. +-spec listen_opt_type(atom()) -> fun((any()) -> any()) | [atom()]. listen_opt_type(tls) -> fun(B) when is_boolean(B) -> B end; listen_opt_type(certfile = Opt) -> diff --git a/src/ejabberd_oauth.erl b/src/ejabberd_oauth.erl index 5f7818cf3..fbd311335 100644 --- a/src/ejabberd_oauth.erl +++ b/src/ejabberd_oauth.erl @@ -646,14 +646,7 @@ logo() -> <<>> end. --spec opt_type(oauth_expire) -> fun((non_neg_integer()) -> non_neg_integer()); - (oauth_access) -> fun((any()) -> any()); - (oauth_db_type) -> fun((atom()) -> atom()); - (oauth_cache_life_time) -> fun((timeout()) -> timeout()); - (oauth_cache_size) -> fun((timeout()) -> timeout()); - (oauth_use_cache) -> fun((boolean()) -> boolean()); - (oauth_cache_misse) -> fun((boolean()) -> boolean()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(oauth_expire) -> fun(I) when is_integer(I), I >= 0 -> I end; opt_type(oauth_access) -> diff --git a/src/ejabberd_oauth_rest.erl b/src/ejabberd_oauth_rest.erl index 6e2e92218..151946d30 100644 --- a/src/ejabberd_oauth_rest.erl +++ b/src/ejabberd_oauth_rest.erl @@ -92,8 +92,7 @@ path(Path) -> <>. --spec opt_type(ext_api_path_oauth) -> fun((binary()) -> binary()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(ext_api_path_oauth) -> fun (X) -> iolist_to_binary(X) end; opt_type(_) -> [ext_api_path_oauth]. diff --git a/src/ejabberd_pkix.erl b/src/ejabberd_pkix.erl index 002a98917..f8c3483d3 100644 --- a/src/ejabberd_pkix.erl +++ b/src/ejabberd_pkix.erl @@ -60,12 +60,12 @@ %%%=================================================================== %%% API %%%=================================================================== --spec add_certfile(filename:filename()) +-spec add_certfile(file:filename()) -> ok | {error, cert_error() | file:posix()}. add_certfile(Path) -> gen_server:call(?MODULE, {add_certfile, prep_path(Path)}). --spec try_certfile(filename:filename()) -> binary(). +-spec try_certfile(file:filename()) -> binary(). try_certfile(Path0) -> Path = prep_path(Path0), case load_certfile(Path) of @@ -885,7 +885,7 @@ get_cert_path(G, [Root|_] = Acc) -> end, Es) end. --spec prep_path(filename:filename()) -> binary(). +-spec prep_path(file:filename()) -> binary(). prep_path(Path0) -> case filename:pathtype(Path0) of relative -> diff --git a/src/ejabberd_rdbms.erl b/src/ejabberd_rdbms.erl index af3950f03..d2c338548 100644 --- a/src/ejabberd_rdbms.erl +++ b/src/ejabberd_rdbms.erl @@ -108,9 +108,7 @@ needs_sql(Host) -> undefined -> false end. --type sql_type() :: mysql | pgsql | sqlite | mssql | odbc. --spec opt_type(sql_type) -> fun((sql_type()) -> sql_type()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(sql_type) -> fun (mysql) -> mysql; (pgsql) -> pgsql; diff --git a/src/ejabberd_redis_sup.erl b/src/ejabberd_redis_sup.erl index f3dfb7e06..bbcd11449 100644 --- a/src/ejabberd_redis_sup.erl +++ b/src/ejabberd_redis_sup.erl @@ -126,14 +126,7 @@ get_pool_size() -> iolist_to_list(IOList) -> binary_to_list(iolist_to_binary(IOList)). --spec opt_type(redis_connect_timeout) -> fun((pos_integer()) -> pos_integer()); - (redis_db) -> fun((non_neg_integer()) -> non_neg_integer()); - (redis_password) -> fun((binary()) -> binary()); - (redis_port) -> fun((0..65535) -> 0..65535); - (redis_server) -> fun((binary()) -> binary()); - (redis_pool_size) -> fun((pos_integer()) -> pos_integer()); - (redis_queue_type) -> fun((ram | file) -> ram | file); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(redis_connect_timeout) -> fun (I) when is_integer(I), I > 0 -> I end; opt_type(redis_db) -> diff --git a/src/ejabberd_riak_sup.erl b/src/ejabberd_riak_sup.erl index 043c5a484..950acbd9e 100644 --- a/src/ejabberd_riak_sup.erl +++ b/src/ejabberd_riak_sup.erl @@ -173,14 +173,7 @@ transform_options({riak_server, {S, P}}, Opts) -> transform_options(Opt, Opts) -> [Opt|Opts]. --spec opt_type(riak_pool_size) -> fun((pos_integer()) -> pos_integer()); - (riak_port) -> fun((0..65535) -> 0..65535); - (riak_server) -> fun((binary()) -> binary()); - (riak_start_interval) -> fun((pos_integer()) -> pos_integer()); - (riak_cacertfile) -> fun((binary()) -> binary()); - (riak_username) -> fun((binary()) -> binary()); - (riak_password) -> fun((binary()) -> binary()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(riak_pool_size) -> fun (N) when is_integer(N), N >= 1 -> N end; opt_type(riak_port) -> diff --git a/src/ejabberd_router.erl b/src/ejabberd_router.erl index cf4bd8e42..bd9a87ce2 100644 --- a/src/ejabberd_router.erl +++ b/src/ejabberd_router.erl @@ -480,7 +480,7 @@ cache_opts() -> end, [{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}]. --spec clean_cache(node()) -> ok. +-spec clean_cache(node()) -> non_neg_integer(). clean_cache(Node) -> ets_cache:filter( ?ROUTES_CACHE, @@ -499,16 +499,7 @@ clean_cache(Node) -> clean_cache() -> ejabberd_cluster:eval_everywhere(?MODULE, clean_cache, [node()]). --type domain_balancing() :: random | source | destination | - bare_source | bare_destination. --spec opt_type(domain_balancing) -> fun((domain_balancing()) -> domain_balancing()); - (domain_balancing_component_number) -> fun((pos_integer()) -> pos_integer()); - (router_db_type) -> fun((atom()) -> atom()); - (router_use_cache) -> fun((boolean()) -> boolean()); - (router_cache_missed) -> fun((boolean()) -> boolean()); - (router_cache_size) -> fun((timeout()) -> timeout()); - (router_cache_life_time) -> fun((timeout()) -> timeout()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(domain_balancing) -> fun (random) -> random; (source) -> source; diff --git a/src/ejabberd_s2s.erl b/src/ejabberd_s2s.erl index 74234e26e..126700f10 100644 --- a/src/ejabberd_s2s.erl +++ b/src/ejabberd_s2s.erl @@ -708,19 +708,7 @@ get_s2s_state(S2sPid) -> end, [{s2s_pid, S2sPid} | Infos]. --type use_starttls() :: boolean() | optional | required | required_trusted. --spec opt_type(route_subdomains) -> fun((s2s | local) -> s2s | local); - (s2s_access) -> fun((any()) -> any()); - (s2s_ciphers) -> fun((binary()) -> binary()); - (s2s_dhfile) -> fun((binary()) -> binary()); - (s2s_cafile) -> fun((binary()) -> binary()); - (s2s_protocol_options) -> fun(([binary()]) -> binary()); - (s2s_tls_compression) -> fun((boolean()) -> boolean()); - (s2s_use_starttls) -> fun((use_starttls()) -> use_starttls()); - (s2s_zlib) -> fun((boolean()) -> boolean()); - (s2s_timeout) -> fun((timeout()) -> timeout()); - (s2s_queue_type) -> fun((ram | file) -> ram | file); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(route_subdomains) -> fun (s2s) -> s2s; (local) -> local diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index 9968e8012..62227984e 100644 --- a/src/ejabberd_s2s_in.erl +++ b/src/ejabberd_s2s_in.erl @@ -350,21 +350,7 @@ change_shaper(#{shaper := ShaperName, server_host := ServerHost} = State, Shaper = acl:match_rule(ServerHost, ShaperName, jid:make(RServer)), xmpp_stream_in:change_shaper(State, ejabberd_shaper:new(Shaper)). --spec listen_opt_type(shaper) -> fun((any()) -> any()); - (certfile) -> fun((binary()) -> binary()); - (ciphers) -> fun((binary()) -> binary()); - (dhfile) -> fun((binary()) -> binary()); - (cafile) -> fun((binary()) -> binary()); - (protocol_options) -> fun(([binary()]) -> binary()); - (tls_compression) -> fun((boolean()) -> boolean()); - (tls) -> fun((boolean()) -> boolean()); - (supervisor) -> fun((boolean()) -> boolean()); - (max_stanza_type) -> fun((timeout()) -> timeout()); - (max_fsm_queue) -> fun((pos_integer()) -> pos_integer()); - (inet) -> fun((boolean()) -> boolean()); - (inet6) -> fun((boolean()) -> boolean()); - (backlog) -> fun((timeout()) -> timeout()); - (atom()) -> [atom()]. +-spec listen_opt_type(atom()) -> fun((any()) -> any()) | [atom()]. listen_opt_type(shaper) -> fun acl:shaper_rules_validator/1; listen_opt_type(certfile = Opt) -> fun(S) -> diff --git a/src/ejabberd_s2s_out.erl b/src/ejabberd_s2s_out.erl index 99bc44ab8..3c40d805a 100644 --- a/src/ejabberd_s2s_out.erl +++ b/src/ejabberd_s2s_out.erl @@ -443,13 +443,7 @@ maybe_report_huge_timeout(Opt, T) when is_integer(T), T >= 1000 -> maybe_report_huge_timeout(_, _) -> ok. --spec opt_type(outgoing_s2s_families) -> fun(([ipv4|ipv6]) -> [inet|inet6]); - (outgoing_s2s_port) -> fun((0..65535) -> 0..65535); - (outgoing_s2s_timeout) -> fun((timeout()) -> timeout()); - (s2s_dns_retries) -> fun((non_neg_integer()) -> non_neg_integer()); - (s2s_dns_timeout) -> fun((timeout()) -> timeout()); - (s2s_max_retry_delay) -> fun((pos_integer()) -> pos_integer()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(outgoing_s2s_families) -> fun(Families) -> lists:map( diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 96478be93..c39a023ab 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -281,25 +281,7 @@ transform_listen_option({host, Host, Os}, Opts) -> transform_listen_option(Opt, Opts) -> [Opt|Opts]. --spec listen_opt_type(access) -> fun((any()) -> any()); - (shaper_rule) -> fun((any()) -> any()); - (certfile) -> fun((binary()) -> binary()); - (ciphers) -> fun((binary()) -> binary()); - (dhfile) -> fun((binary()) -> binary()); - (cafile) -> fun((binary()) -> binary()); - (protocol_options) -> fun(([binary()]) -> binary()); - (tls_compression) -> fun((boolean()) -> boolean()); - (tls) -> fun((boolean()) -> boolean()); - (check_from) -> fun((boolean()) -> boolean()); - (password) -> fun((boolean()) -> boolean()); - (hosts) -> fun(([{binary(), [{password, binary()}]}]) -> - [{binary(), binary() | undefined}]); - (max_stanza_type) -> fun((timeout()) -> timeout()); - (max_fsm_queue) -> fun((pos_integer()) -> pos_integer()); - (inet) -> fun((boolean()) -> boolean()); - (inet6) -> fun((boolean()) -> boolean()); - (backlog) -> fun((timeout()) -> timeout()); - (atom()) -> [atom()]. +-spec listen_opt_type(atom()) -> fun((any()) -> any()) | [atom()]. listen_opt_type(access) -> fun acl:access_rules_validator/1; listen_opt_type(shaper_rule) -> fun acl:shaper_rules_validator/1; listen_opt_type(certfile) -> diff --git a/src/ejabberd_shaper.erl b/src/ejabberd_shaper.erl index 8b6ca4125..e42cb4121 100644 --- a/src/ejabberd_shaper.erl +++ b/src/ejabberd_shaper.erl @@ -147,7 +147,6 @@ transform_options({shaper, List}, Opts) when is_list(List) -> transform_options(Opt, Opts) -> [Opt | Opts]. --spec opt_type(shaper) -> fun((any()) -> any()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(shaper) -> fun(V) -> V end; opt_type(_) -> [shaper]. diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 9e9a2d191..d9e211656 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -898,7 +898,7 @@ cache_opts() -> end, [{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}]. --spec clean_cache(node()) -> ok. +-spec clean_cache(node()) -> non_neg_integer(). clean_cache(Node) -> ets_cache:filter( ?SM_CACHE, @@ -1012,12 +1012,7 @@ kick_user(User, Server, Resource) -> make_sid() -> {p1_time_compat:unique_timestamp(), self()}. --spec opt_type(sm_db_type) -> fun((atom()) -> atom()); - (sm_use_cache) -> fun((boolean()) -> boolean()); - (sm_cache_missed) -> fun((boolean()) -> boolean()); - (sm_cache_size) -> fun((timeout()) -> timeout()); - (sm_cache_life_time) -> fun((timeout()) -> timeout()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(sm_db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end; opt_type(O) when O == sm_use_cache; O == sm_cache_missed -> fun(B) when is_boolean(B) -> B end; diff --git a/src/ejabberd_sql.erl b/src/ejabberd_sql.erl index f126cd259..e6c5c0212 100644 --- a/src/ejabberd_sql.erl +++ b/src/ejabberd_sql.erl @@ -1116,20 +1116,7 @@ check_error({error, Why} = Err, Query) -> check_error(Result, _Query) -> Result. --spec opt_type(sql_database) -> fun((binary()) -> binary()); - (sql_keepalive_interval) -> fun((pos_integer()) -> pos_integer()); - (sql_password) -> fun((binary()) -> binary()); - (sql_port) -> fun((0..65535) -> 0..65535); - (sql_server) -> fun((binary()) -> binary()); - (sql_username) -> fun((binary()) -> binary()); - (sql_ssl) -> fun((boolean()) -> boolean()); - (sql_ssl_verify) -> fun((boolean()) -> boolean()); - (sql_ssl_certfile) -> fun((boolean()) -> boolean()); - (sql_ssl_cafile) -> fun((boolean()) -> boolean()); - (sql_query_timeout) -> fun((pos_integer()) -> pos_integer()); - (sql_connect_timeout) -> fun((pos_integer()) -> pos_integer()); - (sql_queue_type) -> fun((ram | file) -> ram | file); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(sql_database) -> fun iolist_to_binary/1; opt_type(sql_keepalive_interval) -> fun (I) when is_integer(I), I > 0 -> I end; diff --git a/src/ejabberd_sql_sup.erl b/src/ejabberd_sql_sup.erl index 874a9f99d..b6315c175 100644 --- a/src/ejabberd_sql_sup.erl +++ b/src/ejabberd_sql_sup.erl @@ -212,9 +212,7 @@ read_lines(Fd, File, Acc) -> [] end. --spec opt_type(sql_pool_size) -> fun((pos_integer()) -> pos_integer()); - (sql_start_interval) -> fun((pos_integer()) -> pos_integer()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(sql_pool_size) -> fun (I) when is_integer(I), I > 0 -> I end; opt_type(sql_start_interval) -> diff --git a/src/ejabberd_web_admin.erl b/src/ejabberd_web_admin.erl index 46c957330..c7bded027 100644 --- a/src/ejabberd_web_admin.erl +++ b/src/ejabberd_web_admin.erl @@ -2695,8 +2695,7 @@ make_menu_item(item, 3, URI, Name, Lang) -> %%%================================== --spec opt_type(access_readonly) -> fun((any()) -> any()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(access_readonly) -> fun acl:access_rules_validator/1; opt_type(_) -> [access_readonly]. diff --git a/src/eldap_utils.erl b/src/eldap_utils.erl index ce642a779..d757aa31b 100644 --- a/src/eldap_utils.erl +++ b/src/eldap_utils.erl @@ -333,24 +333,7 @@ collect_parts_bit([{?N_BIT_STRING,<>}|Rest],Acc,Uacc) -> collect_parts_bit([],Acc,Uacc) -> list_to_binary([Uacc|lists:reverse(Acc)]). --type deref_aliases() :: never | searching | finding | always. --type uids() :: binary() | {binary()} | {binary(), binary()}. --spec opt_type(deref_aliases) -> fun((deref_aliases()) -> deref_aliases()); - (ldap_backups) -> fun(([binary()]) -> [binary()]); - (ldap_base) -> fun((binary()) -> binary()); - (ldap_deref_aliases) -> fun((deref_aliases()) -> deref_aliases()); - (ldap_encrypt) -> fun((tls | starttls | none) -> tls | starttls | none); - (ldap_password) -> fun((binary()) -> binary()); - (ldap_port) -> fun((0..65535) -> 0..65535); - (ldap_rootdn) -> fun((binary()) -> binary()); - (ldap_servers) -> fun(([binary()]) -> [binary()]); - (ldap_tls_certfile) -> fun((binary()) -> string()); - (ldap_tls_cacertfile) -> fun((binary()) -> string()); - (ldap_tls_depth) -> fun((non_neg_integer()) -> non_neg_integer()); - (ldap_tls_verify) -> fun((hard | soft | false) -> hard | soft | false); - (ldap_filter) -> fun((binary()) -> binary()); - (ldap_uids) -> fun((uids()) -> uids()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(deref_aliases) -> fun(unspecified) -> unspecified; (never) -> never; diff --git a/src/ext_mod.erl b/src/ext_mod.erl index 59cbb87b6..02165bea8 100644 --- a/src/ext_mod.erl +++ b/src/ext_mod.erl @@ -680,8 +680,7 @@ format({Key, Val}) when is_binary(Val) -> format({Key, Val}) -> % TODO: improve Yaml parsing {Key, Val}. --spec opt_type(allow_contrib_modules) -> fun((boolean()) -> boolean()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(allow_contrib_modules) -> fun (false) -> false; (no) -> false; diff --git a/src/gen_iq_handler.erl b/src/gen_iq_handler.erl index 49d1d8e3e..f6a6744fd 100644 --- a/src/gen_iq_handler.erl +++ b/src/gen_iq_handler.erl @@ -154,8 +154,7 @@ transform_module_options(Opts) -> Opt end, Opts). --spec opt_type(iqdisc) -> fun((any()) -> no_queue); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(iqdisc) -> fun check_type/1; opt_type(_) -> [iqdisc]. diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 8d225461c..c15b50443 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -928,8 +928,7 @@ is_opt_list(L) when is_list(L) -> is_opt_list(_) -> false. --spec opt_type(modules) -> fun(([{atom(), list()}]) -> [{atom(), list()}]); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(modules) -> fun(Mods) -> lists:map( diff --git a/src/mod_bosh.erl b/src/mod_bosh.erl index 2aca662c1..a393597eb 100644 --- a/src/mod_bosh.erl +++ b/src/mod_bosh.erl @@ -253,7 +253,7 @@ cache_opts() -> end, [{max_size, MaxSize}, {cache_missed, CacheMissed}, {life_time, LifeTime}]. --spec clean_cache(node()) -> ok. +-spec clean_cache(node()) -> non_neg_integer(). clean_cache(Node) -> ets_cache:filter( ?BOSH_CACHE, diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl index 83bebecb7..73034ec3f 100644 --- a/src/mod_carboncopy.erl +++ b/src/mod_carboncopy.erl @@ -345,7 +345,7 @@ cache_nodes(Mod, Host) -> false -> ejabberd_cluster:get_nodes() end. --spec clean_cache(node()) -> ok. +-spec clean_cache(node()) -> non_neg_integer(). clean_cache(Node) -> ets_cache:filter( ?CARBONCOPY_CACHE, diff --git a/src/mod_multicast.erl b/src/mod_multicast.erl index 632c3d271..2e4241424 100644 --- a/src/mod_multicast.erl +++ b/src/mod_multicast.erl @@ -51,7 +51,7 @@ ts :: integer()}). -record(dest, {jid_string :: binary() | none, - jid_jid :: xmpp:jid(), + jid_jid :: jid(), type :: to | cc | bcc, address :: address()}). @@ -536,7 +536,7 @@ decide_action_groups(Groups) -> %%% Route packet %%%------------------------- --spec route_packet(jid(), #dest{}, xmpp:stanza(), [addresses()], [addresses()]) -> 'ok'. +-spec route_packet(jid(), #dest{}, stanza(), [addresses()], [addresses()]) -> 'ok'. route_packet(From, ToDest, Packet, Others, Addresses) -> Dests = case ToDest#dest.type of bcc -> []; @@ -545,7 +545,7 @@ route_packet(From, ToDest, Packet, Others, Addresses) -> route_packet2(From, ToDest#dest.jid_string, Dests, Packet, {Others, Addresses}). --spec route_packet_multicast(jid(), binary(), xmpp:stanza(), [#dest{}], [address()], #limits{}) -> 'ok'. +-spec route_packet_multicast(jid(), binary(), stanza(), [#dest{}], [address()], #limits{}) -> 'ok'. route_packet_multicast(From, ToS, Packet, Dests, Addresses, Limits) -> Type_of_stanza = type_of_stanza(Packet), @@ -557,7 +557,7 @@ route_packet_multicast(From, ToS, Packet, Dests, Addresses) end, Fragmented_dests). --spec route_packet2(jid(), binary(), [#dest{}], xmpp:stanza(), {[address()], [address()]} | [address()]) -> 'ok'. +-spec route_packet2(jid(), binary(), [#dest{}], stanza(), {[address()], [address()]} | [address()]) -> 'ok'. route_packet2(From, ToS, Dests, Packet, Addresses) -> Els = case append_dests(Dests, Addresses) of [] -> diff --git a/src/mod_register.erl b/src/mod_register.erl index ea822e339..cbc3893fd 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -633,8 +633,7 @@ mod_options(_Host) -> [{subject, <<"">>}, {body, <<"">>}]}]. --spec opt_type(registration_timeout) -> fun((timeout()) -> timeout()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(registration_timeout) -> fun (TO) when is_integer(TO), TO > 0 -> TO; (infinity) -> infinity; diff --git a/src/rest.erl b/src/rest.erl index 6e48f0774..16fa20eb0 100644 --- a/src/rest.erl +++ b/src/rest.erl @@ -219,9 +219,7 @@ url(Server, Path, Params) -> url(Url, Custom++Params) end. --spec opt_type(ext_api_http_pool_size) -> fun((pos_integer()) -> pos_integer()); - (ext_api_url) -> fun((binary()) -> binary()); - (atom()) -> [atom()]. +-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()]. opt_type(ext_api_http_pool_size) -> fun (X) when is_integer(X), X > 0 -> X end; opt_type(ext_api_url) -> -- 2.40.0