Skip to content

Conversation

@joaosaffran
Copy link
Collaborator

CodeQL found some issues within this repo, this patch fixes those issues following it's recommended approach

@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

"otherwise the caller did not check");
m_Mask = 0;
for (BYTE c = StartComp; c < StartComp + NumComp; c++) {
BYTE EndComp = StartComp + NumComp;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems weird to me that the change above is removing the BYTE type but not here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In both scenarios, code ql complain is:

Comparisons between types of different widths in a loop condition can cause the loop to behave unexpectedly.

In this instance:

for (BYTE c = 0; c < SE.GetCols(); c++) {
      BYTE Comp = SE.GetStartCol() + c;

SE.GetCols() returns an unsigned int, and c only usage is in order to calculate Comp which only usage is at function: GetRegIndex, which if you check expects an unsigned int. Since all usages are of unsigned int, I found that it made sense to change the type to unsigned int.

Now, in this scenario:

for (BYTE c = StartComp; c < StartComp + NumComp; c++) {

The issue is being cause because, StartComp + NumComp results in an int, while c is still a byte. Therefore, I found it easier to cast it back to BYTE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants