Rewrite simple pointer casts from C style to reinterpret_cast<>

This pass only targets int8_t and uint8_t.

s/(\s*\(u\?int8_t\s*\*\+\)\s*)\s*(/reinterpret_cast<\1>(/g
This commit is contained in:
Kp 2016-07-03 00:54:14 +00:00
parent a7ceee3c03
commit 19f31eb420
7 changed files with 40 additions and 40 deletions

View file

@ -298,12 +298,12 @@ static int fill_buffer(hmp_file *hmp) {
i = hmp->pending_size;
*(p++) = hmp->pending_event | i;
*(p++) = 0;
memcpy((uint8_t *)(p), hmp->pending, i);
memcpy(reinterpret_cast<uint8_t *>(p), hmp->pending, i);
hmp->pending_size -= i;
p += (i + 3) / 4;
} else {
if ((i = get_event(hmp, &ev))) {
mhdr->dwBytesRecorded = ((uint8_t *)(p)) - ((uint8_t *)(mhdr->lpData));
mhdr->dwBytesRecorded = (reinterpret_cast<uint8_t *>(p)) - (reinterpret_cast<uint8_t *>(mhdr->lpData));
return i;
}
if (ev.datalen) {
@ -320,7 +320,7 @@ static int fill_buffer(hmp_file *hmp) {
}
}
}
mhdr->dwBytesRecorded = ((uint8_t *)(p)) - ((uint8_t *)(mhdr->lpData));
mhdr->dwBytesRecorded = (reinterpret_cast<uint8_t *>(p)) - (reinterpret_cast<uint8_t *>(mhdr->lpData));
return 0;
}

View file

@ -29,14 +29,14 @@ void decodeFrame8(unsigned char *pFrame, const unsigned char *pMap, int mapRemai
for (int i=0; i<xb/2; i++)
{
dispatchDecoder(&pFrame, (*pMap) & 0xf, &pData, &dataRemain, &i, &j);
if (pFrame < (uint8_t *)(g_vBackBuf1))
if (pFrame < reinterpret_cast<uint8_t *>(g_vBackBuf1))
con_printf(CON_CRITICAL, "danger! pointing out of bounds below after dispatch decoder: %d, %d (1) [%x]", i, j, (*pMap) & 0xf);
else if (pFrame >= ((uint8_t *)(g_vBackBuf1)) + g_width*g_height)
else if (pFrame >= (reinterpret_cast<uint8_t *>(g_vBackBuf1)) + g_width*g_height)
con_printf(CON_CRITICAL, "danger! pointing out of bounds above after dispatch decoder: %d, %d (1) [%x]", i, j, (*pMap) & 0xf);
dispatchDecoder(&pFrame, (*pMap) >> 4, &pData, &dataRemain, &i, &j);
if (pFrame < (uint8_t *)(g_vBackBuf1))
if (pFrame < reinterpret_cast<uint8_t *>(g_vBackBuf1))
con_printf(CON_CRITICAL, "danger! pointing out of bounds below after dispatch decoder: %d, %d (2) [%x]", i, j, (*pMap) >> 4);
else if (pFrame >= ((uint8_t *)(g_vBackBuf1)) + g_width*g_height)
else if (pFrame >= (reinterpret_cast<uint8_t *>(g_vBackBuf1)) + g_width*g_height)
con_printf(CON_CRITICAL, "danger! pointing out of bounds above after dispatch decoder: %d, %d (2) [%x]", i, j, (*pMap) >> 4);
++pMap;
@ -229,7 +229,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, cons
{
case 0x0:
/* block is copied from block in current frame */
copyFrame(*pFrame, *pFrame + ((uint8_t *)(g_vBackBuf2) - (uint8_t *)(g_vBackBuf1)));
copyFrame(*pFrame, *pFrame + (reinterpret_cast<uint8_t *>(g_vBackBuf2) - reinterpret_cast<uint8_t *>(g_vBackBuf1)));
case 0x1:
/* block is unchanged from two frames ago */
*pFrame += 8;
@ -287,7 +287,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, cons
y = -8 + BH
*/
relClose(*(*pData)++, &x, &y);
copyFrame(*pFrame, *pFrame + ((uint8_t *)(g_vBackBuf2) - (uint8_t *)(g_vBackBuf1)) + x + y*g_width);
copyFrame(*pFrame, *pFrame + (reinterpret_cast<uint8_t *>(g_vBackBuf2) - reinterpret_cast<uint8_t *>(g_vBackBuf1)) + x + y*g_width);
*pFrame += 8;
--*pDataRemain;
break;
@ -300,7 +300,7 @@ static void dispatchDecoder(unsigned char **pFrame, unsigned char codeType, cons
*/
x = (signed char)*(*pData)++;
y = (signed char)*(*pData)++;
copyFrame(*pFrame, *pFrame + ((uint8_t *)(g_vBackBuf2) - (uint8_t *)(g_vBackBuf1)) + x + y*g_width);
copyFrame(*pFrame, *pFrame + (reinterpret_cast<uint8_t *>(g_vBackBuf2) - reinterpret_cast<uint8_t *>(g_vBackBuf1)) + x + y*g_width);
*pFrame += 8;
*pDataRemain -= 2;
break;

View file

@ -629,7 +629,7 @@ static int video_data_handler(unsigned char, unsigned char, const unsigned char
if (nFlags & 1)
{
temp = (uint8_t *)(g_vBackBuf1);
temp = reinterpret_cast<uint8_t *>(g_vBackBuf1);
g_vBackBuf1 = g_vBackBuf2;
g_vBackBuf2 = temp;
}

View file

@ -2759,7 +2759,7 @@ void multi_send_kill(const vobjptridx_t objnum)
if (killer_objnum != object_none)
{
short s = (short)objnum_local_to_remote(killer_objnum, (int8_t *)(&multibuf[count+2])); // do it with variable since INTEL_SHORT won't work on return val from function.
short s = (short)objnum_local_to_remote(killer_objnum, reinterpret_cast<int8_t *>(&multibuf[count+2])); // do it with variable since INTEL_SHORT won't work on return val from function.
PUT_INTEL_SHORT(multibuf+count, s);
}
else

View file

@ -348,7 +348,7 @@ void multi_send_release_robot(const vobjptridx_t objnum)
multi_delete_controlled_robot(objnum);
multibuf[1] = Player_num;
s = objnum_local_to_remote(objnum, (int8_t *)(&multibuf[4]));
s = objnum_local_to_remote(objnum, reinterpret_cast<int8_t *>(&multibuf[4]));
PUT_INTEL_SHORT(multibuf+2, s);
multi_send_data<MULTI_ROBOT_RELEASE>(multibuf, 5, 2);
@ -426,7 +426,7 @@ void multi_send_robot_position_sub(const vobjptridx_t objnum, int now)
loc += 1;
multibuf[loc] = Player_num; loc += 1;
s = objnum_local_to_remote(objnum, (int8_t *)(&multibuf[loc+2]));
s = objnum_local_to_remote(objnum, reinterpret_cast<int8_t *>(&multibuf[loc+2]));
PUT_INTEL_SHORT(multibuf+loc, s); loc += 3; // 5
quaternionpos qpp{};
@ -482,7 +482,7 @@ void multi_send_robot_fire(const vobjptridx_t obj, int gun_num, const vms_vector
loc += 1;
multibuf[loc] = Player_num; loc += 1;
s = objnum_local_to_remote(obj, (int8_t *)(&multibuf[loc+2]));
s = objnum_local_to_remote(obj, reinterpret_cast<int8_t *>(&multibuf[loc+2]));
PUT_INTEL_SHORT(multibuf+loc, s);
loc += 3;
multibuf[loc] = gun_num; loc += 1;

View file

@ -1669,7 +1669,7 @@ static int newdemo_read_demo_start(enum purpose_type purpose)
{
if (Newdemo_game_mode & GM_TEAM)
{
nd_read_byte((int8_t *)(&Netgame.team_vector));
nd_read_byte(reinterpret_cast<int8_t *>(&Netgame.team_vector));
if (purpose == PURPOSE_REWRITE)
nd_write_byte(Netgame.team_vector);
}
@ -1686,7 +1686,7 @@ static int newdemo_read_demo_start(enum purpose_type purpose)
else
{
if (Newdemo_game_mode & GM_TEAM) {
nd_read_byte((int8_t *) (&Netgame.team_vector));
nd_read_byte(reinterpret_cast<int8_t *>(&Netgame.team_vector));
nd_read_string(Netgame.team_name[0].buffer());
nd_read_string(Netgame.team_name[1].buffer());
if (purpose == PURPOSE_REWRITE)
@ -1704,7 +1704,7 @@ static int newdemo_read_demo_start(enum purpose_type purpose)
N_players = static_cast<int>(c);
// changed this to above two lines -- breaks on the mac because of
// endian issues
// nd_read_byte((int8_t *)(&N_players));
// nd_read_byte(reinterpret_cast<int8_t *>(&N_players));
if (purpose == PURPOSE_REWRITE)
nd_write_byte(N_players);
range_for (auto &i, partial_range(Players, N_players)) {
@ -1811,8 +1811,8 @@ static int newdemo_read_demo_start(enum purpose_type purpose)
nd_recorded_total = 0;
nd_playback_total = 0;
nd_read_byte((int8_t *)(&energy));
nd_read_byte((int8_t *)(&shield));
nd_read_byte(reinterpret_cast<int8_t *>(&energy));
nd_read_byte(reinterpret_cast<int8_t *>(&shield));
if (purpose == PURPOSE_REWRITE)
{
nd_write_byte(energy);
@ -1830,8 +1830,8 @@ static int newdemo_read_demo_start(enum purpose_type purpose)
if (get_local_player_flags() & PLAYER_FLAGS_INVULNERABLE)
get_local_player_invulnerable_time() = GameTime64 - (INVULNERABLE_TIME_MAX / 2);
nd_read_byte((int8_t *)(&Primary_weapon));
nd_read_byte((int8_t *)(&Secondary_weapon));
nd_read_byte(reinterpret_cast<int8_t *>(&Primary_weapon));
nd_read_byte(reinterpret_cast<int8_t *>(&Secondary_weapon));
if (purpose == PURPOSE_REWRITE)
{
nd_write_byte(Primary_weapon);
@ -1845,7 +1845,7 @@ static int newdemo_read_demo_start(enum purpose_type purpose)
#if defined(DXX_BUILD_DESCENT_I)
if (shareware)
{
nd_read_byte((int8_t *)(&c));
nd_read_byte(reinterpret_cast<int8_t *>(&c));
if (c != ND_EVENT_NEW_LEVEL) {
auto flags = get_local_player_flags().get_player_flags();
energy = shield;
@ -2349,8 +2349,8 @@ static int newdemo_read_frame_information(int rewrite)
ubyte old_energy;
if (!shareware)
nd_read_byte((int8_t *)(&old_energy));
nd_read_byte((int8_t *)(&energy));
nd_read_byte(reinterpret_cast<int8_t *>(&old_energy));
nd_read_byte(reinterpret_cast<int8_t *>(&energy));
if (nd_playback_v_bad_read) {done = -1; break; }
if (rewrite)
@ -2378,8 +2378,8 @@ static int newdemo_read_frame_information(int rewrite)
ubyte afterburner;
ubyte old_afterburner;
nd_read_byte((int8_t *)(&old_afterburner));
nd_read_byte((int8_t *)(&afterburner));
nd_read_byte(reinterpret_cast<int8_t *>(&old_afterburner));
nd_read_byte(reinterpret_cast<int8_t *>(&afterburner));
if (nd_playback_v_bad_read) {done = -1; break; }
if (rewrite)
{
@ -2403,8 +2403,8 @@ static int newdemo_read_frame_information(int rewrite)
ubyte old_shield;
if (!shareware)
nd_read_byte((int8_t *)(&old_shield));
nd_read_byte((int8_t *)(&shield));
nd_read_byte(reinterpret_cast<int8_t *>(&old_shield));
nd_read_byte(reinterpret_cast<int8_t *>(&shield));
if (nd_playback_v_bad_read) {done = -1; break; }
if (rewrite)
{
@ -2473,8 +2473,8 @@ static int newdemo_read_frame_information(int rewrite)
{
ubyte weapon_type, weapon_num;
nd_read_byte((int8_t *)(&weapon_type));
nd_read_byte((int8_t *)(&weapon_num));
nd_read_byte(reinterpret_cast<int8_t *>(&weapon_type));
nd_read_byte(reinterpret_cast<int8_t *>(&weapon_num));
if (rewrite)
{
nd_write_byte(weapon_type);
@ -2494,9 +2494,9 @@ static int newdemo_read_frame_information(int rewrite)
ubyte weapon_type, weapon_num;
ubyte old_weapon;
nd_read_byte((int8_t *)(&weapon_type));
nd_read_byte((int8_t *)(&weapon_num));
nd_read_byte((int8_t *)(&old_weapon));
nd_read_byte(reinterpret_cast<int8_t *>(&weapon_type));
nd_read_byte(reinterpret_cast<int8_t *>(&weapon_num));
nd_read_byte(reinterpret_cast<int8_t *>(&old_weapon));
if (rewrite)
{
nd_write_byte(weapon_type);
@ -3269,8 +3269,8 @@ void newdemo_goto_end(int to_rewrite)
nd_read_short(&bshort);
nd_read_int(&bint);
nd_read_byte((int8_t *)(&energy));
nd_read_byte((int8_t *)(&shield));
nd_read_byte(reinterpret_cast<int8_t *>(&energy));
nd_read_byte(reinterpret_cast<int8_t *>(&shield));
get_local_player_energy() = i2f(energy);
get_local_player_shields() = i2f(shield);
int recorded_player_flags;
@ -3281,8 +3281,8 @@ void newdemo_goto_end(int to_rewrite)
}
if (get_local_player_flags() & PLAYER_FLAGS_INVULNERABLE)
get_local_player_invulnerable_time() = GameTime64 - (INVULNERABLE_TIME_MAX / 2);
nd_read_byte((int8_t *)(&Primary_weapon));
nd_read_byte((int8_t *)(&Secondary_weapon));
nd_read_byte(reinterpret_cast<int8_t *>(&Primary_weapon));
nd_read_byte(reinterpret_cast<int8_t *>(&Secondary_weapon));
for (int i = 0; i < MAX_PRIMARY_WEAPONS; i++)
{
short s;
@ -3309,7 +3309,7 @@ void newdemo_goto_end(int to_rewrite)
N_players = static_cast<int>(c);
// see newdemo_read_start_demo for explanation of
// why this is commented out
// nd_read_byte((int8_t *)(&N_players));
// nd_read_byte(reinterpret_cast<int8_t *>(&N_players));
range_for (auto &i, partial_range(Players, N_players)) {
nd_read_string(i.callsign.buffer());
nd_read_byte(&(i.connected));

View file

@ -1841,7 +1841,7 @@ static void bitmap_read_d1( grs_bitmap *bitmap, /* read into this bitmap */
*next_bitmap += new_size - zsize;
} else {
Assert( zsize + JUST_IN_CASE >= new_size );
bitmap->bm_mdata = (uint8_t *) (d_realloc(bitmap->bm_mdata, new_size));
bitmap->bm_mdata = reinterpret_cast<uint8_t *>(d_realloc(bitmap->bm_mdata, new_size));
Assert(bitmap->bm_data);
}
}