[Libreoffice-commits] core.git: shell/source

Stephan Bergmann sbergman at redhat.com
Tue May 9 08:21:56 UTC 2017


 shell/source/backends/macbe/macbackend.mm |   96 ++++++++----------------------
 1 file changed, 27 insertions(+), 69 deletions(-)

New commits:
commit 693528ffd44d9aaa44f9fcf22670246dc8adca77
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue May 9 10:19:20 2017 +0200

    Don't use uninitialized ProxyEntry::Port values
    
    ...and get rid of the useless ProxyEntry struct altogether
    
    Change-Id: I846f126c96343da17518686e666a7d44c6b1bef1

diff --git a/shell/source/backends/macbe/macbackend.mm b/shell/source/backends/macbe/macbackend.mm
index 1e95e90c4c3a..9c9103c5cfcb 100644
--- a/shell/source/backends/macbe/macbackend.mm
+++ b/shell/source/backends/macbe/macbackend.mm
@@ -37,12 +37,6 @@
 #define SPACE      ' '
 #define SEMI_COLON ';'
 
-typedef struct
-{
-    rtl::OUString Server;
-    sal_Int32 Port;
-} ProxyEntry;
-
 typedef enum {
     sHTTP,
     sHTTPS,
@@ -230,8 +224,6 @@ css::uno::Any MacOSXBackend::getPropertyValue(
         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
     } else if ( PropertyName == "ooInetFTPProxyName" )
     {
-        ProxyEntry aFtpProxy;
-
         char host[MAXHOSTNAMELEN];
         UInt16 port;
         bool retVal;
@@ -240,44 +232,32 @@ css::uno::Any MacOSXBackend::getPropertyValue(
 
         if (retVal)
         {
-            aFtpProxy.Server = rtl::OUString::createFromAscii( host );
-        }
-
-        // ftp proxy name
-        if( aFtpProxy.Server.getLength() > 0 )
-        {
-            return css::uno::makeAny(
-                css::beans::Optional< css::uno::Any >(
-                    true, uno::makeAny( aFtpProxy.Server ) ) );
+            auto const Server = rtl::OUString::createFromAscii( host );
+            if( Server.getLength() > 0 )
+            {
+                return css::uno::makeAny(
+                    css::beans::Optional< css::uno::Any >(
+                        true, uno::makeAny( Server ) ) );
+            }
         }
         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
     } else if ( PropertyName == "ooInetFTPProxyPort" )
     {
-        ProxyEntry aFtpProxy;
-
         char host[MAXHOSTNAMELEN];
         UInt16 port;
         bool retVal;
 
         retVal = GetProxySetting(sFTP, host, 100, &port);
 
-        if (retVal)
-        {
-            aFtpProxy.Port = port;
-        }
-
-        // ftp proxy port
-        if( aFtpProxy.Port > 0 )
+        if (retVal && port > 0)
         {
             return css::uno::makeAny(
                 css::beans::Optional< css::uno::Any >(
-                    true, uno::makeAny( aFtpProxy.Port ) ) );
+                    true, uno::makeAny( sal_Int32(port) ) ) );
         }
         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
     } else if ( PropertyName == "ooInetHTTPProxyName" )
     {
-        ProxyEntry aHttpProxy;
-
         char host[MAXHOSTNAMELEN];
         UInt16 port;
         bool retVal;
@@ -286,44 +266,32 @@ css::uno::Any MacOSXBackend::getPropertyValue(
 
         if (retVal)
         {
-            aHttpProxy.Server = rtl::OUString::createFromAscii( host );
-        }
-
-        // http proxy name
-        if( aHttpProxy.Server.getLength() > 0 )
-        {
-            return css::uno::makeAny(
-                css::beans::Optional< css::uno::Any >(
-                    true, uno::makeAny( aHttpProxy.Server ) ) );
+            auto const Server = rtl::OUString::createFromAscii( host );
+            if( Server.getLength() > 0 )
+            {
+                return css::uno::makeAny(
+                    css::beans::Optional< css::uno::Any >(
+                        true, uno::makeAny( Server ) ) );
+            }
         }
         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
     } else if ( PropertyName == "ooInetHTTPProxyPort" )
     {
-        ProxyEntry aHttpProxy;
-
         char host[MAXHOSTNAMELEN];
         UInt16 port;
         bool retVal;
 
         retVal = GetProxySetting(sHTTP, host, 100, &port);
 
-        if (retVal)
-        {
-            aHttpProxy.Port = port;
-        }
-
-        // http proxy port
-        if( aHttpProxy.Port > 0 )
+        if (retVal && port > 0)
         {
             return css::uno::makeAny(
                 css::beans::Optional< css::uno::Any >(
-                    true, uno::makeAny( aHttpProxy.Port ) ) );
+                    true, uno::makeAny( sal_Int32(port) ) ) );
         }
         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
     } else if ( PropertyName == "ooInetHTTPSProxyName" )
     {
-        ProxyEntry aHttpsProxy;
-
         char host[MAXHOSTNAMELEN];
         UInt16 port;
         bool retVal;
@@ -332,38 +300,28 @@ css::uno::Any MacOSXBackend::getPropertyValue(
 
         if (retVal)
         {
-            aHttpsProxy.Server = rtl::OUString::createFromAscii( host );
-        }
-
-        // https proxy name
-        if( aHttpsProxy.Server.getLength() > 0 )
-        {
-            return css::uno::makeAny(
-                css::beans::Optional< css::uno::Any >(
-                    true, uno::makeAny( aHttpsProxy.Server ) ) );
+            auto const Server = rtl::OUString::createFromAscii( host );
+            if( Server.getLength() > 0 )
+            {
+                return css::uno::makeAny(
+                    css::beans::Optional< css::uno::Any >(
+                        true, uno::makeAny( Server ) ) );
+            }
         }
         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
     } else if ( PropertyName == "ooInetHTTPSProxyPort" )
     {
-        ProxyEntry aHttpsProxy;
-
         char host[MAXHOSTNAMELEN];
         UInt16 port;
         bool retVal;
 
         retVal = GetProxySetting(sHTTPS, host, 100, &port);
 
-        if (retVal)
-        {
-            aHttpsProxy.Port = port;
-        }
-
-        // https proxy port
-        if( aHttpsProxy.Port > 0 )
+        if (retVal && port > 0)
         {
             return css::uno::makeAny(
                 css::beans::Optional< css::uno::Any >(
-                    true, uno::makeAny( aHttpsProxy.Port ) ) );
+                    true, uno::makeAny( sal_Int32(port) ) ) );
         }
         return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
     } else if ( PropertyName == "ooInetProxyType" )


More information about the Libreoffice-commits mailing list