[Libreoffice-commits] core.git: sal/osl sal/rtl sal/textenc sal/workben

Michael Weghorn m.weghorn at posteo.de
Fri Dec 19 05:51:56 PST 2014


 sal/osl/unx/conditn.cxx                             |    6 +---
 sal/osl/unx/nlsupport.cxx                           |    6 +---
 sal/osl/unx/pipe.cxx                                |   17 +++++--------
 sal/osl/unx/profile.cxx                             |   25 +++++++------------
 sal/osl/unx/signal.cxx                              |   12 +++++----
 sal/osl/unx/socket.cxx                              |    5 +--
 sal/osl/unx/system.cxx                              |    9 +++---
 sal/osl/w32/file_url.cxx                            |    3 --
 sal/osl/w32/profile.cxx                             |   26 ++++++++------------
 sal/rtl/cipher.cxx                                  |    6 ++--
 sal/rtl/ustring.cxx                                 |    3 --
 sal/textenc/convertsimple.cxx                       |    3 --
 sal/textenc/tcvtbyte.cxx                            |    6 +---
 sal/textenc/tcvtmb.cxx                              |    9 ++----
 sal/workben/clipboardwben/testcopy/XTDataObject.cxx |    3 +-
 sal/workben/testfile.cxx                            |   12 +++------
 16 files changed, 62 insertions(+), 89 deletions(-)

New commits:
commit 2ee336fb556ceb1d7e1ee8017c27539da7fe543b
Author: Michael Weghorn <m.weghorn at posteo.de>
Date:   Fri Dec 19 11:07:02 2014 +0100

    fdo#39440 sal: reduce scope of local variables
    
    This addresses some cppcheck warnings.
    
    Change-Id: Id5f90757571e76a2c05a4cbd37020e1f6a6b2033
    Reviewed-on: https://gerrit.libreoffice.org/13544
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
    Tested-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/sal/osl/unx/conditn.cxx b/sal/osl/unx/conditn.cxx
index 1ba0f84..91d80d7 100644
--- a/sal/osl/unx/conditn.cxx
+++ b/sal/osl/unx/conditn.cxx
@@ -87,13 +87,12 @@ oslCondition SAL_CALL osl_createCondition()
 void SAL_CALL osl_destroyCondition(oslCondition Condition)
 {
     oslConditionImpl* pCond;
-    int nRet = 0;
 
     if ( Condition )
     {
         pCond = (oslConditionImpl*)Condition;
 
-        nRet = pthread_cond_destroy(&pCond->m_Condition);
+        int nRet = pthread_cond_destroy(&pCond->m_Condition);
         SAL_WARN_IF(
             nRet != 0, "sal.osl",
             "pthread_cond_destroy failed, errno " << nRet << ", \""
@@ -225,7 +224,6 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
     {
         if ( ! pCond->m_State )
         {
-            int                 ret;
             struct timeval      tp;
             struct timespec     to;
 
@@ -237,7 +235,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
             /* spurious wake up prevention */
             do
             {
-                ret = pthread_cond_timedwait(&pCond->m_Condition, &pCond->m_Lock, &to);
+                const int ret = pthread_cond_timedwait(&pCond->m_Condition, &pCond->m_Lock, &to);
                 if ( ret != 0 )
                 {
                     if ( ret == ETIME || ret == ETIMEDOUT )
diff --git a/sal/osl/unx/nlsupport.cxx b/sal/osl/unx/nlsupport.cxx
index 4afccaa..1fb6e02 100644
--- a/sal/osl/unx/nlsupport.cxx
+++ b/sal/osl/unx/nlsupport.cxx
@@ -65,8 +65,6 @@ _pair_search (const char *key, const _pair *base, unsigned int member )
 {
     unsigned int lower = 0;
     unsigned int upper = member;
-    unsigned int current;
-    int comparison;
 
     /* check for validity of input */
     if ( (key == NULL) || (base == NULL) || (member == 0) )
@@ -75,8 +73,8 @@ _pair_search (const char *key, const _pair *base, unsigned int member )
     /* binary search */
     while ( lower < upper )
     {
-        current = (lower + upper) / 2;
-        comparison = _pair_compare( key, base + current );
+        const unsigned int current = (lower + upper) / 2;
+        const int comparison = _pair_compare( key, base + current );
         if (comparison < 0)
             upper = current;
         else if (comparison > 0)
diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx
index ecddb66..337d412 100644
--- a/sal/osl/unx/pipe.cxx
+++ b/sal/osl/unx/pipe.cxx
@@ -115,7 +115,6 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *ustrPipeName, oslPipeOptions Option
 {
     oslPipe pPipe=0;
     rtl_String* strPipeName=0;
-    sal_Char* pszPipeName=0;
 
     if ( ustrPipeName != 0 )
     {
@@ -124,7 +123,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *ustrPipeName, oslPipeOptions Option
                             rtl_uString_getLength(ustrPipeName),
                             osl_getThreadTextEncoding(),
                             OUSTRING_TO_OSTRING_CVTFLAGS );
-        pszPipeName = rtl_string_getStr(strPipeName);
+        sal_Char* pszPipeName = rtl_string_getStr(strPipeName);
         pPipe = osl_psz_createPipe(pszPipeName, Options, Security);
 
         if ( strPipeName != 0 )
@@ -364,11 +363,6 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe )
 void SAL_CALL osl_closePipe( oslPipe pPipe )
 {
     int nRet;
-#if defined(LINUX)
-    size_t     len;
-    struct sockaddr_un addr;
-    int fd;
-#endif
     int ConnFD;
 
     if( ! pPipe )
@@ -388,11 +382,13 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
       connect to the accepting pipe
      */
 #if defined(LINUX)
+    struct sockaddr_un addr;
+
     if ( pPipe->m_bIsAccepting )
     {
         pPipe->m_bIsInShutdown = true;
         pPipe->m_Socket = -1;
-        fd = socket(AF_UNIX, SOCK_STREAM, 0);
+        int fd = socket(AF_UNIX, SOCK_STREAM, 0);
         if ( fd < 0 )
         {
             OSL_TRACE("socket in osl_destroyPipe failed with error: %s", strerror(errno));
@@ -404,7 +400,7 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
 
         addr.sun_family = AF_UNIX;
         strncpy(addr.sun_path, pPipe->m_Name, sizeof(addr.sun_path) - 1);
-        len = sizeof(addr);
+        size_t len = sizeof(addr);
 
         nRet = connect( fd, (struct sockaddr *)&addr, len);
         if ( nRet < 0 )
@@ -438,7 +434,7 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
 
 oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
 {
-    int     s, flags;
+    int     s;
     oslPipe pAcceptedPipe;
 
     OSL_ASSERT(pPipe);
@@ -485,6 +481,7 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
         }
 
         /* set close-on-exec flag */
+        int flags;
         if (!((flags = fcntl(s, F_GETFD, 0)) < 0))
         {
             flags |= FD_CLOEXEC;
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index 088a261..e2d559a 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -357,7 +357,6 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
 {
     sal_uInt32    NoEntry;
     sal_Char* pStr=0;
-    osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile=0;
     osl_TProfileImpl*    pTmpProfile=0;
     bool bRet = false;
@@ -389,6 +388,7 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
 
     if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
     {
+        osl_TProfileSection* pSec;
         if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != NULL) &&
             (NoEntry < pSec->m_NoEntries) &&
             ((pStr = strchr(pProfile->m_Lines[pSec->m_Entries[NoEntry].m_Line],
@@ -644,7 +644,6 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile,
                                          const sal_Char *pszEntry)
 {
     sal_uInt32    NoEntry;
-    osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile = 0;
     osl_TProfileImpl*    pTmpProfile = 0;
     bool bRet = false;
@@ -676,6 +675,7 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile,
 
     if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
     {
+        osl_TProfileSection* pSec;
         if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != NULL) &&
             (NoEntry < pSec->m_NoEntries))
         {
@@ -713,7 +713,6 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile,
 {
     sal_uInt32    i, n = 0;
     sal_uInt32    NoEntry;
-    osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile = 0;
     osl_TProfileImpl*    pTmpProfile = 0;
     bool bRet = false;
@@ -748,6 +747,7 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile,
 
     if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
     {
+        osl_TProfileSection* pSec;
         if ((pSec = findEntry(pProfile, pszSection, "", &NoEntry)) != NULL)
         {
             if (MaxLen != 0)
@@ -797,7 +797,6 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile,
                                            sal_uInt32 MaxLen)
 {
     sal_uInt32    i, n = 0;
-    osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile = 0;
     osl_TProfileImpl*    pTmpProfile = 0;
     bool bRet = false;
@@ -834,7 +833,7 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile,
         {
             for (i = 0; i < pProfile->m_NoSections; i++)
             {
-                pSec = &pProfile->m_Sections[i];
+                osl_TProfileSection* pSec = &pProfile->m_Sections[i];
 
                 if ((n + pSec->m_Len + 1) < MaxLen)
                 {
@@ -1052,7 +1051,7 @@ static bool OslProfile_rewindFile(osl_TFile* pFile, bool bTruncate)
 
 static sal_Char* OslProfile_getLine(osl_TFile* pFile)
 {
-    int   Max, Free, Bytes, nLineBytes = 0;
+    int   Max, Free, nLineBytes = 0;
     sal_Char* pChr;
     sal_Char* pLine = NULL;
     sal_Char* pNewLine;
@@ -1067,7 +1066,7 @@ static sal_Char* OslProfile_getLine(osl_TFile* pFile)
 
     do
     {
-        Bytes = sizeof(pFile->m_ReadBuf) - (pFile->m_pReadPtr - pFile->m_ReadBuf);
+        int Bytes = sizeof(pFile->m_ReadBuf) - (pFile->m_pReadPtr - pFile->m_ReadBuf);
 
         if (Bytes <= 1)
         {
@@ -1274,7 +1273,6 @@ static sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Line, sa
     if (LineNo < pProfile->m_NoLines)
     {
         sal_uInt32 i, n;
-        osl_TProfileSection* pSec;
 
         memmove(&pProfile->m_Lines[LineNo + 1], &pProfile->m_Lines[LineNo],
                 (pProfile->m_NoLines - LineNo) * sizeof(sal_Char *));
@@ -1282,7 +1280,7 @@ static sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Line, sa
         /* adjust line references */
         for (i = 0; i < pProfile->m_NoSections; i++)
         {
-            pSec = &pProfile->m_Sections[i];
+            osl_TProfileSection* pSec = &pProfile->m_Sections[i];
 
             if (pSec->m_Line >= LineNo)
                 pSec->m_Line++;
@@ -1309,7 +1307,6 @@ static void removeLine(osl_TProfileImpl* pProfile, sal_uInt32 LineNo)
         if (pProfile->m_NoLines - LineNo > 1)
         {
             sal_uInt32 i, n;
-            osl_TProfileSection* pSec;
 
             memmove(&pProfile->m_Lines[LineNo], &pProfile->m_Lines[LineNo + 1],
                     (pProfile->m_NoLines - LineNo - 1) * sizeof(sal_Char *));
@@ -1321,7 +1318,7 @@ static void removeLine(osl_TProfileImpl* pProfile, sal_uInt32 LineNo)
             /* adjust line references */
             for (i = 0; i < pProfile->m_NoSections; i++)
             {
-                pSec = &pProfile->m_Sections[i];
+                osl_TProfileSection* pSec = &pProfile->m_Sections[i];
 
                 if (pSec->m_Line > LineNo)
                     pSec->m_Line--;
@@ -1502,7 +1499,6 @@ static osl_TProfileSection* findEntry(osl_TProfileImpl* pProfile,
     static  sal_uInt32    Sect = 0;
             sal_uInt32    i, n;
             sal_uInt32  Len;
-            const sal_Char* pStr;
             osl_TProfileSection* pSec=0;
 
     Len = strlen(Section);
@@ -1530,7 +1526,7 @@ static osl_TProfileSection* findEntry(osl_TProfileImpl* pProfile,
 
         for (i = 0; i < pSec->m_NoEntries; i++)
         {
-            pStr = &pProfile->m_Lines[pSec->m_Entries[i].m_Line]
+            const sal_Char* pStr = &pProfile->m_Lines[pSec->m_Entries[i].m_Line]
                                      [pSec->m_Entries[i].m_Offset];
             if ((Len == pSec->m_Entries[i].m_Len) &&
                 (strncasecmp(Entry, pStr, pSec->m_Entries[i].m_Len)
@@ -1554,7 +1550,6 @@ static bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile)
     sal_Char*   pChar;
 
     sal_Char* pLine;
-    sal_Char* bWasAdded = NULL;
 
     if ( !pFile )
     {
@@ -1573,7 +1568,7 @@ static bool loadProfile(osl_TFile* pFile, osl_TProfileImpl* pProfile)
 
     while ( ( pLine=OslProfile_getLine(pFile) ) != 0 )
     {
-        bWasAdded = addLine( pProfile, pLine );
+        sal_Char* bWasAdded = addLine( pProfile, pLine );
         rtl_freeMemory( pLine );
         SAL_WARN_IF(!bWasAdded, "sal.osl", "addLine( pProfile, pLine ) ==> false");
         if ( ! bWasAdded )
diff --git a/sal/osl/unx/signal.cxx b/sal/osl/unx/signal.cxx
index d5098a2..29359b0 100644
--- a/sal/osl/unx/signal.cxx
+++ b/sal/osl/unx/signal.cxx
@@ -421,8 +421,6 @@ callback(struct dl_phdr_info *info, size_t size, void *data)
 
     if (pDynamic)
     {
-        char buffer[100];
-        int len;
         char exe[PATH_MAX];
         const char *dsoname = info->dlpi_name;
 
@@ -430,6 +428,9 @@ callback(struct dl_phdr_info *info, size_t size, void *data)
 
         if (strcmp(dsoname, "") == 0)
         {
+            char buffer[100];
+            int len;
+
             snprintf(buffer, sizeof(buffer), "/proc/%d/exe", getpid());
             if ((len = readlink(buffer, exe, PATH_MAX)) != -1)
             {
@@ -557,7 +558,6 @@ static int ReportCrash( int Signal )
                 char szStackTempNameBuffer[L_tmpnam];
 
                 void *stackframes[MAX_STACK_FRAMES];
-                int  iFrame;
                 int  nFrames = backtrace( stackframes, SAL_N_ELEMENTS(stackframes) );
 
                 FILE *xmlout = NULL, *stackout = NULL, *checksumout = NULL;
@@ -590,6 +590,7 @@ static int ReportCrash( int Signal )
 
                     fprintf( checksumout, "<errormail:Checksums type=\"MD5\">\n" );
 
+                    int  iFrame;
                     for ( iFrame = 0; iFrame < nFrames; iFrame++ )
                     {
                         Dl_info dl_info;
@@ -609,14 +610,15 @@ static int ReportCrash( int Signal )
                         {
                             const char *dli_fname = NULL;
                             char *dli_fdir = NULL;
-                            char szDirectory[PATH_MAX];
-                            char szCanonicDirectory[PATH_MAX];
 
                             /* Don't expect that dladdr filled all members of dl_info */
 
                             dli_fname = dl_info.dli_fname ? strrchr(  dl_info.dli_fname, '/' ) : NULL;
                             if ( dli_fname )
                             {
+                                char szDirectory[PATH_MAX];
+                                char szCanonicDirectory[PATH_MAX];
+
                                 ++dli_fname;
                                 memcpy( szDirectory, dl_info.dli_fname, dli_fname - dl_info.dli_fname );
                                 szDirectory[dli_fname - dl_info.dli_fname] = 0;
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index f9836af..f58fcc9 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -1044,7 +1044,6 @@ oslSocketResult SAL_CALL osl_psz_getLocalHostname (
 
     if (strlen(LocalHostname) == 0)
     {
-        const sal_Char *pStr;
 
 #ifdef SYSV
         struct utsname uts;
@@ -1070,6 +1069,7 @@ oslSocketResult SAL_CALL osl_psz_getLocalHostname (
             /* no, determine it via dns */
             Addr = osl_psz_createHostAddrByName(LocalHostname);
 
+            const sal_Char *pStr;
             if ((pStr = osl_psz_getHostnameOfHostAddr(Addr)) != NULL)
             {
                 strncpy(LocalHostname, pStr, sizeof( LocalHostname ));
@@ -1395,7 +1395,6 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
 
     if ( pSocket->m_bIsAccepting )
     {
-        int nConnFD;
         union {
             struct sockaddr aSockAddr;
             struct sockaddr_in aSockAddrIn;
@@ -1415,7 +1414,7 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
                 s.aSockAddrIn.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
             }
 
-            nConnFD = socket(AF_INET, SOCK_STREAM, 0);
+            int nConnFD = socket(AF_INET, SOCK_STREAM, 0);
             if ( nConnFD < 0 )
             {
                 OSL_TRACE("socket call failed with error: %s", strerror(errno));
diff --git a/sal/osl/unx/system.cxx b/sal/osl/unx/system.cxx
index 6fae151..3d0fb6a 100644
--- a/sal/osl/unx/system.cxx
+++ b/sal/osl/unx/system.cxx
@@ -65,7 +65,7 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result,
 
       if ( (res = gethostbyname(name)) )
       {
-        int nname, naliases, naddr_list, naliasesdata, n;
+        int nname, naliases, naddr_list, naliasesdata;
         char **p, **parray, *data;
 
         /* Check buffer size before copying, we want to leave the
@@ -101,7 +101,7 @@ struct hostent *gethostbyname_r(const char *name, struct hostent *result,
             result->h_aliases = parray;
             data = buffer + (naliases+1)*sizeof(char*);
             for ( p = res->h_aliases; *p != NULL; p++) {
-                n = strlen(*p)+1;
+                int n = strlen(*p)+1;
                 *parray++ = data;
                 memcpy(data, *p, n);
                 data += n;
@@ -251,7 +251,6 @@ char *fcvt(double value, int ndigit, int *decpt, int *sign)
 {
   static char ret[256];
   char buf[256],zahl[256],format[256]="%";
-  char *v1,*v2;
 
   if (value==0.0) value=1e-30;
 
@@ -279,8 +278,8 @@ char *fcvt(double value, int ndigit, int *decpt, int *sign)
 
   if (ndigit!=0)
   {
-    v1=strtok(buf,".");
-    v2=strtok(NULL,".");
+    char *v1=strtok(buf,".");
+    char *v2=strtok(NULL,".");
     strcpy(ret,v1);
     strcat(ret,v2);
   }
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
index 0f35ad4..3620e28 100644
--- a/sal/osl/w32/file_url.cxx
+++ b/sal/osl/w32/file_url.cxx
@@ -684,7 +684,6 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
     rtl_String          *strUTF8 = NULL;
     rtl_uString         *strDecodedURL = NULL;
     rtl_uString         *strTempPath = NULL;
-    const sal_Unicode   *pDecodedURL;
     sal_uInt32          nDecodedLen;
     sal_Bool            bValidEncoded;
     oslFileError        nError = osl_File_E_INVAL;  /* Assume failure */
@@ -714,7 +713,7 @@ oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **p
         rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '/', '\\' );
         rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '|', ':' );
 
-        pDecodedURL = rtl_uString_getStr( strDecodedURL );
+        const sal_Unicode *pDecodedURL = rtl_uString_getStr( strDecodedURL );
         nDecodedLen = rtl_uString_getLength( strDecodedURL );
 
         /* Must start with "file://" */
diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx
index 43db47f..980e515 100644
--- a/sal/osl/w32/profile.cxx
+++ b/sal/osl/w32/profile.cxx
@@ -418,7 +418,6 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
 {
     sal_uInt32    NoEntry;
     const sal_Char* pStr = 0;
-    osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile = 0;
 
 #ifdef TRACE_OSL_PROFILE
@@ -438,6 +437,7 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
 
     if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
     {
+        osl_TProfileSection* pSec;
         if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != NULL) &&
             (NoEntry < pSec->m_NoEntries) &&
             ((pStr = strchr(pProfile->m_Lines[pSec->m_Entries[NoEntry].m_Line],
@@ -695,7 +695,6 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile,
                                const sal_Char *pszSection, const sal_Char *pszEntry)
 {
     sal_uInt32    NoEntry;
-    osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile = 0;
     sal_Bool bRet = sal_False;
 
@@ -716,6 +715,7 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile,
 
     if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
     {
+        osl_TProfileSection* pSec;
         if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != NULL) &&
             (NoEntry < pSec->m_NoEntries))
         {
@@ -755,7 +755,6 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C
 {
     sal_uInt32    i, n = 0;
     sal_uInt32    NoEntry;
-    osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile = 0;
 
 #ifdef TRACE_OSL_PROFILE
@@ -775,6 +774,7 @@ sal_uInt32 SAL_CALL osl_getProfileSectionEntries(oslProfile Profile, const sal_C
 
     if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
     {
+        osl_TProfileSection* pSec;
         if ((pSec = findEntry(pProfile, pszSection, "", &NoEntry)) != NULL)
         {
             if (MaxLen != 0)
@@ -1041,7 +1041,6 @@ sal_Bool SAL_CALL osl_getProfileName(rtl_uString* strPath, rtl_uString* strName,
 sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuffer, sal_uInt32 MaxLen)
 {
     sal_uInt32    i, n = 0;
-    osl_TProfileSection* pSec;
     osl_TProfileImpl*    pProfile = acquireProfile(Profile, sal_False);
 
     if (pProfile == NULL)
@@ -1053,7 +1052,7 @@ sal_uInt32 SAL_CALL osl_getProfileSections(oslProfile Profile, sal_Char* pszBuff
         {
              for (i = 0; i < pProfile->m_NoSections; i++)
             {
-                pSec = &pProfile->m_Sections[i];
+                osl_TProfileSection* pSec = &pProfile->m_Sections[i];
 
                 if ((n + pSec->m_Len + 1) < MaxLen)
                 {
@@ -1237,7 +1236,7 @@ static sal_Bool rewindFile(osl_TFile* pFile, sal_Bool bTruncate)
 static sal_Bool getLine(osl_TFile* pFile, const sal_Char *pszLine, int MaxLen)
 {
     DWORD Max;
-    size_t Free, Bytes;
+    size_t Free;
     sal_Char* pChr;
     sal_Char* pLine = (sal_Char *)pszLine;
 
@@ -1248,7 +1247,7 @@ static sal_Bool getLine(osl_TFile* pFile, const sal_Char *pszLine, int MaxLen)
 
     do
     {
-        Bytes = sizeof(pFile->m_ReadBuf) - (pFile->m_pReadPtr - pFile->m_ReadBuf);
+        size_t Bytes = sizeof(pFile->m_ReadBuf) - (pFile->m_pReadPtr - pFile->m_ReadBuf);
 
         if (Bytes <= 1)
         {
@@ -1455,7 +1454,6 @@ static const sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Li
     if (LineNo < pProfile->m_NoLines)
     {
         sal_uInt32 i, n;
-        osl_TProfileSection* pSec;
 
         memmove(&pProfile->m_Lines[LineNo + 1], &pProfile->m_Lines[LineNo],
                 (pProfile->m_NoLines - LineNo) * sizeof(sal_Char *));
@@ -1463,7 +1461,7 @@ static const sal_Char* insertLine(osl_TProfileImpl* pProfile, const sal_Char* Li
         /* adjust line references */
         for (i = 0; i < pProfile->m_NoSections; i++)
         {
-            pSec = &pProfile->m_Sections[i];
+            osl_TProfileSection* pSec = &pProfile->m_Sections[i];
 
             if (pSec->m_Line >= LineNo)
                 pSec->m_Line++;
@@ -1490,7 +1488,6 @@ static void removeLine(osl_TProfileImpl* pProfile, sal_uInt32 LineNo)
         if (pProfile->m_NoLines - LineNo > 1)
         {
             sal_uInt32 i, n;
-            osl_TProfileSection* pSec;
 
             memmove(&pProfile->m_Lines[LineNo], &pProfile->m_Lines[LineNo + 1],
                     (pProfile->m_NoLines - LineNo - 1) * sizeof(sal_Char *));
@@ -1502,7 +1499,7 @@ static void removeLine(osl_TProfileImpl* pProfile, sal_uInt32 LineNo)
             /* adjust line references */
             for (i = 0; i < pProfile->m_NoSections; i++)
             {
-                pSec = &pProfile->m_Sections[i];
+                osl_TProfileSection* pSec = &pProfile->m_Sections[i];
 
                 if (pSec->m_Line > LineNo)
                     pSec->m_Line--;
@@ -1680,7 +1677,6 @@ static osl_TProfileSection* findEntry(osl_TProfileImpl* pProfile, const sal_Char
 static  sal_uInt32    Sect = 0;
         sal_uInt32    i, n;
         sal_uInt32    Len;
-        const sal_Char* pStr;
         osl_TProfileSection* pSec = NULL;
 
     Len = strlen(Section);
@@ -1710,7 +1706,7 @@ static  sal_uInt32    Sect = 0;
 
         for (i = 0; i < pSec->m_NoEntries; i++)
         {
-            pStr = &pProfile->m_Lines[pSec->m_Entries[i].m_Line]
+            const sal_Char* pStr = &pProfile->m_Lines[pSec->m_Entries[i].m_Line]
                                      [pSec->m_Entries[i].m_Offset];
             if ((Len == pSec->m_Entries[i].m_Len) &&
                 (strnicmp(Entry, pStr, pSec->m_Entries[i].m_Len)
@@ -2072,7 +2068,7 @@ static sal_Bool releaseProfile(osl_TProfileImpl* pProfile)
 
 static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *strFile, sal_Unicode *strProfile)
 {
-    sal_Char *pChr, *pStr;
+    sal_Char *pChr;
     sal_Char Buffer[4096] = "";
     sal_Char Product[132] = "";
 
@@ -2326,7 +2322,7 @@ static sal_Bool lookupProfile(const sal_Unicode *strPath, const sal_Unicode *str
                 static const sal_Char *SubDirs[] = SVERSION_DIRS;
 
                 unsigned i = 0;
-                pStr = aTmpPath + nPos;
+                sal_Char *pStr = aTmpPath + nPos;
 
                 for (i = 0; i < SAL_N_ELEMENTS(SubDirs); i++)
                     if (strnicmp(pStr + 1, SubDirs[i], strlen(SubDirs[i])) == 0)
diff --git a/sal/rtl/cipher.cxx b/sal/rtl/cipher.cxx
index 236ac2f..ba799ec 100644
--- a/sal/rtl/cipher.cxx
+++ b/sal/rtl/cipher.cxx
@@ -1194,7 +1194,7 @@ static rtlCipherError rtl_cipherARCFOUR_update_Impl (
     sal_uInt8           *pBuffer, sal_Size nBufLen)
 {
     unsigned int *S;
-    unsigned int  x, y, t;
+    unsigned int t;
     sal_Size               k;
 
     /* Check arguments. */
@@ -1209,8 +1209,8 @@ static rtlCipherError rtl_cipherARCFOUR_update_Impl (
     for (k = 0; k < nDatLen; k++)
     {
         /* Update counters X and Y. */
-        x = ctx->m_X;
-        y = ctx->m_Y;
+        unsigned int x = ctx->m_X;
+        unsigned int y = ctx->m_Y;
         x = (x + 1   ) % CIPHER_CBLOCK_ARCFOUR;
         y = (y + S[x]) % CIPHER_CBLOCK_ARCFOUR;
         ctx->m_X = x;
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index 5f1c12a..b3eeac1 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -569,7 +569,6 @@ void SAL_CALL rtl_uString_newFromCodePoints(
 static int rtl_ImplGetFastUTF8UnicodeLen( const sal_Char* pStr, sal_Int32 nLen, bool * ascii )
 {
     int             n;
-    unsigned char       c;
     const sal_Char* pEndStr;
 
     *ascii = true;
@@ -577,7 +576,7 @@ static int rtl_ImplGetFastUTF8UnicodeLen( const sal_Char* pStr, sal_Int32 nLen,
     pEndStr  = pStr+nLen;
     while ( pStr < pEndStr )
     {
-        c = (unsigned char)*pStr;
+        unsigned char c = (unsigned char)*pStr;
 
         if ( !(c & 0x80) )
             pStr++;
diff --git a/sal/textenc/convertsimple.cxx b/sal/textenc/convertsimple.cxx
index 6f5b500..0766416 100644
--- a/sal/textenc/convertsimple.cxx
+++ b/sal/textenc/convertsimple.cxx
@@ -517,7 +517,6 @@ sal_Size sal::detail::textenc::convertCharToUnicode(
     sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars,
     sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtBytes)
 {
-    unsigned char                   c;
     sal_Unicode                 cConv;
     const ImplByteConvertData*  pConvertData = (const ImplByteConvertData*)pData;
     sal_Unicode*                pEndDestBuf;
@@ -528,7 +527,7 @@ sal_Size sal::detail::textenc::convertCharToUnicode(
     pEndSrcBuf  = pSrcBuf+nSrcBytes;
     while ( pSrcBuf < pEndSrcBuf )
     {
-        c = (unsigned char)*pSrcBuf;
+        unsigned char c = (unsigned char)*pSrcBuf;
         if ( c < 0x80 )
             cConv = c;
         else
diff --git a/sal/textenc/tcvtbyte.cxx b/sal/textenc/tcvtbyte.cxx
index 94336da..0248e01 100644
--- a/sal/textenc/tcvtbyte.cxx
+++ b/sal/textenc/tcvtbyte.cxx
@@ -32,7 +32,6 @@ sal_Size ImplSymbolToUnicode( SAL_UNUSED_PARAMETER const void*,
                               SAL_UNUSED_PARAMETER sal_uInt32,
                               sal_uInt32* pInfo, sal_Size* pSrcCvtBytes )
 {
-    unsigned char               c;
     sal_Unicode*            pEndDestBuf;
     const char*         pEndSrcBuf;
 
@@ -48,7 +47,7 @@ sal_Size ImplSymbolToUnicode( SAL_UNUSED_PARAMETER const void*,
         }
 
         /* 0-31 (all Control-Character get the same Unicode value) */
-        c = (unsigned char)*pSrcBuf;
+        unsigned char c = (unsigned char)*pSrcBuf;
         if ( c <= 0x1F )
             *pDestBuf = (sal_Unicode)c;
         else
@@ -127,7 +126,6 @@ sal_Size ImplUpperCharToUnicode( const void* pData,
                             SAL_UNUSED_PARAMETER sal_uInt32, sal_uInt32* pInfo,
                             sal_Size* pSrcCvtBytes )
 {
-    unsigned char                   c;
     sal_Unicode                 cConv;
     const ImplByteConvertData*  pConvertData = (const ImplByteConvertData*)pData;
     sal_Unicode*                pEndDestBuf;
@@ -144,7 +142,7 @@ sal_Size ImplUpperCharToUnicode( const void* pData,
     }
     while ( pSrcBuf < pEndSrcBuf )
     {
-        c = (unsigned char)*pSrcBuf;
+        unsigned char c = (unsigned char)*pSrcBuf;
         if (c < 0x80)
             cConv = c;
         else
diff --git a/sal/textenc/tcvtmb.cxx b/sal/textenc/tcvtmb.cxx
index 8f84e7f..80c4955 100644
--- a/sal/textenc/tcvtmb.cxx
+++ b/sal/textenc/tcvtmb.cxx
@@ -221,8 +221,6 @@ sal_Size ImplUnicodeToDBCS( const void* pData, SAL_UNUSED_PARAMETER void*,
 {
     sal_uInt16                  cConv;
     sal_Unicode                 c;
-    unsigned char                   nHighChar;
-    unsigned char                   nLowChar;
     const ImplUniToDBCSHighTab* pHighEntry;
     const ImplDBCSConvertData*  pConvertData = (const ImplDBCSConvertData*)pData;
     const ImplUniToDBCSHighTab* pHighTab = pConvertData->mpToDBCSHighTab;
@@ -241,8 +239,8 @@ sal_Size ImplUnicodeToDBCS( const void* pData, SAL_UNUSED_PARAMETER void*,
     while ( pSrcBuf < pEndSrcBuf )
     {
         c = *pSrcBuf;
-        nHighChar = (unsigned char)((c >> 8) & 0xFF);
-        nLowChar = (unsigned char)(c & 0xFF);
+        unsigned char nHighChar = (unsigned char)((c >> 8) & 0xFF);
+        unsigned char nLowChar = (unsigned char)(c & 0xFF);
 
         /* get entry for the high byte */
         pHighEntry = pHighTab+nHighChar;
@@ -382,7 +380,6 @@ sal_Size ImplEUCJPToUnicode( const void* pData,
                              sal_uInt32 nFlags, sal_uInt32* pInfo,
                              sal_Size* pSrcCvtBytes )
 {
-    unsigned char                   c;
     unsigned char                   cLead = '\0';
     unsigned char                   cTrail = '\0';
     sal_Unicode                 cConv;
@@ -397,7 +394,7 @@ sal_Size ImplEUCJPToUnicode( const void* pData,
     pEndSrcBuf  = pSrcBuf+nSrcBytes;
     while ( pSrcBuf < pEndSrcBuf )
     {
-        c = (unsigned char)*pSrcBuf;
+        unsigned char c = (unsigned char)*pSrcBuf;
 
         /* ASCII */
         if ( c <= 0x7F )
diff --git a/sal/workben/clipboardwben/testcopy/XTDataObject.cxx b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx
index ac7b60e..bd42b01 100644
--- a/sal/workben/clipboardwben/testcopy/XTDataObject.cxx
+++ b/sal/workben/clipboardwben/testcopy/XTDataObject.cxx
@@ -105,12 +105,13 @@ STDMETHODIMP CXTDataObject::GetData(LPFORMATETC pFormatetc, LPSTGMEDIUM pmedium
 
     if ( CF_TEXT == pFormatetc->cfFormat )
     {
-        char     buff[] = "Hello World, How are you!";
         LPSTREAM lpStream;
 
         hr = CreateStreamOnHGlobal( NULL, FALSE, &lpStream );
         if ( SUCCEEDED( hr ) )
         {
+            char buff[] = "Hello World, How are you!";
+
             hr = lpStream->Write( buff, sizeof( buff ) * sizeof( char ), NULL );
             if ( SUCCEEDED( hr ) )
             {
diff --git a/sal/workben/testfile.cxx b/sal/workben/testfile.cxx
index 49ec449..cbe5043 100644
--- a/sal/workben/testfile.cxx
+++ b/sal/workben/testfile.cxx
@@ -114,7 +114,6 @@ sal_Bool Initialize( void )
 
     rtl::OUString   iniFileURL;
     File            *pFile;
-    sal_Unicode     *pExeFileCount;
 
     FileBase::RC    rc;
 
@@ -132,7 +131,7 @@ sal_Bool Initialize( void )
 
     if ( ProcessError == osl_Process_E_None)
     {
-        pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL);
+        sal_Unicode *pExeFileCount=rtl_uString_getStr(strExeFileURL)+rtl_uString_getLength(strExeFileURL);
 
         // Search for the last slash in the Path
         while (*pExeFileCount!=L'/' && pExeFileCount>rtl_uString_getStr(strExeFileURL))
@@ -1748,7 +1747,6 @@ void DirectoryFileStatusTest( void )
 {
     FileBase::RC    rc;
     DirectoryItem   aItem;
-    FileStatus      *pStatus;
 
     printf( "--------------------------------------------\n" );
     printf( "Directory-FileStatus-Test\n" );
@@ -1765,7 +1763,7 @@ void DirectoryFileStatusTest( void )
 
     if ( rc==FileBase::E_None )
     {
-        pStatus=new FileStatus( osl_FileStatus_Mask_All );
+        FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All );
         rc=aItem.getFileStatus( *pStatus );
 
         FileStatusTest( pStatus );
@@ -1785,7 +1783,6 @@ void FileFileStatusTest( void )
 {
     FileBase::RC    rc;
     DirectoryItem   aItem;
-    FileStatus      *pStatus;
 
     printf( "--------------------------------------------\n" );
     printf( "File-FileStatus-Test\n" );
@@ -1802,7 +1799,7 @@ void FileFileStatusTest( void )
 
     if ( rc==FileBase::E_None )
     {
-        pStatus=new FileStatus( osl_FileStatus_Mask_All );
+        FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All );
         rc=aItem.getFileStatus( *pStatus );
 
         FileStatusTest( pStatus );
@@ -1822,7 +1819,6 @@ void VolumeFileStatusTest( void )
 {
     FileBase::RC    rc;
     DirectoryItem   aItem;
-    FileStatus      *pStatus;
 
     printf( "--------------------------------------------\n" );
     printf( "Volume-FileStatus-Test\n" );
@@ -1839,7 +1835,7 @@ void VolumeFileStatusTest( void )
 
     if ( rc==FileBase::E_None )
     {
-        pStatus=new FileStatus( osl_FileStatus_Mask_All) ;
+        FileStatus *pStatus=new FileStatus( osl_FileStatus_Mask_All) ;
         rc=aItem.getFileStatus( *pStatus );
 
         FileStatusTest( pStatus );


More information about the Libreoffice-commits mailing list