[Spice-commits] vdservice/vdservice.cpp

Frediano Ziglio fziglio at kemper.freedesktop.org
Thu Jul 20 09:52:34 UTC 2017


 vdservice/vdservice.cpp |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit b15e525702be9cbeddb14654745bbd6da15defd5
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Jul 19 09:54:01 2017 +0100

    Split long if statement
    
    Instead of having a long if statement with checks and assignment
    split in two.
    The conditions where used to compute 2 different path, this does
    not help much with code readability.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Uri Lublin <uril at redhat.com>

diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp
index 1eff380..7f3a5a3 100644
--- a/vdservice/vdservice.cpp
+++ b/vdservice/vdservice.cpp
@@ -306,19 +306,20 @@ VOID WINAPI VDService::main(DWORD argc, TCHAR* argv[])
 {
     VDService* s = new VDService;
     SERVICE_STATUS* status;
-    TCHAR log_path[MAX_PATH];
     TCHAR full_path[MAX_PATH];
     TCHAR temp_path[MAX_PATH];
     TCHAR* slash;
 
     ASSERT(s);
-    if (GetModuleFileName(NULL, full_path, MAX_PATH) && (slash = wcsrchr(full_path, TCHAR('\\'))) &&
-        GetTempPath(MAX_PATH, temp_path)) {
-        *slash = TCHAR('\0');
-        swprintf_s(s->_agent_path, MAX_PATH, VD_AGENT_PATH, full_path);
+    if (GetTempPath(MAX_PATH, temp_path)) {
+        TCHAR log_path[MAX_PATH];
         swprintf_s(log_path, MAX_PATH, VD_SERVICE_LOG_PATH, temp_path);
         s->_log = VDLog::get(log_path);
     }
+    if (GetModuleFileName(NULL, full_path, MAX_PATH) && (slash = wcsrchr(full_path, TCHAR('\\')))) {
+        *slash = TCHAR('\0');
+        swprintf_s(s->_agent_path, MAX_PATH, VD_AGENT_PATH, full_path);
+    }
     vd_printf("***Service started***");
     log_version();
     if (!SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS)) {


More information about the Spice-commits mailing list