diff options
author | Hans Bolinder <[email protected]> | 2013-04-29 15:28:32 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2013-05-06 12:14:14 +0200 |
commit | fa6ce2d4653bd7955c8c478a143119dbdd6b9d06 (patch) | |
tree | 0bafb8b34d91d7780bf588b614c6e04f784ed88d | |
parent | 19d41eefa1cf4856587930d99959bbed73a818b5 (diff) | |
download | otp-fa6ce2d4653bd7955c8c478a143119dbdd6b9d06.tar.gz otp-fa6ce2d4653bd7955c8c478a143119dbdd6b9d06.tar.bz2 otp-fa6ce2d4653bd7955c8c478a143119dbdd6b9d06.zip |
Fix unmatched_returns warning in Kernel
If the file given by the Kernel application variable 'error_logger'
cannot be opened a crash will occur.
-rw-r--r-- | lib/kernel/src/error_logger.erl | 20 | ||||
-rw-r--r-- | lib/kernel/src/kernel.erl | 11 |
2 files changed, 19 insertions, 12 deletions
diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl index 92c1eb80dc..b8fbf02feb 100644 --- a/lib/kernel/src/error_logger.erl +++ b/lib/kernel/src/error_logger.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2012. All Rights Reserved. +%% Copyright Ericsson AB 1996-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -245,16 +245,18 @@ notify(Msg) -> -spec swap_handler(Type :: swap_handler_type()) -> any(). swap_handler(tty) -> - gen_event:swap_handler(error_logger, {error_logger, swap}, - {error_logger_tty_h, []}), - simple_logger(); + R = gen_event:swap_handler(error_logger, {error_logger, swap}, + {error_logger_tty_h, []}), + ok = simple_logger(), + R; swap_handler({logfile, File}) -> - gen_event:swap_handler(error_logger, {error_logger, swap}, - {error_logger_file_h, File}), - simple_logger(); + R = gen_event:swap_handler(error_logger, {error_logger, swap}, + {error_logger_file_h, File}), + ok = simple_logger(), + R; swap_handler(silent) -> - gen_event:delete_handler(error_logger, error_logger, delete), - simple_logger(); + _ = gen_event:delete_handler(error_logger, error_logger, delete), + ok = simple_logger(); swap_handler(false) -> ok. % keep primitive event handler as-is diff --git a/lib/kernel/src/kernel.erl b/lib/kernel/src/kernel.erl index 1e07620a3e..ecdb32424a 100644 --- a/lib/kernel/src/kernel.erl +++ b/lib/kernel/src/kernel.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% Copyright Ericsson AB 1996-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -32,8 +32,13 @@ start(_, []) -> case supervisor:start_link({local, kernel_sup}, kernel, []) of {ok, Pid} -> Type = get_error_logger_type(), - error_logger:swap_handler(Type), - {ok, Pid, []}; + case error_logger:swap_handler(Type) of + ok -> {ok, Pid, []}; + Error -> + %% Not necessary since the node will crash anyway: + exit(Pid, shutdown), + Error + end; Error -> Error end. |