summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-01-06 22:21:33 +0100
committerStephan Bergmann <sbergman@redhat.com>2015-01-07 14:42:07 +0100
commit7b1261f6f956271ec2a545f635e11432a5e64fa1 (patch)
tree60419323374af92164590d274134a3e7f0c6eae6 /sal
parentd1a74c273d10e6ab228acac2b8ebc151362a41b3 (diff)
loplugin:cstylecast: sal
Change-Id: I0ad9681a8b31d78cefce5b66040415154a1c7a99
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/socket.cxx70
-rw-r--r--sal/osl/unx/thread.cxx6
-rw-r--r--sal/qa/rtl/textenc/rtl_textcvt.cxx2
-rw-r--r--sal/rtl/alloc_arena.cxx15
-rw-r--r--sal/rtl/alloc_cache.cxx18
-rw-r--r--sal/textenc/textcvt.cxx4
6 files changed, 47 insertions, 68 deletions
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index f58fcc9db74a..b32987ef6351 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -2322,18 +2322,18 @@ oslSocketError SAL_CALL osl_getLastSocketError(oslSocket pSocket)
return ERROR_FROM_NATIVE(pSocket->m_nLastError);
}
-typedef struct _TSocketSetImpl
+struct oslSocketSetImpl
{
int m_MaxHandle; /* for select(), the largest descriptor in the set */
fd_set m_Set; /* the set of descriptors */
-} TSocketSetImpl;
+};
oslSocketSet SAL_CALL osl_createSocketSet()
{
- TSocketSetImpl* pSet;
+ oslSocketSetImpl* pSet;
- pSet= (TSocketSetImpl*)malloc(sizeof(TSocketSetImpl));
+ pSet= (oslSocketSetImpl*)malloc(sizeof(oslSocketSetImpl));
OSL_ASSERT(pSet);
@@ -2354,23 +2354,19 @@ void SAL_CALL osl_destroySocketSet(oslSocketSet Set)
void SAL_CALL osl_clearSocketSet(oslSocketSet Set)
{
- TSocketSetImpl* pSet;
OSL_ASSERT(Set);
if ( Set == 0 )
{
return;
}
- pSet= (TSocketSetImpl*)Set;
- pSet->m_MaxHandle= 0;
+ Set->m_MaxHandle= 0;
- FD_ZERO(&pSet->m_Set);
+ FD_ZERO(&Set->m_Set);
}
void SAL_CALL osl_addToSocketSet(oslSocketSet Set, oslSocket pSocket)
{
- TSocketSetImpl* pSet;
-
OSL_ASSERT(Set);
OSL_ASSERT(pSocket);
@@ -2379,19 +2375,15 @@ void SAL_CALL osl_addToSocketSet(oslSocketSet Set, oslSocket pSocket)
return;
}
- pSet= (TSocketSetImpl*)Set;
-
/* correct max handle */
- if(pSocket->m_Socket > pSet->m_MaxHandle)
- pSet->m_MaxHandle= pSocket->m_Socket;
- FD_SET(pSocket->m_Socket, &pSet->m_Set);
+ if(pSocket->m_Socket > Set->m_MaxHandle)
+ Set->m_MaxHandle= pSocket->m_Socket;
+ FD_SET(pSocket->m_Socket, &Set->m_Set);
}
void SAL_CALL osl_removeFromSocketSet(oslSocketSet Set, oslSocket pSocket)
{
- TSocketSetImpl* pSet;
-
OSL_ASSERT(Set);
OSL_ASSERT(pSocket);
@@ -2400,27 +2392,23 @@ void SAL_CALL osl_removeFromSocketSet(oslSocketSet Set, oslSocket pSocket)
return;
}
- pSet= (TSocketSetImpl*)Set;
-
/* correct max handle */
- if(pSocket->m_Socket == pSet->m_MaxHandle)
+ if(pSocket->m_Socket == Set->m_MaxHandle)
{
/* not optimal, since the next used descriptor might be */
/* much smaller than m_Socket-1, but it will do */
- pSet->m_MaxHandle--;
- if(pSet->m_MaxHandle < 0)
+ Set->m_MaxHandle--;
+ if(Set->m_MaxHandle < 0)
{
- pSet->m_MaxHandle= 0; /* avoid underflow */
+ Set->m_MaxHandle= 0; /* avoid underflow */
}
}
- FD_CLR(pSocket->m_Socket, &pSet->m_Set);
+ FD_CLR(pSocket->m_Socket, &Set->m_Set);
}
sal_Bool SAL_CALL osl_isInSocketSet(oslSocketSet Set, oslSocket pSocket)
{
- TSocketSetImpl* pSet;
-
OSL_ASSERT(Set);
OSL_ASSERT(pSocket);
if ( Set == 0 || pSocket == 0 )
@@ -2428,9 +2416,7 @@ sal_Bool SAL_CALL osl_isInSocketSet(oslSocketSet Set, oslSocket pSocket)
return sal_False;
}
- pSet= (TSocketSetImpl*)Set;
-
- return bool(FD_ISSET(pSocket->m_Socket, &pSet->m_Set));
+ return bool(FD_ISSET(pSocket->m_Socket, &Set->m_Set));
}
sal_Int32 SAL_CALL osl_demultiplexSocketEvents(oslSocketSet IncomingSet,
@@ -2440,9 +2426,6 @@ sal_Int32 SAL_CALL osl_demultiplexSocketEvents(oslSocketSet IncomingSet,
{
int MaxHandle= 0;
struct timeval tv;
- TSocketSetImpl* pInSet;
- TSocketSetImpl* pOutSet;
- TSocketSetImpl* pOOBSet;
if (pTimeout)
{
@@ -2451,25 +2434,20 @@ sal_Int32 SAL_CALL osl_demultiplexSocketEvents(oslSocketSet IncomingSet,
tv.tv_usec = pTimeout->Nanosec / 1000L;
}
- /* map opaque data to impl-types */
- pInSet= (TSocketSetImpl*)IncomingSet;
- pOutSet= (TSocketSetImpl*)OutgoingSet;
- pOOBSet= (TSocketSetImpl*)OutOfBandSet;
-
/* get max handle from all sets */
- if (pInSet)
- MaxHandle= pInSet->m_MaxHandle;
+ if (IncomingSet)
+ MaxHandle= IncomingSet->m_MaxHandle;
- if (pOutSet && (pOutSet->m_MaxHandle > MaxHandle))
- MaxHandle= pOutSet->m_MaxHandle;
+ if (OutgoingSet && (OutgoingSet->m_MaxHandle > MaxHandle))
+ MaxHandle= OutgoingSet->m_MaxHandle;
- if (pOOBSet && (pOOBSet->m_MaxHandle > MaxHandle))
- MaxHandle= pOOBSet->m_MaxHandle;
+ if (OutOfBandSet && (OutOfBandSet->m_MaxHandle > MaxHandle))
+ MaxHandle= OutOfBandSet->m_MaxHandle;
return select(MaxHandle+1,
- pInSet ? PTR_FD_SET(pInSet->m_Set) : 0,
- pOutSet ? PTR_FD_SET(pOutSet->m_Set) : 0,
- pOOBSet ? PTR_FD_SET(pOOBSet->m_Set) : 0,
+ IncomingSet ? PTR_FD_SET(IncomingSet->m_Set) : 0,
+ OutgoingSet ? PTR_FD_SET(OutgoingSet->m_Set) : 0,
+ OutOfBandSet ? PTR_FD_SET(OutOfBandSet->m_Set) : 0,
pTimeout ? &tv : 0);
}
diff --git a/sal/osl/unx/thread.cxx b/sal/osl/unx/thread.cxx
index c2f2fc95ff93..0ca411383c27 100644
--- a/sal/osl/unx/thread.cxx
+++ b/sal/osl/unx/thread.cxx
@@ -538,7 +538,7 @@ void SAL_CALL osl_yieldThread()
void SAL_CALL osl_setThreadName(char const * name) {
#if defined LINUX && ! defined __FreeBSD_kernel__
- if (prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0) != 0) {
+ if (prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(name), 0, 0, 0) != 0) {
int e = errno;
SAL_WARN("sal.osl", "prctl(PR_SET_NAME) failed with errno " << e);
}
@@ -1022,7 +1022,7 @@ rtl_TextEncoding SAL_CALL osl_getThreadTextEncoding()
/* check for thread specific encoding, use default if not set */
threadEncoding = static_cast<rtl_TextEncoding>(
- (sal_uIntPtr) pthread_getspecific(g_thread.m_textencoding.m_key));
+ reinterpret_cast<sal_uIntPtr>(pthread_getspecific(g_thread.m_textencoding.m_key)));
if (0 == threadEncoding)
threadEncoding = g_thread.m_textencoding.m_default;
@@ -1036,7 +1036,7 @@ rtl_TextEncoding osl_setThreadTextEncoding(rtl_TextEncoding Encoding)
/* save encoding in thread local storage */
pthread_setspecific (
g_thread.m_textencoding.m_key,
- (void*) static_cast<sal_uIntPtr>(Encoding));
+ reinterpret_cast<void*>(static_cast<sal_uIntPtr>(Encoding)));
return oldThreadEncoding;
}
diff --git a/sal/qa/rtl/textenc/rtl_textcvt.cxx b/sal/qa/rtl/textenc/rtl_textcvt.cxx
index 9aa6630b2462..7a142394a538 100644
--- a/sal/qa/rtl/textenc/rtl_textcvt.cxx
+++ b/sal/qa/rtl/textenc/rtl_textcvt.cxx
@@ -239,7 +239,7 @@ void doComplexCharSetTest(ComplexCharSetTest const & rTest) {
rtl_TextToUnicodeContext aContext
= rtl_createTextToUnicodeContext(aConverter);
CPPUNIT_ASSERT_MESSAGE("rtl_createTextToUnicodeContext failed", aContext != NULL);
- if (aContext != (rtl_TextToUnicodeContext) 1) {
+ if (aContext != reinterpret_cast<rtl_TextToUnicodeContext>(1)) {
sal_Size nInput = 0;
sal_Size nOutput = 0;
for (bool bFlush = true; nInput < rTest.m_nTextSize || bFlush;) {
diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx
index b826f1347571..9f3b2d237274 100644
--- a/sal/rtl/alloc_arena.cxx
+++ b/sal/rtl/alloc_arena.cxx
@@ -137,7 +137,7 @@ rtl_arena_segment_populate (
/* insert onto reserve span list */
QUEUE_INSERT_TAIL_NAMED(&(arena->m_segment_reserve_span_head), span, s);
QUEUE_START_NAMED(span, f);
- span->m_addr = (sal_uIntPtr)(span);
+ span->m_addr = reinterpret_cast<sal_uIntPtr>(span);
span->m_size = size;
span->m_type = RTL_ARENA_SEGMENT_TYPE_SPAN;
@@ -499,8 +499,9 @@ rtl_arena_segment_create (
RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock));
span->m_size = size;
- span->m_addr = (sal_uIntPtr)(arena->m_source_alloc)(
- arena->m_source_arena, &(span->m_size));
+ span->m_addr = reinterpret_cast<sal_uIntPtr>(
+ (arena->m_source_alloc)(
+ arena->m_source_arena, &(span->m_size)));
RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock));
if (span->m_addr != 0)
@@ -851,7 +852,7 @@ rtl_arena_deactivate (
QUEUE_REMOVE_NAMED(segment, s);
/* return span to g_machdep_arena */
- rtl_machdep_free (gp_machdep_arena, (void*)(segment->m_addr), segment->m_size);
+ rtl_machdep_free (gp_machdep_arena, reinterpret_cast<void*>(segment->m_addr), segment->m_size);
}
}
@@ -992,7 +993,7 @@ SAL_CALL rtl_arena_alloc (
rtl_arena_hash_insert (arena, segment);
(*pSize) = segment->m_size;
- addr = (void*)(segment->m_addr);
+ addr = reinterpret_cast<void*>(segment->m_addr);
}
RTL_MEMORY_LOCK_RELEASE(&(arena->m_lock));
}
@@ -1035,7 +1036,7 @@ SAL_CALL rtl_arena_free (
RTL_MEMORY_LOCK_ACQUIRE(&(arena->m_lock));
- segment = rtl_arena_hash_remove (arena, (sal_uIntPtr)(addr), size);
+ segment = rtl_arena_hash_remove (arena, reinterpret_cast<sal_uIntPtr>(addr), size);
if (segment != 0)
{
rtl_arena_segment_type *next, *prev;
@@ -1057,7 +1058,7 @@ SAL_CALL rtl_arena_free (
if (arena->m_source_free)
{
- addr = (void*)(prev->m_addr);
+ addr = reinterpret_cast<void*>(prev->m_addr);
size = prev->m_size;
/* remove from segment list */
diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx
index a8db5c23ed59..e85f7520ea16 100644
--- a/sal/rtl/alloc_cache.cxx
+++ b/sal/rtl/alloc_cache.cxx
@@ -229,7 +229,7 @@ rtl_cache_hash_remove (
/** RTL_CACHE_SLAB()
*/
#define RTL_CACHE_SLAB(addr, size) \
- (((rtl_cache_slab_type*)(RTL_MEMORY_P2END((sal_uIntPtr)(addr), (size)))) - 1)
+ ((reinterpret_cast<rtl_cache_slab_type*>(RTL_MEMORY_P2END(reinterpret_cast<sal_uIntPtr>(addr), (size)))) - 1)
/** rtl_cache_slab_constructor()
*/
@@ -288,7 +288,7 @@ rtl_cache_slab_create (
}
if (slab != 0)
{
- slab->m_data = (sal_uIntPtr)(addr);
+ slab->m_data = reinterpret_cast<sal_uIntPtr>(addr);
/* dynamic freelist initialization */
slab->m_bp = slab->m_data;
@@ -312,7 +312,7 @@ rtl_cache_slab_destroy (
rtl_cache_slab_type * slab
)
{
- void * addr = (void*)(slab->m_data);
+ void * addr = reinterpret_cast<void*>(slab->m_data);
sal_Size refcnt = slab->m_ntypes; slab->m_ntypes = 0;
if (cache->m_features & RTL_CACHE_FEATURE_HASH)
@@ -422,12 +422,12 @@ rtl_cache_slab_alloc (
}
bufctl->m_addr = slab->m_bp;
- bufctl->m_slab = (sal_uIntPtr)(slab);
+ bufctl->m_slab = reinterpret_cast<sal_uIntPtr>(slab);
}
else
{
/* embedded bufctl */
- bufctl = (rtl_cache_bufctl_type*)(slab->m_bp);
+ bufctl = reinterpret_cast<rtl_cache_bufctl_type*>(slab->m_bp);
}
bufctl->m_next = 0;
@@ -457,7 +457,7 @@ rtl_cache_slab_alloc (
cache->m_slab_stats.m_mem_alloc += cache->m_type_size;
if (cache->m_features & RTL_CACHE_FEATURE_HASH)
- addr = (void*)rtl_cache_hash_insert (cache, bufctl);
+ addr = reinterpret_cast<void*>(rtl_cache_hash_insert (cache, bufctl));
else
addr = bufctl;
}
@@ -484,8 +484,8 @@ rtl_cache_slab_free (
/* determine slab from addr */
if (cache->m_features & RTL_CACHE_FEATURE_HASH)
{
- bufctl = rtl_cache_hash_remove (cache, (sal_uIntPtr)(addr));
- slab = (bufctl != 0) ? (rtl_cache_slab_type*)(bufctl->m_slab) : 0;
+ bufctl = rtl_cache_hash_remove (cache, reinterpret_cast<sal_uIntPtr>(addr));
+ slab = (bufctl != 0) ? reinterpret_cast<rtl_cache_slab_type*>(bufctl->m_slab) : 0;
}
else
{
@@ -1326,7 +1326,7 @@ rtl_cache_wsupdate_init()
g_cache_list.m_update_done = 0;
(void) pthread_cond_init (&(g_cache_list.m_update_cond), NULL);
if (pthread_create (
- &(g_cache_list.m_update_thread), NULL, rtl_cache_wsupdate_all, (void*)(10)) != 0)
+ &(g_cache_list.m_update_thread), NULL, rtl_cache_wsupdate_all, reinterpret_cast<void*>(10)) != 0)
{
/* failure */
g_cache_list.m_update_thread = (pthread_t)(0);
diff --git a/sal/textenc/textcvt.cxx b/sal/textenc/textcvt.cxx
index 2710973e4941..cda7faa56464 100644
--- a/sal/textenc/textcvt.cxx
+++ b/sal/textenc/textcvt.cxx
@@ -127,7 +127,7 @@ rtl_TextToUnicodeContext SAL_CALL rtl_createTextToUnicodeContext( rtl_TextToUnic
else if ( pConverter->mpCreateTextToUnicodeContext )
return (rtl_TextToUnicodeContext)pConverter->mpCreateTextToUnicodeContext();
else
- return (rtl_TextToUnicodeContext)1;
+ return reinterpret_cast<rtl_TextToUnicodeContext>(1);
}
/* ----------------------------------------------------------------------- */
@@ -205,7 +205,7 @@ rtl_UnicodeToTextContext SAL_CALL rtl_createUnicodeToTextContext( rtl_UnicodeToT
else if ( pConverter->mpCreateUnicodeToTextContext )
return (rtl_UnicodeToTextContext)pConverter->mpCreateUnicodeToTextContext();
else
- return (rtl_UnicodeToTextContext)1;
+ return reinterpret_cast<rtl_UnicodeToTextContext>(1);
}
/* ----------------------------------------------------------------------- */