[Libreoffice-commits] core.git: 6 commits - include/comphelper sal/osl sal/rtl shell/source
Stephan Bergmann
sbergman at redhat.com
Wed Apr 26 15:37:44 UTC 2017
include/comphelper/windowserrorstring.hxx | 9 +----
sal/osl/w32/file_error.cxx | 1
sal/osl/w32/process.cxx | 23 +++++++-------
sal/rtl/alloc_arena.cxx | 2 -
sal/rtl/alloc_cache.cxx | 8 ++--
shell/source/win32/shlxthandler/infotips/infotips.cxx | 2 -
shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx | 2 -
shell/source/win32/zipfile/zipfile.cxx | 9 ++---
8 files changed, 25 insertions(+), 31 deletions(-)
New commits:
commit 979bd73144ea38168b3e536c46c762a7b46c8072
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Apr 26 17:36:57 2017 +0200
Clean up uses of SAL_U/SAL_W: comphelper
Change-Id: I56976f91647c3969d5709e5f691f860bb97ed548
diff --git a/include/comphelper/windowserrorstring.hxx b/include/comphelper/windowserrorstring.hxx
index 34614fbfe93b..805c491c37e1 100644
--- a/include/comphelper/windowserrorstring.hxx
+++ b/include/comphelper/windowserrorstring.hxx
@@ -29,13 +29,8 @@ inline OUString WindowsErrorString(DWORD nErrorCode)
nullptr) == 0)
return OUString::number(nErrorCode, 16);
- if (pMsgBuf[wcslen(pMsgBuf)-1] == '\n')
- pMsgBuf[wcslen(pMsgBuf)-1] = '\0';
-
- if (pMsgBuf[wcslen(pMsgBuf)-1] == '\r')
- pMsgBuf[wcslen(pMsgBuf)-1] = '\0';
-
- OUString result(SAL_U(pMsgBuf));
+ OUString result(reinterpret_cast<sal_Unicode const *>(pMsgBuf));
+ result.endsWith("\r\n", &result);
LocalFree(pMsgBuf);
commit 99637fb4c69ad7f136acc69c2fc0a46f57b9ce67
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Apr 26 17:36:17 2017 +0200
loplugin:useuniqueptr (clang-cl)
Change-Id: Ie541ecc3ec8d7032666b09aaec7d216a43ae44f1
diff --git a/shell/source/win32/zipfile/zipfile.cxx b/shell/source/win32/zipfile/zipfile.cxx
index a65fe32248a6..d33500735977 100644
--- a/shell/source/win32/zipfile/zipfile.cxx
+++ b/shell/source/win32/zipfile/zipfile.cxx
@@ -26,6 +26,7 @@
#include <malloc.h>
#include <algorithm>
#include <functional>
+#include <memory>
#include <string.h>
@@ -130,16 +131,14 @@ std::string readString(StreamInterface *stream, unsigned long size)
{
if (!stream || stream->stell() == -1)
throw IOException(-1);
- unsigned char *tmp = new unsigned char[size];
- unsigned long numBytesRead = stream->sread(tmp, size);
+ auto tmp = std::unique_ptr<unsigned char[]>(new unsigned char[size]);
+ unsigned long numBytesRead = stream->sread(tmp.get(), size);
if (numBytesRead != size)
{
- delete [] tmp;
throw IOException(-1);
}
- std::string aStr(reinterpret_cast<char *>(tmp), size);
- delete [] tmp;
+ std::string aStr(reinterpret_cast<char *>(tmp.get()), size);
return aStr;
}
commit 3427e613c68fefd0464cb1f9806deb55ca1c3661
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Apr 26 17:36:06 2017 +0200
loplugin:redundantcast (clang-cl)
Change-Id: I4370a16ae9652d4f1e5aa3ed472cd88ad6d210c7
diff --git a/shell/source/win32/shlxthandler/infotips/infotips.cxx b/shell/source/win32/shlxthandler/infotips/infotips.cxx
index 31f9bc56e144..aff286d7b68c 100644
--- a/shell/source/win32/shlxthandler/infotips/infotips.cxx
+++ b/shell/source/win32/shlxthandler/infotips/infotips.cxx
@@ -150,7 +150,7 @@ std::wstring formatSizeOfFile( DWORD dwSize )
char *buffer=nullptr;
int decimal, sign;
- double dFileSize = (double)dwSize/(double)KB;
+ double dFileSize = (double)dwSize/KB;
buffer = _fcvt( dFileSize, 1, &decimal, &sign );
diff --git a/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx
index 49adb0aa95ac..76fc42927777 100644
--- a/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx
+++ b/shell/source/win32/shlxthandler/ooofilt/stream_helper.cxx
@@ -54,7 +54,7 @@ unsigned long BufferStream::sread (unsigned char *buf, unsigned long size)
hr = stream->Read (buf, size, &newsize);
if (hr == S_OK)
- return (unsigned long)newsize;
+ return newsize;
else
return (unsigned long)0;
}
commit d22ef4eb1234fc14ae965189b7a2f4e21451fd20
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Apr 26 17:35:40 2017 +0200
loplugin:redundantcast (clang-cl)
Change-Id: I5164bc1bfa1aaae0f648e0384227d92c8b2ff7a3
diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx
index 68dd29836ef5..1459c06816d6 100644
--- a/sal/rtl/alloc_arena.cxx
+++ b/sal/rtl/alloc_arena.cxx
@@ -596,7 +596,7 @@ rtl_arena_constructor (void * obj)
QUEUE_START_NAMED(arena, arena_);
- (void) RTL_MEMORY_LOCK_INIT(&(arena->m_lock));
+ RTL_MEMORY_LOCK_INIT(&(arena->m_lock));
head = &(arena->m_segment_reserve_span_head);
rtl_arena_segment_constructor (head);
diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx
index 1529626e0537..79c8e76e8ca3 100644
--- a/sal/rtl/alloc_cache.cxx
+++ b/sal/rtl/alloc_cache.cxx
@@ -736,7 +736,7 @@ rtl_cache_constructor (void * obj)
QUEUE_START_NAMED(cache, cache_);
/* slab layer */
- (void)RTL_MEMORY_LOCK_INIT(&(cache->m_slab_lock));
+ RTL_MEMORY_LOCK_INIT(&(cache->m_slab_lock));
QUEUE_START_NAMED(&(cache->m_free_head), slab_);
QUEUE_START_NAMED(&(cache->m_used_head), slab_);
@@ -746,7 +746,7 @@ rtl_cache_constructor (void * obj)
cache->m_hash_shift = highbit(cache->m_hash_size) - 1;
/* depot layer */
- (void)RTL_MEMORY_LOCK_INIT(&(cache->m_depot_lock));
+ RTL_MEMORY_LOCK_INIT(&(cache->m_depot_lock));
return 1;
}
@@ -762,7 +762,7 @@ rtl_cache_destructor (void * obj)
assert(QUEUE_STARTED_NAMED(cache, cache_));
/* slab layer */
- (void)RTL_MEMORY_LOCK_DESTROY(&(cache->m_slab_lock));
+ RTL_MEMORY_LOCK_DESTROY(&(cache->m_slab_lock));
assert(QUEUE_STARTED_NAMED(&(cache->m_free_head), slab_));
assert(QUEUE_STARTED_NAMED(&(cache->m_used_head), slab_));
@@ -772,7 +772,7 @@ rtl_cache_destructor (void * obj)
assert(cache->m_hash_shift == highbit(cache->m_hash_size) - 1);
/* depot layer */
- (void)RTL_MEMORY_LOCK_DESTROY(&(cache->m_depot_lock));
+ RTL_MEMORY_LOCK_DESTROY(&(cache->m_depot_lock));
}
/* ================================================================= */
commit 10006071c0e39eef7c30e227d619dd2997a4fec7
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Apr 26 17:35:17 2017 +0200
loplugin:useuniqueptr (clang-cl)
Change-Id: I491fb1fdcc3f5f64e4adb7276217bbdc13a1fa19
diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx
index be617d55adc7..8aa06b468c52 100644
--- a/sal/osl/w32/process.cxx
+++ b/sal/osl/w32/process.cxx
@@ -29,6 +29,7 @@
#endif
#include <cassert>
+#include <memory>
#include <osl/diagnose.h>
#include <osl/security.h>
@@ -497,12 +498,12 @@ oslProcessError SAL_CALL osl_setEnvironment(rtl_uString *ustrVar, rtl_uString *u
LPCWSTR lpValue = reinterpret_cast<LPCWSTR>(ustrValue->buffer);
if (SetEnvironmentVariableW(lpName, lpValue))
{
- wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + wcslen(lpValue) + 1];
- wcscpy(buffer, lpName);
- wcscat(buffer, L"=");
- wcscat(buffer, lpValue);
- _wputenv(buffer);
- delete[] buffer;
+ auto buffer = std::unique_ptr<wchar_t[]>(
+ new wchar_t[wcslen(lpName) + 1 + wcslen(lpValue) + 1]);
+ wcscpy(buffer.get(), lpName);
+ wcscat(buffer.get(), L"=");
+ wcscat(buffer.get(), lpValue);
+ _wputenv(buffer.get());
return osl_Process_E_None;
}
return osl_Process_E_Unknown;
@@ -515,11 +516,11 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString *ustrVar)
LPCWSTR lpName = reinterpret_cast<LPCWSTR>(ustrVar->buffer);
if (SetEnvironmentVariableW(lpName, nullptr))
{
- wchar_t *buffer = new wchar_t[wcslen(lpName) + 1 + 1];
- wcscpy(buffer, lpName);
- wcscat(buffer, L"=");
- _wputenv(buffer);
- delete[] buffer;
+ auto buffer = std::unique_ptr<wchar_t[]>(
+ new wchar_t[wcslen(lpName) + 1 + 1]);
+ wcscpy(buffer.get(), lpName);
+ wcscat(buffer.get(), L"=");
+ _wputenv(buffer.get());
return osl_Process_E_None;
}
return osl_Process_E_Unknown;
commit 1a476f14c9b1e23fa761bf09904eb5c8c7e46c47
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Apr 26 17:34:39 2017 +0200
-Werror,-Wunused-macros (clang-cl)
Change-Id: I64fa44caecd3f86bd23dc625e72c134659610b1a
diff --git a/sal/osl/w32/file_error.cxx b/sal/osl/w32/file_error.cxx
index 520fad586f4b..dc9425d20bf8 100644
--- a/sal/osl/w32/file_error.cxx
+++ b/sal/osl/w32/file_error.cxx
@@ -18,7 +18,6 @@
*/
#define UNICODE
-#define _UNICODE
#include "systools/win32/uwinapi.h"
#include "file_error.hxx"
More information about the Libreoffice-commits
mailing list