Index: /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 43805)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp	(revision 43806)
@@ -1632,12 +1632,7 @@
                         { "SataLUN1", "SataLUN2", "SataLUN3", "SataLUN4" };
 
-                        LONG lPortNum = 0;
                         LONG lPortLUN[MAX_SATA_LUN_COUNT];
                         LONG lPortUsed[MAX_SATA_PORTS];
                         uint32_t u32HDSataPortCount = 0;
-                        uint32_t u32MaxPortCount = MAX_SATA_LUN_COUNT;
-                        size_t uNumAttachments = 0;
-                        DeviceType_T lType;
-                        com::SafeIfaceArray<IMediumAttachment> atts;
 
                         /* init to max value */
@@ -1649,8 +1644,8 @@
                         }
 
-
+                        com::SafeIfaceArray<IMediumAttachment> atts;
                         hrc = pMachine->GetMediumAttachmentsOfController(controllerName.raw(),
                                                             ComSafeArrayAsOutParam(atts));  H();
-                        uNumAttachments = atts.size();
+                        size_t uNumAttachments = atts.size();
                         if (uNumAttachments > MAX_SATA_PORTS)
                         {
@@ -1665,6 +1660,9 @@
                         {
                             IMediumAttachment *pMediumAtt = atts[j];
+                            LONG lPortNum = 0;
                             hrc = pMediumAtt->COMGETTER(Port)(&lPortNum);                   H();
                             if(SUCCEEDED(hrc))
+                            {
+                                DeviceType_T lType;
                                 hrc = pMediumAtt->COMGETTER(Type)(&lType);                    H();
                                 if(SUCCEEDED(hrc) && lType == DeviceType_HardDisk)
@@ -1676,4 +1674,5 @@
                                     LogFlowFunc(("HD Sata port Count=%d\n", u32HDSataPortCount));
                                 }
+                             }
                         }
 
@@ -1682,4 +1681,5 @@
                          * to save details for every 30 ports
                          */
+                        uint32_t u32MaxPortCount = MAX_SATA_LUN_COUNT;
                         if (u32HDSataPortCount < MAX_SATA_LUN_COUNT)
                             u32MaxPortCount = u32HDSataPortCount;
@@ -1689,4 +1689,5 @@
                                                               u32HDSataPortCount);
                         if (pBiosCfg)
+                        {
                             for (size_t j = 0; j < u32MaxPortCount; j++)
                             {
@@ -1694,4 +1695,5 @@
                                 LogFlowFunc(("Top %d ports = %s, %d\n", j, s_apszBiosConfig[j], lPortLUN[j]));
                             }
+                        }
                     }
 
