It is only warning. You must be sure that all your branches bound variable or in very rare case you know what you are doing.<br><br><div class="gmail_quote">On Thu, Jul 10, 2008 at 10:41 AM, Alexander Lamb <alexander.lamb@rodanotech.ch> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello List,<br>
<br>
Here is a very simple code to search if a supplied password is correct<br>
or not:<br>
<br>
F1 = fun() -> mnesia:match_object(systems,<br>
#system_info{full_attribute = {System_Name,admin_password}, _ = '_'},<br>
read) end,<br>
case Password of<br>
[] -> MD5_Password = [];<br>
_Any -> MD5_Password = erlang:md5(Password)<br>
end,</blockquote><div><br>% It will remove warning message.<br>
MD5_Password = case Password of<br> [] -> [];<br> _ -> erlang:md5(Password)<br> end,<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
case mnesia:transaction(F1) of<br>
{atomic, []} -> {error, unknown_system};<br>
{atomic, [#system_info{data = MD5_Password}]} -> {ok, password};<br>
{atomic, _} -> {error, bad_password};<br>
{aborted, Reason} -> {error, Reason}<br>
end<br>
<br>
<br>
<br>
Basically, if supplied Password is empty, the MD5_Password must be<br>
empty. If not, I encrypt the Password to compare it with stored version.<br>
<br>
My problem is that it compiles with a warning:<br>
<br>
./cs_systems.erl:173: Warning: variable 'MD5_Password' exported from<br>
'case' (line 167)<br>
<br>
Why? Obviously I am trying to match the password in the record I found<br>
with the password I supply.<br>
<br>
Thanks,<br>
<br>
Alex<br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil