Kaydet (Commit) 7b1261f6 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

loplugin:cstylecast: sal

Change-Id: I0ad9681a8b31d78cefce5b66040415154a1c7a99
üst d1a74c27
......@@ -97,19 +97,12 @@ bool CStyleCast::VisitCStyleCastExpr(const CStyleCastExpr * expr) {
return true;
}
if ( compat::isInMainFile(compiler.getSourceManager(), spellingLocation) ) {
if (filename.startswith(SRCDIR "/sal/") // sal has tons of weird stuff going on that I don't understand enough to fix
|| filename.startswith(SRCDIR "/bridges/")) { // I'm not messing with this code - far too dangerous
if (filename.startswith(SRCDIR "/bridges/")) { // I'm not messing with this code - far too dangerous
return true;
}
} else {
if (filename == SRCDIR "/include/tools/solar.h"
|| filename.startswith(SRCDIR "/include/cppuhelper/")
|| ((StringRef(
compiler.getSourceManager().getFileEntryForID(
compiler.getSourceManager().getMainFileID())
->getName())
== SRCDIR "/jurt/source/pipe/staticsalhack.cxx")
&& filename.startswith(SRCDIR "/sal/"))) {
|| filename.startswith(SRCDIR "/include/cppuhelper/")) {
return true;
}
}
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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;) {
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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);
}
/* ----------------------------------------------------------------------- */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment