-
Notifications
You must be signed in to change notification settings - Fork 154
Fix UBSAN errors in unit tests #935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
c963b40
to
161e5a4
Compare
I think I've seen this error in another PR, might be a problem with IT itself |
0fa87a1
to
92f5486
Compare
switch (res) { | ||
case bmqt::GenericResult::Enum::e_SUCCESS: { | ||
return bmqp_ctrlmsg::StatusCategory::E_SUCCESS; | ||
} break; | ||
case bmqt::GenericResult::Enum::e_UNKNOWN: { | ||
return bmqp_ctrlmsg::StatusCategory::E_UNKNOWN; | ||
} break; | ||
case bmqt::GenericResult::Enum::e_TIMEOUT: { | ||
return bmqp_ctrlmsg::StatusCategory::E_TIMEOUT; | ||
} break; | ||
case bmqt::GenericResult::Enum::e_NOT_CONNECTED: { | ||
return bmqp_ctrlmsg::StatusCategory::E_NOT_CONNECTED; | ||
} break; | ||
case bmqt::GenericResult::Enum::e_CANCELED: { | ||
return bmqp_ctrlmsg::StatusCategory::E_CANCELED; | ||
} break; | ||
case bmqt::GenericResult::Enum::e_NOT_SUPPORTED: { | ||
return bmqp_ctrlmsg::StatusCategory::E_NOT_SUPPORTED; | ||
} break; | ||
case bmqt::GenericResult::Enum::e_REFUSED: { | ||
return bmqp_ctrlmsg::StatusCategory::E_REFUSED; | ||
} break; | ||
case bmqt::GenericResult::Enum::e_INVALID_ARGUMENT: { | ||
return bmqp_ctrlmsg::StatusCategory::E_INVALID_ARGUMENT; | ||
} break; | ||
case bmqt::GenericResult::Enum::e_NOT_READY: { | ||
return bmqp_ctrlmsg::StatusCategory::E_NOT_READY; | ||
} break; | ||
default: { | ||
return bmqp_ctrlmsg::StatusCategory::E_UNKNOWN; | ||
} break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch (res) { | |
case bmqt::GenericResult::Enum::e_SUCCESS: { | |
return bmqp_ctrlmsg::StatusCategory::E_SUCCESS; | |
} break; | |
case bmqt::GenericResult::Enum::e_UNKNOWN: { | |
return bmqp_ctrlmsg::StatusCategory::E_UNKNOWN; | |
} break; | |
case bmqt::GenericResult::Enum::e_TIMEOUT: { | |
return bmqp_ctrlmsg::StatusCategory::E_TIMEOUT; | |
} break; | |
case bmqt::GenericResult::Enum::e_NOT_CONNECTED: { | |
return bmqp_ctrlmsg::StatusCategory::E_NOT_CONNECTED; | |
} break; | |
case bmqt::GenericResult::Enum::e_CANCELED: { | |
return bmqp_ctrlmsg::StatusCategory::E_CANCELED; | |
} break; | |
case bmqt::GenericResult::Enum::e_NOT_SUPPORTED: { | |
return bmqp_ctrlmsg::StatusCategory::E_NOT_SUPPORTED; | |
} break; | |
case bmqt::GenericResult::Enum::e_REFUSED: { | |
return bmqp_ctrlmsg::StatusCategory::E_REFUSED; | |
} break; | |
case bmqt::GenericResult::Enum::e_INVALID_ARGUMENT: { | |
return bmqp_ctrlmsg::StatusCategory::E_INVALID_ARGUMENT; | |
} break; | |
case bmqt::GenericResult::Enum::e_NOT_READY: { | |
return bmqp_ctrlmsg::StatusCategory::E_NOT_READY; | |
} break; | |
default: { | |
return bmqp_ctrlmsg::StatusCategory::E_UNKNOWN; | |
} break; | |
} | |
#define BMQIMP_CASE(CODE) \ | |
case bmqt::GenericResult::Enum::CODE: { \ | |
return bmqp_ctrlmsg::StatusCategory::CODE; \ | |
} break; | |
switch (res) { | |
BMQIMP_CASE(e_SUCCESS); | |
BMQIMP_CASE(e_UNKNOWN); | |
BMQIMP_CASE(e_TIMEOUT); | |
BMQIMP_CASE(e_NOT_CONNECTED); | |
BMQIMP_CASE(e_CANCELED); | |
BMQIMP_CASE(e_NOT_SUPPORTED); | |
BMQIMP_CASE(e_REFUSED); | |
BMQIMP_CASE(e_INVALID_ARGUMENT); | |
BMQIMP_CASE(e_NOT_READY); | |
default: { | |
return bmqp_ctrlmsg::StatusCategory::E_UNKNOWN; | |
} break; | |
} | |
#undef BMQIMP_CASE |
Possible alternative. I guess the original variant is easier for search though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be alright, but there is a slight issue in that one of these enums are named with e_VALUE
, and the other is named E_VALUE
389d6f6
to
f20277d
Compare
- Deleted tests that were intentionally invoking UB by casting an out of range int to an enum - Fixed the status code handling in queue FSM mode to appropriately convert out of range error codes into the UKNOWN category - Fixed other test cases with UB Signed-off-by: Aleksandr Ivanov <[email protected]> Signed-off-by: Taylor Foxhall <[email protected]>
This is mostly addressing the outstanding issues in #829. There are a handful of changes:
UKNOWN
category