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 a compilation warning #3682

Merged
merged 1 commit into from
Aug 3, 2024
Merged

Fix a compilation warning #3682

merged 1 commit into from
Aug 3, 2024

Conversation

no1wudi
Copy link
Collaborator

@no1wudi no1wudi commented Aug 2, 2024

Fix:

wamr/core/iwasm/compilation/aot_llvm.c: In function ‘insert_native_symbol’:
wamr/core/iwasm/compilation/aot_llvm.c:3290:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
 3290 |     if (ret < 0 || ret + 1 > sizeof(sym->symbol)) {
      |                            ^

Fix:
```
wamr/core/iwasm/compilation/aot_llvm.c: In function ‘insert_native_symbol’:
wamr/core/iwasm/compilation/aot_llvm.c:3290:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
 3290 |     if (ret < 0 || ret + 1 > sizeof(sym->symbol)) {
      |                            ^
```

Signed-off-by: Huang Qi <[email protected]>
@no1wudi no1wudi force-pushed the main branch 2 times, most recently from 4321a18 to 2492383 Compare August 2, 2024 06:51
@wenyongh wenyongh requested a review from yamt August 2, 2024 13:25
@@ -3287,7 +3287,7 @@ insert_native_symbol(AOTCompContext *comp_ctx, const char *symbol, int32 idx)
memset(sym, 0, sizeof(AOTNativeSymbol));
bh_assert(strlen(symbol) <= sizeof(sym->symbol));
ret = snprintf(sym->symbol, sizeof(sym->symbol), "%s", symbol);
if (ret < 0 || ret + 1 > sizeof(sym->symbol)) {
if (ret < 0 || ret + 1 > (int)sizeof(sym->symbol)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

in general i prefer to cast to the larger type. (size_t)
but i guess it doesn't matter for this specific code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the size of sym->symbol is is only 48 byte for this case

@wenyongh wenyongh merged commit c3dd559 into bytecodealliance:main Aug 3, 2024
385 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.

3 participants