Brutally replace all reinterpret_casts with static_casts

This commit is contained in:
Andrew Nelless
2016-09-19 17:22:41 +01:00
parent e6a3caaf75
commit f3d1470e58
46 changed files with 213 additions and 213 deletions

View File

@@ -78,7 +78,7 @@ MSWindowsClipboardBitmapConverter::toIClipboard(HANDLE data) const
UInt32 srcSize = (UInt32)GlobalSize(data);
// check image type
const BITMAPINFO* bitmap = reinterpret_cast<const BITMAPINFO*>(src);
const BITMAPINFO* bitmap = static_cast<const BITMAPINFO*>(src);
LOG((CLOG_INFO "bitmap: %dx%d %d", bitmap->bmiHeader.biWidth, bitmap->bmiHeader.biHeight, (int)bitmap->bmiHeader.biBitCount));
if (bitmap->bmiHeader.biPlanes == 1 &&
(bitmap->bmiHeader.biBitCount == 24 ||

View File

@@ -241,7 +241,7 @@ void
MSWindowsDesks::getCursorPos(SInt32& x, SInt32& y) const
{
POINT pos;
sendMessage(SYNERGY_MSG_CURSOR_POS, reinterpret_cast<WPARAM>(&pos), 0);
sendMessage(SYNERGY_MSG_CURSOR_POS, static_cast<WPARAM>(&pos), 0);
x = pos.x;
y = pos.y;
}
@@ -427,7 +427,7 @@ void
MSWindowsDesks::destroyClass(ATOM windowClass) const
{
if (windowClass != 0) {
UnregisterClass(reinterpret_cast<LPCTSTR>(windowClass),
UnregisterClass(static_cast<LPCTSTR>(windowClass),
MSWindowsScreen::getWindowInstance());
}
}
@@ -437,7 +437,7 @@ MSWindowsDesks::createWindow(ATOM windowClass, const char* name) const
{
HWND window = CreateWindowEx(WS_EX_TRANSPARENT |
WS_EX_TOOLWINDOW,
reinterpret_cast<LPCTSTR>(windowClass),
static_cast<LPCTSTR>(windowClass),
name,
WS_POPUP,
0, 0, 1, 1,
@@ -656,7 +656,7 @@ MSWindowsDesks::deskThread(void* vdesk)
MSG msg;
// use given desktop for this thread
Desk* desk = reinterpret_cast<Desk*>(vdesk);
Desk* desk = static_cast<Desk*>(vdesk);
desk->m_threadID = GetCurrentThreadId();
desk->m_window = NULL;
desk->m_foregroundWindow = NULL;
@@ -757,7 +757,7 @@ MSWindowsDesks::deskThread(void* vdesk)
break;
case SYNERGY_MSG_CURSOR_POS: {
POINT* pos = reinterpret_cast<POINT*>(msg.wParam);
POINT* pos = static_cast<POINT*>(msg.wParam);
if (!GetCursorPos(pos)) {
pos->x = m_xCenter;
pos->y = m_yCenter;

View File

@@ -864,7 +864,7 @@ void
MSWindowsScreen::destroyClass(ATOM windowClass) const
{
if (windowClass != 0) {
UnregisterClass(reinterpret_cast<LPCTSTR>(windowClass), s_windowInstance);
UnregisterClass(static_cast<LPCTSTR>(windowClass), s_windowInstance);
}
}
@@ -874,7 +874,7 @@ MSWindowsScreen::createWindow(ATOM windowClass, const char* name) const
HWND window = CreateWindowEx(WS_EX_TOPMOST |
WS_EX_TRANSPARENT |
WS_EX_TOOLWINDOW,
reinterpret_cast<LPCTSTR>(windowClass),
static_cast<LPCTSTR>(windowClass),
name,
WS_POPUP,
0, 0, 1, 1,
@@ -895,7 +895,7 @@ MSWindowsScreen::createDropWindow(ATOM windowClass, const char* name) const
WS_EX_TOPMOST |
WS_EX_TRANSPARENT |
WS_EX_ACCEPTFILES,
reinterpret_cast<LPCTSTR>(m_class),
static_cast<LPCTSTR>(m_class),
name,
WS_POPUP,
0, 0, m_dropWindowSize, m_dropWindowSize,
@@ -941,7 +941,7 @@ MSWindowsScreen::sendClipboardEvent(Event::Type type, ClipboardID id)
void
MSWindowsScreen::handleSystemEvent(const Event& event, void*)
{
MSG* msg = reinterpret_cast<MSG*>(event.getData());
MSG* msg = static_cast<MSG*>(event.getData());
assert(msg != NULL);
if (ArchMiscWindows::processDialog(msg)) {

View File

@@ -162,7 +162,7 @@ MSWindowsScreenSaver::deactivate()
if (desktop != NULL) {
EnumDesktopWindows(desktop,
&MSWindowsScreenSaver::killScreenSaverFunc,
reinterpret_cast<LPARAM>(&killed));
static_cast<LPARAM>(&killed));
CloseDesktop(desktop);
}
@@ -205,7 +205,7 @@ MSWindowsScreenSaver::killScreenSaverFunc(HWND hwnd, LPARAM arg)
HINSTANCE instance = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
if (instance != MSWindowsScreen::getWindowInstance()) {
PostMessage(hwnd, WM_CLOSE, 0, 0);
*reinterpret_cast<bool*>(arg) = true;
*static_cast<bool*>(arg) = true;
}
}
return TRUE;

View File

@@ -104,7 +104,7 @@ OSXClipboardBMPConverter::fromIClipboard(const String& bmp) const
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt32>(14 + 40));
return String(reinterpret_cast<const char*>(header), 14) + bmp;
return String(static_cast<const char*>(header), 14) + bmp;
}
String
@@ -116,7 +116,7 @@ OSXClipboardBMPConverter::toIClipboard(const String& bmp) const
}
// check BMP file header
const UInt8* rawBMPHeader = reinterpret_cast<const UInt8*>(bmp.data());
const UInt8* rawBMPHeader = static_cast<const UInt8*>(bmp.data());
if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') {
return String();
}

View File

@@ -415,7 +415,7 @@ OSXKeyState::pollPressedKeys(KeyButtonSet& pressedKeys) const
{
::KeyMap km;
GetKeys(km);
const UInt8* m = reinterpret_cast<const UInt8*>(km);
const UInt8* m = static_cast<const UInt8*>(km);
for (UInt32 i = 0; i < 16; ++i) {
for (UInt32 j = 0; j < 8; ++j) {
if ((m[i] & (1u << j)) != 0) {

View File

@@ -986,7 +986,7 @@ OSXScreen::sendClipboardEvent(Event::Type type, ClipboardID id) const
void
OSXScreen::handleSystemEvent(const Event& event, void*)
{
EventRef* carbonEvent = reinterpret_cast<EventRef*>(event.getData());
EventRef* carbonEvent = static_cast<EventRef*>(event.getData());
assert(carbonEvent != NULL);
UInt32 eventClass = GetEventClass(*carbonEvent);

View File

@@ -31,7 +31,7 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void* resource,
m_sri(NULL),
m_st(NULL)
{
m_resource = reinterpret_cast<const UCKeyboardLayout*>(resource);
m_resource = static_cast<const UCKeyboardLayout*>(resource);
if (m_resource == NULL) {
return;
}
@@ -56,19 +56,19 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void* resource,
}
// get tables for keyboard type
const UInt8* base = reinterpret_cast<const UInt8*>(m_resource);
m_m = reinterpret_cast<const UCKeyModifiersToTableNum*>(base +
const UInt8* base = static_cast<const UInt8*>(m_resource);
m_m = static_cast<const UCKeyModifiersToTableNum*>(base +
th->keyModifiersToTableNumOffset);
m_cti = reinterpret_cast<const UCKeyToCharTableIndex*>(base +
m_cti = static_cast<const UCKeyToCharTableIndex*>(base +
th->keyToCharTableIndexOffset);
m_sdi = reinterpret_cast<const UCKeySequenceDataIndex*>(base +
m_sdi = static_cast<const UCKeySequenceDataIndex*>(base +
th->keySequenceDataIndexOffset);
if (th->keyStateRecordsIndexOffset != 0) {
m_sri = reinterpret_cast<const UCKeyStateRecordsIndex*>(base +
m_sri = static_cast<const UCKeyStateRecordsIndex*>(base +
th->keyStateRecordsIndexOffset);
}
if (th->keyStateTerminatorsOffset != 0) {
m_st = reinterpret_cast<const UCKeyStateTerminators*>(base +
m_st = static_cast<const UCKeyStateTerminators*>(base +
th->keyStateTerminatorsOffset);
}
@@ -81,7 +81,7 @@ OSXUchrKeyResource::OSXUchrKeyResource(const void* resource,
KeyID id = getKey(table, button);
if (id == 0x20) {
UCKeyOutput c =
reinterpret_cast<const UCKeyOutput*>(base +
static_cast<const UCKeyOutput*>(base +
m_cti->keyToCharTableOffsets[table])[button];
if ((c & kUCKeyOutputTestForIndexMask) ==
kUCKeyOutputStateIndexMask) {
@@ -134,8 +134,8 @@ OSXUchrKeyResource::getKey(UInt32 table, UInt32 button) const
assert(table < getNumTables());
assert(button < getNumButtons());
const UInt8* base = reinterpret_cast<const UInt8*>(m_resource);
const UCKeyOutput* cPtr = reinterpret_cast<const UCKeyOutput*>(base +
const UInt8* base = static_cast<const UInt8*>(m_resource);
const UCKeyOutput* cPtr = static_cast<const UCKeyOutput*>(base +
m_cti->keyToCharTableOffsets[table]);
const UCKeyOutput c = cPtr[button];
@@ -211,12 +211,12 @@ bool
OSXUchrKeyResource::getKeyRecord(
KeySequence& keys, UInt16 index, UInt16& state) const
{
const UInt8* base = reinterpret_cast<const UInt8*>(m_resource);
const UInt8* base = static_cast<const UInt8*>(m_resource);
const UCKeyStateRecord* sr =
reinterpret_cast<const UCKeyStateRecord*>(base +
static_cast<const UCKeyStateRecord*>(base +
m_sri->keyStateRecordOffsets[index]);
const UCKeyStateEntryTerminal* kset =
reinterpret_cast<const UCKeyStateEntryTerminal*>(sr->stateEntryData);
static_cast<const UCKeyStateEntryTerminal*>(sr->stateEntryData);
UInt16 nextState = 0;
bool found = false;

View File

@@ -516,7 +516,7 @@ XWindowsClipboard::icccmFillCache()
}
XWindowsUtil::convertAtomProperty(data);
const Atom* targets = reinterpret_cast<const Atom*>(data.data());
const Atom* targets = static_cast<const Atom*>(data.data());
const UInt32 numTargets = data.size() / sizeof(Atom);
LOG((CLOG_DEBUG " available targets: %s", XWindowsUtil::atomsToString(m_display, targets, numTargets).c_str()));
@@ -594,7 +594,7 @@ XWindowsClipboard::icccmGetTime() const
String data;
if (icccmGetSelection(m_atomTimestamp, &actualTarget, &data) &&
actualTarget == m_atomInteger) {
Time time = *reinterpret_cast<const Time*>(data.data());
Time time = *static_cast<const Time*>(data.data());
LOG((CLOG_DEBUG1 "got ICCCM time %d", time));
return time;
}
@@ -672,7 +672,7 @@ XWindowsClipboard::motifOwnsClipboard() const
// check the owner window against the current clipboard owner
const MotifClipHeader* header =
reinterpret_cast<const MotifClipHeader*>(data.data());
static_cast<const MotifClipHeader*>(data.data());
if (data.size() >= sizeof(MotifClipHeader) &&
header->m_id == kMotifClipHeader) {
if (static_cast<Window>(header->m_selectionOwner) == owner) {
@@ -701,7 +701,7 @@ XWindowsClipboard::motifFillCache()
// check that the header is okay
const MotifClipHeader* header =
reinterpret_cast<const MotifClipHeader*>(data.data());
static_cast<const MotifClipHeader*>(data.data());
if (data.size() < sizeof(MotifClipHeader) ||
header->m_id != kMotifClipHeader ||
header->m_numItems < 1) {
@@ -721,7 +721,7 @@ XWindowsClipboard::motifFillCache()
// check that the item is okay
const MotifClipItem* item =
reinterpret_cast<const MotifClipItem*>(data.data());
static_cast<const MotifClipItem*>(data.data());
if (data.size() < sizeof(MotifClipItem) ||
item->m_id != kMotifClipItem ||
item->m_numFormats - item->m_numDeletedFormats < 1) {
@@ -730,8 +730,8 @@ XWindowsClipboard::motifFillCache()
// format list is after static item structure elements
const SInt32 numFormats = item->m_numFormats - item->m_numDeletedFormats;
const SInt32* formats = reinterpret_cast<const SInt32*>(item->m_size +
reinterpret_cast<const char*>(data.data()));
const SInt32* formats = static_cast<const SInt32*>(item->m_size +
static_cast<const char*>(data.data()));
// get the available formats
typedef std::map<Atom, String> MotifFormatMap;
@@ -749,7 +749,7 @@ XWindowsClipboard::motifFillCache()
// check that the format is okay
const MotifClipFormat* motifFormat =
reinterpret_cast<const MotifClipFormat*>(data.data());
static_cast<const MotifClipFormat*>(data.data());
if (data.size() < sizeof(MotifClipFormat) ||
motifFormat->m_id != kMotifClipFormat ||
motifFormat->m_length < 0 ||
@@ -783,7 +783,7 @@ XWindowsClipboard::motifFillCache()
// get format
const MotifClipFormat* motifFormat =
reinterpret_cast<const MotifClipFormat*>(
static_cast<const MotifClipFormat*>(
index2->second.data());
const Atom target = motifFormat->m_type;
@@ -855,7 +855,7 @@ XWindowsClipboard::insertMultipleReply(Window requestor,
// data is a list of atom pairs: target, property
XWindowsUtil::convertAtomProperty(data);
const Atom* targets = reinterpret_cast<const Atom*>(data.data());
const Atom* targets = static_cast<const Atom*>(data.data());
const UInt32 numTargets = data.size() / sizeof(Atom);
// add replies for each target

View File

@@ -127,7 +127,7 @@ XWindowsClipboardAnyBitmapConverter::fromIClipboard(const String& bmp) const
{
// fill BMP info header with native-endian data
CBMPInfoHeader infoHeader;
const UInt8* rawBMPInfoHeader = reinterpret_cast<const UInt8*>(bmp.data());
const UInt8* rawBMPInfoHeader = static_cast<const UInt8*>(bmp.data());
infoHeader.biSize = fromLEU32(rawBMPInfoHeader + 0);
infoHeader.biWidth = fromLES32(rawBMPInfoHeader + 4);
infoHeader.biHeight = fromLES32(rawBMPInfoHeader + 8);
@@ -186,6 +186,6 @@ XWindowsClipboardAnyBitmapConverter::toIClipboard(const String& image) const
toLE(dst, static_cast<UInt32>(0));
// construct image
return String(reinterpret_cast<const char*>(infoHeader),
return String(static_cast<const char*>(infoHeader),
sizeof(infoHeader)) + rawBMP;
}

View File

@@ -113,7 +113,7 @@ XWindowsClipboardBMPConverter::fromIClipboard(const String& bmp) const
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt16>(0));
toLE(dst, static_cast<UInt32>(14 + 40));
return String(reinterpret_cast<const char*>(header), 14) + bmp;
return String(static_cast<const char*>(header), 14) + bmp;
}
String
@@ -125,7 +125,7 @@ XWindowsClipboardBMPConverter::toIClipboard(const String& bmp) const
}
// check BMP file header
const UInt8* rawBMPHeader = reinterpret_cast<const UInt8*>(bmp.data());
const UInt8* rawBMPHeader = static_cast<const UInt8*>(bmp.data());
if (rawBMPHeader[0] != 'B' || rawBMPHeader[1] != 'M') {
return String();
}

View File

@@ -785,7 +785,7 @@ void
XWindowsKeyState::remapKeyModifiers(KeyID id, SInt32 group,
synergy::KeyMap::KeyItem& item, void* vself)
{
XWindowsKeyState* self = reinterpret_cast<XWindowsKeyState*>(vself);
XWindowsKeyState* self = static_cast<XWindowsKeyState*>(vself);
item.m_required =
self->mapModifiersFromX(XkbBuildCoreState(item.m_required, group));
item.m_sensitive =

View File

@@ -1169,7 +1169,7 @@ XWindowsScreen::getKeyState() const
Bool
XWindowsScreen::findKeyEvent(Display*, XEvent* xevent, XPointer arg)
{
KeyEventFilter* filter = reinterpret_cast<KeyEventFilter*>(arg);
KeyEventFilter* filter = static_cast<KeyEventFilter*>(arg);
return (xevent->type == filter->m_event &&
xevent->xkey.window == filter->m_window &&
xevent->xkey.time == filter->m_time &&
@@ -1179,7 +1179,7 @@ XWindowsScreen::findKeyEvent(Display*, XEvent* xevent, XPointer arg)
void
XWindowsScreen::handleSystemEvent(const Event& event, void*)
{
XEvent* xevent = reinterpret_cast<XEvent*>(event.getData());
XEvent* xevent = static_cast<XEvent*>(event.getData());
assert(xevent != NULL);
// update key state
@@ -1408,7 +1408,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*)
default:
#if HAVE_XKB_EXTENSION
if (m_xkb && xevent->type == m_xkbEventBase) {
XkbEvent* xkbEvent = reinterpret_cast<XkbEvent*>(xevent);
XkbEvent* xkbEvent = static_cast<XkbEvent*>(xevent);
switch (xkbEvent->any.xkb_type) {
case XkbMapNotify:
refreshKeyboard(xevent);
@@ -1426,7 +1426,7 @@ XWindowsScreen::handleSystemEvent(const Event& event, void*)
if (m_xrandr) {
if (xevent->type == m_xrandrEventBase + RRScreenChangeNotify
|| xevent->type == m_xrandrEventBase + RRNotify
&& reinterpret_cast<XRRNotifyEvent *>(xevent)->subtype == RRNotify_CrtcChange) {
&& static_cast<XRRNotifyEvent *>(xevent)->subtype == RRNotify_CrtcChange) {
LOG((CLOG_INFO "XRRScreenChangeNotifyEvent or RRNotify_CrtcChange received"));
// we're required to call back into XLib so XLib can update its internal state

View File

@@ -1386,7 +1386,7 @@ XWindowsUtil::setWindowProperty(Display* display, Window window,
Atom type, SInt32 format)
{
const UInt32 length = 4 * XMaxRequestSize(display);
const unsigned char* data = reinterpret_cast<const unsigned char*>(vdata);
const unsigned char* data = static_cast<const unsigned char*>(vdata);
UInt32 datumSize = static_cast<UInt32>(format / 8);
// format 32 on 64bit systems is 8 bytes not 4.
if (format == 32) {
@@ -1665,35 +1665,35 @@ XWindowsUtil::convertAtomProperty(String& data)
// 64-bit numbers we have to ensure the last number is a full 64 bits.
if (sizeof(Atom) != 4 && ((data.size() / 4) & 1) != 0) {
UInt32 zero = 0;
data.append(reinterpret_cast<char*>(&zero), sizeof(zero));
data.append(static_cast<char*>(&zero), sizeof(zero));
}
}
void
XWindowsUtil::appendAtomData(String& data, Atom atom)
{
data.append(reinterpret_cast<char*>(&atom), sizeof(Atom));
data.append(static_cast<char*>(&atom), sizeof(Atom));
}
void
XWindowsUtil::replaceAtomData(String& data, UInt32 index, Atom atom)
{
data.replace(index * sizeof(Atom), sizeof(Atom),
reinterpret_cast<const char*>(&atom),
static_cast<const char*>(&atom),
sizeof(Atom));
}
void
XWindowsUtil::appendTimeData(String& data, Time time)
{
data.append(reinterpret_cast<char*>(&time), sizeof(Time));
data.append(static_cast<char*>(&time), sizeof(Time));
}
Bool
XWindowsUtil::propertyNotifyPredicate(Display*, XEvent* xevent, XPointer arg)
{
PropertyNotifyPredicateInfo* filter =
reinterpret_cast<PropertyNotifyPredicateInfo*>(arg);
static_cast<PropertyNotifyPredicateInfo*>(arg);
return (xevent->type == PropertyNotify &&
xevent->xproperty.window == filter->m_window &&
xevent->xproperty.atom == filter->m_property &&
@@ -1784,5 +1784,5 @@ void
XWindowsUtil::ErrorLock::saveHandler(Display*, XErrorEvent* e, void* flag)
{
LOG((CLOG_DEBUG1 "flagging X error: %d", e->error_code));
*reinterpret_cast<bool*>(flag) = true;
*static_cast<bool*>(flag) = true;
}