[PATCH xorg-gtest 03/11] xserver: use temporary variable for log file too
Chase Douglas
chase.douglas at canonical.com
Thu Aug 16 08:49:24 PDT 2012
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 <peter.hutterer at who-t.net>
> ---
> 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 <chase.douglas at canonical.com>
More information about the xorg-devel
mailing list