Browse Source

Fix exported from case warnings.

Michael Truog 10 years ago
parent
commit
cebd2c88cf
4 changed files with 59 additions and 49 deletions
  1. 15 11
      src/epgsql_fdatetime.erl
  2. 12 8
      src/epgsql_idatetime.erl
  3. 24 24
      src/epgsql_sock.erl
  4. 8 6
      src/epgsql_wire.erl

+ 15 - 11
src/epgsql_fdatetime.erl

@@ -38,9 +38,9 @@ j2date(N) ->
     Q2 = J2 div 1461,
     J3 = J2 - Q2 * 1461,
     Y = J3 * 4 div 1461,
-    case Y of
-        0 -> J4 = ((J3 + 306) rem 366) + 123;
-        _ -> J4 = ((J3 + 305) rem 365) + 123
+    J4 = case Y of
+        0 -> ((J3 + 306) rem 366) + 123;
+        _ -> ((J3 + 305) rem 365) + 123
     end,
     Year = (Y + Q2 * 4) - 4800,
     Q3 = J4 * 2141 div 65536,
@@ -49,13 +49,17 @@ j2date(N) ->
     {Year, Month, Day}.
 
 date2j({Y, M, D}) ->
-    case M > 2 of
+    M2 = case M > 2 of
         true ->
-            M2 = M + 1,
-            Y2 = Y + 4800;
+            M + 1;
         false ->
-            M2 = M + 13,
-            Y2 = Y + 4799
+            M + 13
+    end,
+    Y2 = case M > 2 of
+        true ->
+            Y + 4800;
+        false ->
+            Y + 4799
     end,
     C = Y2 div 100,
     J1 = Y2 * 365 - 32167,
@@ -101,9 +105,9 @@ now2f({MegaSecs, Secs, MicroSecs}) ->
     MegaSecs * 1000000 + Secs + MicroSecs / 1000000.0 - ?postgres_epoc_secs.
 
 tmodulo(T, U) ->
-    case T < 0 of
-        true  -> Q = ceiling(T / U);
-        false -> Q = floor(T / U)
+    Q = case T < 0 of
+        true  -> ceiling(T / U);
+        false -> floor(T / U)
     end,
     case Q of
         0 -> {T, Q};

+ 12 - 8
src/epgsql_idatetime.erl

@@ -41,9 +41,9 @@ j2date(N) ->
     Q2 = J2 div 1461,
     J3 = J2 - Q2 * 1461,
     Y = J3 * 4 div 1461,
-    case Y of
-        0 -> J4 = ((J3 + 306) rem 366) + 123;
-        _ -> J4 = ((J3 + 305) rem 365) + 123
+    J4 = case Y of
+        0 -> ((J3 + 306) rem 366) + 123;
+        _ -> ((J3 + 305) rem 365) + 123
     end,
     Year = (Y + Q2 * 4) - 4800,
     Q3 = J4 * 2141 div 65536,
@@ -52,13 +52,17 @@ j2date(N) ->
     {Year, Month, Day}.
 
 date2j({Y, M, D}) ->
-    case M > 2 of
+    M2 = case M > 2 of
         true ->
-            M2 = M + 1,
-            Y2 = Y + 4800;
+            M + 1;
         false ->
-            M2 = M + 13,
-            Y2 = Y + 4799
+            M + 13
+    end,
+    Y2 = case M > 2 of
+        true ->
+            Y + 4800;
+        false ->
+            Y + 4799
     end,
     C = Y2 div 100,
     J1 = Y2 * 365 - 32167,

+ 24 - 24
src/epgsql_sock.erl

@@ -99,11 +99,11 @@ handle_call({update_type_cache, TypeInfos}, _From, #state{codec = Codec} = State
     {reply, ok, State#state{codec = Codec2}};
 
 handle_call({get_parameter, Name}, _From, State) ->
-    case lists:keysearch(Name, 1, State#state.parameters) of
+    Value1 = case lists:keysearch(Name, 1, State#state.parameters) of
         {value, {Name, Value}} -> Value;
-        false                  -> Value = undefined
+        false                  -> undefined
     end,
-    {reply, {ok, Value}, State};
+    {reply, {ok, Value1}, State};
 
 handle_call(Command, From, State) ->
     #state{queue = Q} = State,
@@ -185,9 +185,9 @@ command({connect, Host, Username, Password, Opts}, State) ->
                      end,
 
             Opts2 = ["user", 0, Username, 0],
-            case proplists:get_value(database, Opts, undefined) of
-                undefined -> Opts3 = Opts2;
-                Database  -> Opts3 = [Opts2 | ["database", 0, Database, 0]]
+            Opts3 = case proplists:get_value(database, Opts, undefined) of
+                undefined -> Opts2;
+                Database  -> [Opts2 | ["database", 0, Database, 0]]
             end,
             send(State2, [<<196608:?int32>>, Opts3, 0]),
             Async   = proplists:get_value(async, Opts, undefined),
@@ -271,9 +271,9 @@ command({describe_portal, Name}, State) ->
     {noreply, State};
 
 command({close, Type, Name}, State) ->
-    case Type of
-        statement -> Type2 = ?PREPARED_STATEMENT;
-        portal    -> Type2 = ?PORTAL
+    Type2 = case Type of
+        statement -> ?PREPARED_STATEMENT;
+        portal    -> ?PORTAL
     end,
     send(State, ?CLOSE, [Type2, Name, 0]),
     send(State, ?FLUSH, []),
@@ -479,23 +479,23 @@ auth({?AUTHENTICATION_REQUEST, <<5:?int32, Salt:4/binary>>}, State) ->
     {noreply, State};
 
 auth({?AUTHENTICATION_REQUEST, <<M:?int32, _/binary>>}, State) ->
-    case M of
-        2 -> Method = kerberosV5;
-        4 -> Method = crypt;
-        6 -> Method = scm;
-        7 -> Method = gss;
-        8 -> Method = sspi;
-        _ -> Method = unknown
+    Method = case M of
+        2 -> kerberosV5;
+        4 -> crypt;
+        6 -> scm;
+        7 -> gss;
+        8 -> sspi;
+        _ -> unknown
     end,
     State2 = finish(State, {error, {unsupported_auth_method, Method}}),
     {stop, normal, State2};
 
 %% ErrorResponse
 auth({error, E}, State) ->
-    case E#error.code of
-        <<"28000">> -> Why = invalid_authorization_specification;
-        <<"28P01">> -> Why = invalid_password;
-        Any         -> Why = Any
+    Why = case E#error.code of
+        <<"28000">> -> invalid_authorization_specification;
+        <<"28P01">> -> invalid_password;
+        Any         -> Any
     end,
     {stop, normal, finish(State, {error, Why})};
 
@@ -699,9 +699,9 @@ on_message({?PARAMETER_STATUS, Data}, State) ->
 
 %% NotificationResponse
 on_message({?NOTIFICATION, <<Pid:?int32, Strings/binary>>}, State) ->
-    case epgsql_wire:decode_strings(Strings) of
-        [Channel, Payload] -> ok;
-        [Channel]          -> Payload = <<>>
+    {Channel1, Payload1} = case epgsql_wire:decode_strings(Strings) of
+        [Channel, Payload] -> {Channel, Payload};
+        [Channel]          -> {Channel, <<>>}
     end,
-    State2 = notify_async(State, {notification, Channel, Pid, Payload}),
+    State2 = notify_async(State, {notification, Channel1, Pid, Payload1}),
     {noreply, State2}.

+ 8 - 6
src/epgsql_wire.erl

@@ -100,9 +100,11 @@ decode_data([], _Bin, Acc, _Codec) ->
 decode_data([_C | T], <<-1:?int32, Rest/binary>>, Acc, Codec) ->
     decode_data(T, Rest, [null | Acc], Codec);
 decode_data([C | T], <<Len:?int32, Value:Len/binary, Rest/binary>>, Acc, Codec) ->
-    case C of
-        #column{type = Type, format = 1}   -> Value2 = epgsql_binary:decode(Type, Value, Codec);
-        #column{}                          -> Value2 = Value
+    Value2 = case C of
+        #column{type = Type, format = 1} ->
+            epgsql_binary:decode(Type, Value, Codec);
+        #column{} ->
+            Value
     end,
     decode_data(T, Rest, [Value2 | Acc], Codec).
 
@@ -148,9 +150,9 @@ encode_types([], Count, Acc, _Codec) ->
     <<Count:?int16, Acc/binary>>;
 
 encode_types([Type | T], Count, Acc, Codec) ->
-    case Type of
-        undefined -> Oid = 0;
-        _Any      -> Oid = epgsql_binary:type2oid(Type, Codec)
+    Oid = case Type of
+        undefined -> 0;
+        _Any      -> epgsql_binary:type2oid(Type, Codec)
     end,
     encode_types(T, Count + 1, <<Acc/binary, Oid:?int32>>, Codec).