remove use of deprecated random module

This commit is contained in:
Tristan Sloughter 2016-05-12 21:24:27 -05:00
parent 0c1636e75a
commit 001e7fcf4b
2 changed files with 13 additions and 2 deletions

View file

@ -10,6 +10,8 @@
[{platform_define, "^[0-9]+", namespaced_types}, [{platform_define, "^[0-9]+", namespaced_types},
{platform_define, "^[0-9]+", have_callback_support}, {platform_define, "^[0-9]+", have_callback_support},
{platform_define, "^R1[4|5]", deprecated_crypto}, {platform_define, "^R1[4|5]", deprecated_crypto},
{platform_define, "^1[8|9]", rand_module},
{platform_define, "^2", rand_module},
debug_info, debug_info,
warnings_as_errors]}. warnings_as_errors]}.

View file

@ -174,8 +174,7 @@ real_dir_path(Path) ->
%% function of the same name. %% function of the same name.
-spec insecure_mkdtemp() -> TmpDirPath::file:name(). -spec insecure_mkdtemp() -> TmpDirPath::file:name().
insecure_mkdtemp() -> insecure_mkdtemp() ->
random:seed(os:timestamp()), UniqueNumber = erlang:integer_to_list(erlang:trunc(random_uniform() * 1000000000000)),
UniqueNumber = erlang:integer_to_list(erlang:trunc(random:uniform() * 1000000000000)),
TmpDirPath = TmpDirPath =
filename:join([tmp(), lists:flatten([".tmp_dir", UniqueNumber])]), filename:join([tmp(), lists:flatten([".tmp_dir", UniqueNumber])]),
@ -321,6 +320,16 @@ hex0(I) -> $0 + I.
sub_files(From) -> sub_files(From) ->
{ok, SubFiles} = file:list_dir(From), {ok, SubFiles} = file:list_dir(From),
[filename:join(From, SubFile) || SubFile <- SubFiles]. [filename:join(From, SubFile) || SubFile <- SubFiles].
-ifdef(rand_module).
random_uniform() ->
rand:uniform().
-else.
random_uniform() ->
random:seed(os:timestamp()),
random:uniform().
-endif.
%%%=================================================================== %%%===================================================================
%%% Test Functions %%% Test Functions
%%%=================================================================== %%%===================================================================