Merge pull request #5293 from ReinUsesLisp/return-values

core: Enforce C4715 (not all control paths return a value)
This commit is contained in:
bunnei 2021-01-05 19:04:15 -08:00 committed by GitHub
commit dc02b03c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 8 deletions

View File

@ -635,6 +635,8 @@ if (MSVC)
/we4267 /we4267
# 'context' : truncation from 'type1' to 'type2' # 'context' : truncation from 'type1' to 'type2'
/we4305 /we4305
# 'function' : not all control paths return a value
/we4715
) )
else() else()
target_compile_options(core PRIVATE target_compile_options(core PRIVATE

View File

@ -143,6 +143,7 @@ u64 GetSignatureTypeDataSize(SignatureType type) {
return 0x3C; return 0x3C;
} }
UNREACHABLE(); UNREACHABLE();
return 0;
} }
u64 GetSignatureTypePaddingSize(SignatureType type) { u64 GetSignatureTypePaddingSize(SignatureType type) {
@ -157,6 +158,7 @@ u64 GetSignatureTypePaddingSize(SignatureType type) {
return 0x40; return 0x40;
} }
UNREACHABLE(); UNREACHABLE();
return 0;
} }
SignatureType Ticket::GetSignatureType() const { SignatureType Ticket::GetSignatureType() const {
@ -169,8 +171,7 @@ SignatureType Ticket::GetSignatureType() const {
if (const auto* ticket = std::get_if<ECDSATicket>(&data)) { if (const auto* ticket = std::get_if<ECDSATicket>(&data)) {
return ticket->sig_type; return ticket->sig_type;
} }
throw std::bad_variant_access{};
UNREACHABLE();
} }
TicketData& Ticket::GetData() { TicketData& Ticket::GetData() {
@ -183,8 +184,7 @@ TicketData& Ticket::GetData() {
if (auto* ticket = std::get_if<ECDSATicket>(&data)) { if (auto* ticket = std::get_if<ECDSATicket>(&data)) {
return ticket->data; return ticket->data;
} }
throw std::bad_variant_access{};
UNREACHABLE();
} }
const TicketData& Ticket::GetData() const { const TicketData& Ticket::GetData() const {
@ -197,8 +197,7 @@ const TicketData& Ticket::GetData() const {
if (const auto* ticket = std::get_if<ECDSATicket>(&data)) { if (const auto* ticket = std::get_if<ECDSATicket>(&data)) {
return ticket->data; return ticket->data;
} }
throw std::bad_variant_access{};
UNREACHABLE();
} }
u64 Ticket::GetSize() const { u64 Ticket::GetSize() const {

View File

@ -51,8 +51,8 @@ std::pair<std::size_t, std::size_t> SearchBucketEntry(u64 offset, const BlockTyp
low = mid + 1; low = mid + 1;
} }
} }
UNREACHABLE_MSG("Offset could not be found in BKTR block."); UNREACHABLE_MSG("Offset could not be found in BKTR block.");
return {0, 0};
} }
} // Anonymous namespace } // Anonymous namespace

View File

@ -105,7 +105,8 @@ ContentRecordType GetCRTypeFromNCAType(NCAContentType type) {
// TODO(DarkLordZach): Peek at NCA contents to differentiate Manual and Legal. // TODO(DarkLordZach): Peek at NCA contents to differentiate Manual and Legal.
return ContentRecordType::HtmlDocument; return ContentRecordType::HtmlDocument;
default: default:
UNREACHABLE_MSG("Invalid NCAContentType={:02X}", static_cast<u8>(type)); UNREACHABLE_MSG("Invalid NCAContentType={:02X}", type);
return ContentRecordType{};
} }
} }

View File

@ -96,6 +96,7 @@ u64 AddressSpaceInfo::GetAddressSpaceStart(std::size_t width, Type type) {
return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].address; return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].address;
} }
UNREACHABLE(); UNREACHABLE();
return 0;
} }
std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type) { std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type) {
@ -112,6 +113,7 @@ std::size_t AddressSpaceInfo::GetAddressSpaceSize(std::size_t width, Type type)
return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].size; return AddressSpaceInfos[AddressSpaceIndices39Bit[index]].size;
} }
UNREACHABLE(); UNREACHABLE();
return 0;
} }
} // namespace Kernel::Memory } // namespace Kernel::Memory

View File

@ -64,6 +64,7 @@ Network::Type Translate(Type type) {
return Network::Type::DGRAM; return Network::Type::DGRAM;
default: default:
UNIMPLEMENTED_MSG("Unimplemented type={}", type); UNIMPLEMENTED_MSG("Unimplemented type={}", type);
return Network::Type{};
} }
} }