Skip to content

Commit bab81aa

Browse files
committed
Fix rpcn type cast warnings
1 parent 8a6c967 commit bab81aa

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

rpcs3/Emu/NP/rpcn_client.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ namespace rpcn
720720
if (data.size() != 4)
721721
return error_and_disconnect("Invalid size of ServerInfo packet");
722722

723-
received_version = reinterpret_cast<le_t<u32>&>(data[0]);
723+
received_version = read_from_ptr<le_t<u32>>(data, 0);
724724
server_info_received = true;
725725
break;
726726
}
@@ -1656,7 +1656,7 @@ namespace rpcn
16561656
{
16571657
std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(u16));
16581658
rpcn_client::write_communication_id(communication_id, data);
1659-
reinterpret_cast<le_t<u16>&>(data[COMMUNICATION_ID_SIZE]) = server_id;
1659+
write_to_ptr<le_t<u16>>(data, COMMUNICATION_ID_SIZE, server_id);
16601660

16611661
return forge_send(CommandType::GetWorldList, req_id, data);
16621662
}
@@ -2209,7 +2209,7 @@ namespace rpcn
22092209
pb_req.SerializeToString(&serialized);
22102210

22112211
std::vector<u8> data(serialized.size() + sizeof(u32));
2212-
reinterpret_cast<le_t<u32>&>(data[0]) = static_cast<u32>(serialized.size());
2212+
write_to_ptr<le_t<u32>>(data, 0, static_cast<u32>(serialized.size()));
22132213
memcpy(data.data() + sizeof(u32), serialized.data(), serialized.size());
22142214

22152215
return forge_send(CommandType::SendMessage, rpcn_request_counter.fetch_add(1), data);
@@ -2309,9 +2309,9 @@ namespace rpcn
23092309
std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize + sizeof(u32) + score_data.size());
23102310

23112311
rpcn_client::write_communication_id(communication_id, data);
2312-
reinterpret_cast<le_t<u32>&>(data[COMMUNICATION_ID_SIZE]) = static_cast<u32>(bufsize);
2312+
write_to_ptr<le_t<u32>>(data, COMMUNICATION_ID_SIZE, static_cast<u32>(bufsize));
23132313
memcpy(data.data() + COMMUNICATION_ID_SIZE + sizeof(u32), serialized.data(), bufsize);
2314-
reinterpret_cast<le_t<u32>&>(data[COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize]) = static_cast<u32>(score_data.size());
2314+
write_to_ptr<le_t<u32>>(data, COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize, static_cast<u32>(score_data.size()));
23152315
memcpy(data.data() + COMMUNICATION_ID_SIZE + sizeof(u32) + bufsize + sizeof(u32), score_data.data(), score_data.size());
23162316

23172317
return forge_send(CommandType::RecordScoreData, req_id, data);
@@ -2612,8 +2612,8 @@ namespace rpcn
26122612
{
26132613
std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(s32) + sizeof(s64));
26142614
rpcn_client::write_communication_id(communication_id, data);
2615-
reinterpret_cast<le_t<s32>&>(data[COMMUNICATION_ID_SIZE]) = trophy_id;
2616-
reinterpret_cast<le_t<s64>&>(data[COMMUNICATION_ID_SIZE + sizeof(s32)]) = timestamp;
2615+
write_to_ptr<le_t<s32>>(data, COMMUNICATION_ID_SIZE, trophy_id);
2616+
write_to_ptr<le_t<s64>>(data, COMMUNICATION_ID_SIZE + sizeof(s32), timestamp);
26172617
return forge_send(CommandType::UnlockTrophy, rpcn_request_counter.fetch_add(1), data);
26182618
}
26192619

@@ -2626,14 +2626,14 @@ namespace rpcn
26262626
std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(u32) + count * (sizeof(s32) + sizeof(s64))), reply_data;
26272627

26282628
rpcn_client::write_communication_id(communication_id, data);
2629-
reinterpret_cast<le_t<u32>&>(data[COMMUNICATION_ID_SIZE]) = count;
2629+
write_to_ptr<le_t<u32>>(data, COMMUNICATION_ID_SIZE, count);
26302630

26312631
usz offset = COMMUNICATION_ID_SIZE + sizeof(u32);
26322632
for (const auto& [tid, ts] : local_unlocked)
26332633
{
2634-
reinterpret_cast<le_t<s32>&>(data[offset]) = tid;
2634+
write_to_ptr<le_t<s32>>(data, offset, tid);
26352635
offset += sizeof(s32);
2636-
reinterpret_cast<le_t<s64>&>(data[offset]) = ts;
2636+
write_to_ptr<le_t<s64>>(data, offset, ts);
26372637
offset += sizeof(s64);
26382638
}
26392639

@@ -2927,7 +2927,7 @@ namespace rpcn
29272927

29282928
rpcn_client::write_communication_id(com_id, data);
29292929

2930-
reinterpret_cast<le_t<u32>&>(data[COMMUNICATION_ID_SIZE]) = static_cast<u32>(bufsize);
2930+
write_to_ptr<le_t<u32>>(data, COMMUNICATION_ID_SIZE, static_cast<u32>(bufsize));
29312931
memcpy(data.data() + COMMUNICATION_ID_SIZE + sizeof(u32), serialized_data.data(), bufsize);
29322932

29332933
return forge_send(command, packet_id, data);
@@ -2938,7 +2938,7 @@ namespace rpcn
29382938
const usz bufsize = serialized_data.size();
29392939
std::vector<u8> data(sizeof(u32) + bufsize);
29402940

2941-
reinterpret_cast<le_t<u32>&>(data[0]) = static_cast<u32>(bufsize);
2941+
write_to_ptr<le_t<u32>>(data, 0, static_cast<u32>(bufsize));
29422942
memcpy(data.data() + sizeof(u32), serialized_data.data(), bufsize);
29432943

29442944
return forge_send(command, packet_id, data);
@@ -2950,9 +2950,9 @@ namespace rpcn
29502950

29512951
std::vector<u8> packet(packet_size);
29522952
packet[0] = static_cast<u8>(PacketType::Request);
2953-
reinterpret_cast<le_t<u16>&>(packet[1]) = static_cast<u16>(command);
2954-
reinterpret_cast<le_t<u32>&>(packet[3]) = ::narrow<u32>(packet_size);
2955-
reinterpret_cast<le_t<u64>&>(packet[7]) = packet_id;
2953+
write_to_ptr<le_t<u16>>(packet, 1, static_cast<u16>(command));
2954+
write_to_ptr<le_t<u32>>(packet, 3, ::narrow<u32>(packet_size));
2955+
write_to_ptr<le_t<u64>>(packet, 7, packet_id);
29562956

29572957
memcpy(packet.data() + RPCN_HEADER_SIZE, data.data(), data.size());
29582958
return packet;

0 commit comments

Comments
 (0)