Skip to content
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

fix gcc warning in NdFetchData #95

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

BJNFNE
Copy link
Contributor

@BJNFNE BJNFNE commented Jul 29, 2024

this PR fixes this compiler warning: bddisasm_crt.c bdx86_decoder.c
bdx86_decoder.c: In function ‘NdFetchData’:
bdx86_decoder.c:104:12: warning: operand of ‘?:’ changes signedness from ‘int’ to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]
104 | (2 == Size) ? ND_FETCH_16(Buffer) :
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105 | 0;
| ~
bdx86_formatter.c
bdx86_helpers.c
Disasm library in ../bin/x64/Debug/libbddisasm.a
bddisasm_crt.c
bdx86_decoder.c
bdx86_decoder.c: In function ‘NdFetchData’:
bdx86_decoder.c:104:12: warning: operand of ‘?:’ changes signedness from ‘int’ to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]
104 | (2 == Size) ? ND_FETCH_16(Buffer) :
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105 | 0;
| ~
bdx86_formatter.c
bdx86_helpers.c
Disasm library in ../bin/x64/Release/libbddisasm.a
bdshemu.c
bdshemu_x86.c
Shemu library in ../bin/x64/Debug/libbdshemu.a
bdshemu.c
bdshemu_x86.c
Shemu library in ../bin/x64/Release/libbdshemu.a

(8 == Size) ? ND_FETCH_64(Buffer) :
(2 == Size) ? ND_FETCH_16(Buffer) :
0;
switch (Size) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The switch - case statement should adhere to the coding style used throughout the rest of the project:

switch (expression)
{
case value1:
    ...
case value2:
    ...
default:
    ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So i should call it expression instead of Size?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, you should format the code properly, like this:

switch (Size) 
{
case 1:
    return ND_FETCH_8(Buffer);
case 2:
    return ND_FETCH_16(Buffer);
case 4:
    return ND_FETCH_32(Buffer);
case 8:
    return ND_FETCH_64(Buffer);
default:
    return 0;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

this PR fixes this compiler warning: bddisasm_crt.c
bdx86_decoder.c
bdx86_decoder.c: In function ‘NdFetchData’:
bdx86_decoder.c:104:12: warning: operand of ‘?:’ changes signedness from ‘int’ to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]
  104 |            (2 == Size) ? ND_FETCH_16(Buffer) :
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105 |            0;
      |            ~
bdx86_formatter.c
bdx86_helpers.c
Disasm library in ../bin/x64/Debug/libbddisasm.a
bddisasm_crt.c
bdx86_decoder.c
bdx86_decoder.c: In function ‘NdFetchData’:
bdx86_decoder.c:104:12: warning: operand of ‘?:’ changes signedness from ‘int’ to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]
  104 |            (2 == Size) ? ND_FETCH_16(Buffer) :
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105 |            0;
      |            ~
bdx86_formatter.c
bdx86_helpers.c
Disasm library in ../bin/x64/Release/libbddisasm.a
bdshemu.c
bdshemu_x86.c
Shemu library in ../bin/x64/Debug/libbdshemu.a
bdshemu.c
bdshemu_x86.c
Shemu library in ../bin/x64/Release/libbdshemu.a
@BJNFNE BJNFNE requested a review from vlutas July 30, 2024 16:08
@vlutas vlutas merged commit 8b4cc48 into bitdefender:master Jul 31, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants