From a85d2dae32ebe1d4495df9936c86153e8398c849 Mon Sep 17 00:00:00 2001
From: pharook <ph@rook.cz>
Date: Tue, 21 Aug 2012 11:18:59 +0200
Subject: [PATCH] Upraveno cteni konfiguracnich souboru - odchyceny navraty
 'do', zruseno nadbytecne kontrolni cteni (#533)

---
 src/warden-client/lib/WardenClientConf.pm | 12 ++++--------
 src/warden-server/lib/Warden.pm           | 12 ++++--------
 src/warden-server/lib/WardenConf.pm       | 12 ++++--------
 3 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/src/warden-client/lib/WardenClientConf.pm b/src/warden-client/lib/WardenClientConf.pm
index c185aea..7720f6b 100755
--- a/src/warden-client/lib/WardenClientConf.pm
+++ b/src/warden-client/lib/WardenClientConf.pm
@@ -26,15 +26,11 @@ sub loadConf
   our $SSL_CA_FILE = undef;
   our $MAX_RCV_EVENTS_LIMIT = undef;
 
-  # read config file
-  if ( ! open( TMP, $conf_file) ) {
-    die("Can't read config file '$conf_file': $!\n");
-  }
-  close TMP;
-
   # load set variables by user
-  if ( !do $conf_file ) {
-    die("Errors in config file '$conf_file': $@");
+  unless (do $conf_file) {
+    die("Errors in config file '$conf_file': $@") if $@;
+    die("Can't read config file '$conf_file': $!") unless defined $_;
+    # if $_ defined, it's retvalue of last statement of conf, for which we don't care
   }
 
   return ($URI, $SSL_KEY_FILE, $SSL_CERT_FILE, $SSL_CA_FILE, $MAX_RCV_EVENTS_LIMIT);
diff --git a/src/warden-server/lib/Warden.pm b/src/warden-server/lib/Warden.pm
index 0fcc219..742c15e 100755
--- a/src/warden-server/lib/Warden.pm
+++ b/src/warden-server/lib/Warden.pm
@@ -36,15 +36,11 @@ our $DB_HOST	= undef;
 our $MAX_EVENTS_LIMIT	= undef;
 our %VALID_STRINGS	= undef;
 
-# read config file
-if (!open( TMP, $conf_file)) {
-  errMsg("Can't read config file '$conf_file': $!\n");
-}
-close TMP;
-
 # load set variables by user
-if (!do $conf_file) {
-  errMsg("Errors in config file '$conf_file': $@");
+unless (do $conf_file) {
+  errMsg("Errors in config file '$conf_file': $@") if $@;
+  errMsg("Can't read config file '$conf_file': $!") unless defined $_;
+  # if $_ defined, it's retvalue of last statement of conf, for which we don't care
 }
 
 
diff --git a/src/warden-server/lib/WardenConf.pm b/src/warden-server/lib/WardenConf.pm
index 1d1ad54..db32d5a 100755
--- a/src/warden-server/lib/WardenConf.pm
+++ b/src/warden-server/lib/WardenConf.pm
@@ -25,15 +25,11 @@ sub loadConf
   our $SSL_CERT_FILE 	= undef;
   our $SSL_CA_FILE 	= undef;
 
-  # read config file
-  if ( ! open( TMP, $conf_file) ) {
-    die "Can't read config file '$conf_file': $!\n";
-  }
-  close TMP;
-
   # load set variables by user
-  if ( !do $conf_file ) {
-    die("Errors in config file '$conf_file': $@");
+  unless (do $conf_file) {
+    die("Errors in config file '$conf_file': $@") if $@;
+    die("Can't read config file '$conf_file': $!") unless defined $_;
+    # if $_ defined, it's retvalue of last statement of conf, for which we don't care
   }
 
   return ($URI, $SSL_KEY_FILE, $SSL_CERT_FILE, $SSL_CA_FILE);
-- 
GitLab