Skip to content

Commit

Permalink
Add missing assert for getAlignment ret value
Browse files Browse the repository at this point in the history
getAlignment() (visa_igc_common_header.h) returns VISA_Align (enum) type
value. For that it performs a cast. That could potentially result in
returning a value not defined in the enum. This commit adds an assert
that checks if that's the case.
  • Loading branch information
smilczek authored and igcbot committed Jul 25, 2023
1 parent 490df0b commit 0c1367e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion visa/Common_ISA.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ struct var_info_t {
VISA_Type getType() const { return (VISA_Type)(bit_properties & 0xF); }

VISA_Align getAlignment() const {
return (VISA_Align)((bit_properties >> 4) & 0xF);
VISA_Align alignment = (VISA_Align)((bit_properties >> 4) & 0xF);
vASSERT(alignment <= ALIGN_TOTAL_NUM);

return alignment;
}

VISA_Align getTypeAlignment(unsigned grfSize) const {
Expand Down

0 comments on commit 0c1367e

Please sign in to comment.