Skip to content

Commit

Permalink
[storage] To strictly check integer values(2)
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara authored and mocchira committed Mar 27, 2018
1 parent 4c407ad commit 81d673b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/leo_storage/src/leo_storage_statistics.erl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ get_and_set_mq_value([{?SNMP_MQ_NUM_OF_DEL_DIR = Id, ?QUEUE_ID_DEL_DIR}|Rest]) -
end,
SoFar + RetN
end, 0, ?del_dir_queue_list()),
catch snmp_generic:variable_set(Id, V),
catch snmp_generic:variable_set(Id, check_number(V)),
get_and_set_mq_value(Rest);
get_and_set_mq_value([{Id, QId}|Rest]) ->
V = case catch leo_mq_api:status(QId) of
Expand All @@ -132,7 +132,7 @@ get_and_set_mq_value([{Id, QId}|Rest]) ->
_ ->
0
end,
catch snmp_generic:variable_set(Id, V),
catch snmp_generic:variable_set(Id, check_number(V)),
get_and_set_mq_value(Rest).


Expand Down Expand Up @@ -225,9 +225,10 @@ to_unixtime(DateTime) ->

%% @private
check_number(V) when is_number(V) ->
case (leo_math:power(2,32) =< V) of
Max = leo_math:power(2, 32),
case (Max =< V) of
true ->
4294967296;
Max;
false when V < 0 ->
0;
false ->
Expand Down

0 comments on commit 81d673b

Please sign in to comment.