[PATCH xorg-gtest 03/11] xserver: use temporary variable for log file too

2012-08-16 Thread Peter Hutterer
And use + for string concatination, the code as-is was a legacy from const
char* handling.

Signed-off-by: Peter Hutterer 
---
 src/xserver.cpp | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/xserver.cpp b/src/xserver.cpp
index 86c8484..eb64d3b 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -266,28 +266,27 @@ void xorg::testing::XServer::TestStartup(void) {
 throw std::runtime_error(message);
   }
 
+  std::string log = d_->options["-logfile"];
+
   /* The Xorg server won't start unless the log file and the old log file are
* writable. */
   std::ofstream log_test;
-  log_test.open(d_->options["-logfile"].c_str(), std::ofstream::out);
+  log_test.open(log.c_str(), std::ofstream::out);
   log_test.close();
   if (log_test.fail()) {
 std::string message;
-message += "X.org server log file ";
-message += d_->options["-logfile"];
-message += " is not writable.";
+message += "X.org server log file " + log + " is not writable.";
 throw std::runtime_error(message);
   }
 
-  std::string old_log_file = d_->options["-logfile"];
-  old_log_file += ".old";
+  std::string old_log_file = log + ".old";
+
+
   log_test.open(old_log_file.c_str(), std::ofstream::out);
   log_test.close();
   if (log_test.fail()) {
 std::string message;
-message += "X.org old server log file ";
-message += old_log_file;
-message += " is not writable.";
+message += "X.org old server log file " + old_log_file + " is not 
writable.";
 throw std::runtime_error(message);
   }
 
-- 
1.7.11.2

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH xorg-gtest 03/11] xserver: use temporary variable for log file too

2012-08-16 Thread Chase Douglas

On 08/15/2012 11:36 PM, Peter Hutterer wrote:

And use + for string concatination, the code as-is was a legacy from const
char* handling.

Signed-off-by: Peter Hutterer 
---
  src/xserver.cpp | 17 -
  1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/xserver.cpp b/src/xserver.cpp
index 86c8484..eb64d3b 100644
--- a/src/xserver.cpp
+++ b/src/xserver.cpp
@@ -266,28 +266,27 @@ void xorg::testing::XServer::TestStartup(void) {
  throw std::runtime_error(message);
}

+  std::string log = d_->options["-logfile"];
+
/* The Xorg server won't start unless the log file and the old log file are
 * writable. */
std::ofstream log_test;
-  log_test.open(d_->options["-logfile"].c_str(), std::ofstream::out);
+  log_test.open(log.c_str(), std::ofstream::out);
log_test.close();
if (log_test.fail()) {
  std::string message;
-message += "X.org server log file ";
-message += d_->options["-logfile"];
-message += " is not writable.";
+message += "X.org server log file " + log + " is not writable.";


I think this could be simplified to:

std::string message =
"X.org server log file " + log + " is not writeable.";


  throw std::runtime_error(message);
}

-  std::string old_log_file = d_->options["-logfile"];
-  old_log_file += ".old";
+  std::string old_log_file = log + ".old";
+
+
log_test.open(old_log_file.c_str(), std::ofstream::out);
log_test.close();
if (log_test.fail()) {
  std::string message;
-message += "X.org old server log file ";
-message += old_log_file;
-message += " is not writable.";
+message += "X.org old server log file " + old_log_file + " is not 
writable.";


Same simplification here


  throw std::runtime_error(message);
}




Either way,

Reviewed-by: Chase Douglas 
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH xorg-gtest 03/11] xserver: use temporary variable for log file too

2012-08-16 Thread Peter Hutterer
On Thu, Aug 16, 2012 at 08:49:24AM -0700, Chase Douglas wrote:
> On 08/15/2012 11:36 PM, Peter Hutterer wrote:
> >And use + for string concatination, the code as-is was a legacy from const
> >char* handling.
> >
> >Signed-off-by: Peter Hutterer 
> >---
> >  src/xserver.cpp | 17 -
> >  1 file changed, 8 insertions(+), 9 deletions(-)
> >
> >diff --git a/src/xserver.cpp b/src/xserver.cpp
> >index 86c8484..eb64d3b 100644
> >--- a/src/xserver.cpp
> >+++ b/src/xserver.cpp
> >@@ -266,28 +266,27 @@ void xorg::testing::XServer::TestStartup(void) {
> >  throw std::runtime_error(message);
> >}
> >
> >+  std::string log = d_->options["-logfile"];
> >+
> >/* The Xorg server won't start unless the log file and the old log file 
> > are
> > * writable. */
> >std::ofstream log_test;
> >-  log_test.open(d_->options["-logfile"].c_str(), std::ofstream::out);
> >+  log_test.open(log.c_str(), std::ofstream::out);
> >log_test.close();
> >if (log_test.fail()) {
> >  std::string message;
> >-message += "X.org server log file ";
> >-message += d_->options["-logfile"];
> >-message += " is not writable.";
> >+message += "X.org server log file " + log + " is not writable.";
> 
> I think this could be simplified to:
> 
> std::string message =
> "X.org server log file " + log + " is not writeable.";
> 
> >  throw std::runtime_error(message);

whoops, must have had my blinkers on. you're right, it can even be
simplified to 
   throw std::runtime_error("Xorg server " + log + " blah blah ")
so I've done just that.

Cheers,
   Peter

> >}
> >
> >-  std::string old_log_file = d_->options["-logfile"];
> >-  old_log_file += ".old";
> >+  std::string old_log_file = log + ".old";
> >+
> >+
> >log_test.open(old_log_file.c_str(), std::ofstream::out);
> >log_test.close();
> >if (log_test.fail()) {
> >  std::string message;
> >-message += "X.org old server log file ";
> >-message += old_log_file;
> >-message += " is not writable.";
> >+message += "X.org old server log file " + old_log_file + " is not 
> >writable.";
> 
> Same simplification here
> 
> >  throw std::runtime_error(message);
> >}
> >
> >
> 
> Either way,
> 
> Reviewed-by: Chase Douglas 
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel