Index: /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibAutoLogon.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibAutoLogon.cpp	(revision 40414)
+++ /trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibAutoLogon.cpp	(revision 40415)
@@ -1,6 +1,6 @@
-/* $Id */
+/* $Id$ */
 /** @file
  * VBoxGuestR3LibAutoLogon - Ring-3 utility functions for auto-logon modules
- * (VBoxGINA / VBoxCredProv / pam_vbox).
+ *                           (VBoxGINA / VBoxCredProv / pam_vbox).
  */
 
@@ -30,9 +30,7 @@
 *   Header Files                                                               *
 *******************************************************************************/
-#include <iprt/asm.h>
-#include <iprt/mem.h>
-#include <iprt/rand.h>
-#include <iprt/string.h>
-#include <VBox/log.h>
+#ifdef RT_OS_WINDOWS
+# include <Windows.h>
+#endif
 
 #include "VBGLR3Internal.h"
@@ -68,55 +66,27 @@
             if (RT_SUCCESS(rc))
             {
-                /** @todo Move VBoxGuestStatusCurrent -> const char* to an own function. */
-                char szStatus[RTPATH_MAX];
-                size_t cbRet = 0;
+                const char *pszStatus;
                 switch (enmStatus)
                 {
-                    case VBoxGuestFacilityStatus_Inactive:
-                        cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Inactive");
-                        break;
-                    case VBoxGuestFacilityStatus_Paused:
-                        cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Disabled");
-                        break;
-                    case VBoxGuestFacilityStatus_PreInit:
-                        cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "PreInit");
-                        break;
-                    case VBoxGuestFacilityStatus_Init:
-                        cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Init");
-                        break;
-                    case VBoxGuestFacilityStatus_Active:
-                        cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Active");
-                        break;
-                    case VBoxGuestFacilityStatus_Terminating:
-                        cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Terminating");
-                        break;
-                    case VBoxGuestFacilityStatus_Terminated:
-                        cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Terminated");
-                        break;
-                    case VBoxGuestFacilityStatus_Failed:
-                        cbRet = RTStrPrintf(szStatus, sizeof(szStatus), "Failed");
-                        break;
-                    default:
-                        /* cbRet will be 0. */
-                        break;
+                    case VBoxGuestFacilityStatus_Inactive:      pszStatus = "Inactive"; break;
+                    case VBoxGuestFacilityStatus_Paused:        pszStatus = "Disabled"; break;
+                    case VBoxGuestFacilityStatus_PreInit:       pszStatus = "PreInit"; break;
+                    case VBoxGuestFacilityStatus_Init:          pszStatus = "Init"; break;
+                    case VBoxGuestFacilityStatus_Active:        pszStatus = "Active"; break;
+                    case VBoxGuestFacilityStatus_Terminating:   pszStatus = "Terminating"; break;
+                    case VBoxGuestFacilityStatus_Terminated:    pszStatus = "Terminated"; break;
+                    case VBoxGuestFacilityStatus_Failed:        pszStatus = "Failed"; break;
+                    default:                                    pszStatus = NULL;
                 }
-
-                if (cbRet)
+                if (pszStatus)
                 {
-                    const char szPath[] = "/VirtualBox/GuestInfo/OS/AutoLogonStatus";
-
                     /*
-                     * Because a value can be temporary we have to make sure it also
-                     * gets deleted when the property cache did not have the chance to
-                     * gracefully clean it up (due to a hard VM reset etc), so set this
-                     * guest property using the TRANSRESET flag..
+                     * Use TRANSRESET when possible, fall back to TRANSIENT
+                     * (generally sufficient unless the guest misbehaves).
                      */
-                    rc = VbglR3GuestPropWrite(u32ClientId, szPath, szStatus, "TRANSRESET");
+                    static const char s_szPath[] = "/VirtualBox/GuestInfo/OS/AutoLogonStatus";
+                    rc = VbglR3GuestPropWrite(u32ClientId, s_szPath, pszStatus, "TRANSRESET");
                     if (rc == VERR_PARSE_ERROR)
-                    {
-                        /* Host does not support the "TRANSRESET" flag, so only
-                         * use the "TRANSIENT" flag -- better than nothing :-). */
-                        rc = VbglR3GuestPropWrite(u32ClientId, szPath, szStatus, "TRANSIENT");
-                    }
+                        rc = VbglR3GuestPropWrite(u32ClientId, s_szPath, pszStatus, "TRANSIENT");
                 }
                 else
@@ -141,5 +111,5 @@
 {
 #ifdef RT_OS_WINDOWS
-    return (0 != GetSystemMetrics(SM_REMOTESESSION)) ? true : false;
+    return GetSystemMetrics(SM_REMOTESESSION) != 0 ? true : false;
 #else
     return false; /* Not implemented. */
@@ -147,3 +117,2 @@
 }
 
-
