-
Notifications
You must be signed in to change notification settings - Fork 24
Refactor to address compiler warnings #38
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
52e736e
Fix compiler warnings: Unused functions
bdd 77df78c
Fix compiler warnings: Unused function params
bdd 847be6c
Fix compiler warnings: enum-int-mismatch
bdd 77410ad
Fix compiler warnings: enum-conversion
bdd 20270e5
Fix compiler warnings: blisp_flash_firmware
bdd cb89bdb
Fix compiler warnings: format string
bdd d60e004
Enable all compiler warnings
bdd ee10c51
Fix compiler warnings: Explicit cast where needed
bdd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: MIT | ||
#include <stdarg.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
|
||
#ifdef WIN32 | ||
# include <windows.h> | ||
#else | ||
# include <time.h> | ||
#endif | ||
|
||
#include "blisp_util.h" | ||
|
||
void blisp_dlog(const char* format, ...) | ||
{ | ||
fflush(stdout); | ||
va_list args; | ||
va_start(args, format); | ||
vfprintf(stderr, format, args); | ||
va_end(args); | ||
fputc('\n', stderr); | ||
} | ||
|
||
|
||
void sleep_ms(int milliseconds) { | ||
#ifdef WIN32 | ||
Sleep(milliseconds); | ||
#else | ||
struct timespec ts; | ||
ts.tv_sec = milliseconds / 1000; | ||
ts.tv_nsec = (milliseconds % 1000) * 1000000; | ||
nanosleep(&ts, NULL); | ||
#endif | ||
} | ||
|
||
uint32_t crc32_calculate(const void *data, size_t data_len) | ||
{ | ||
uint32_t crc = 0xffffffff; | ||
const unsigned char *d = (const unsigned char *)data; | ||
unsigned int tbl_idx; | ||
|
||
while (data_len--) { | ||
tbl_idx = (crc ^ *d) & 0xff; | ||
crc = (crc_table[tbl_idx] ^ (crc >> 8)) & 0xffffffff; | ||
d++; | ||
} | ||
return (crc & 0xffffffff) ^ 0xffffffff; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm guessing this isn't working with the build failures?
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.
it is working. there's a missing one. i'm working on sending something that'll address the build issue but MSVC gives a useful warning neither gcc nor clang gave.
blisp_send_command
receives auint16_t
type payload_size, but in various places what is passed to it isuint32_t
. I was reading the call sites and went down the rabbit hole of Bouffalo Lab docs.Let me update this real quick, retaining the warnings. They can be worked on later.
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.
Ahh makes sense. No pressure/rush was trying to help 😓
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.
Everything is green right now, but I think MSVC's warning highlights a possibly unintended but currently benign type down conversion issue.
From: https://github.com/pine64/blisp/actions/runs/16361436024/job/46229915025?pr=38#step:4:35
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.
So, for the first one,
float
touint32_t
, what is missing is an explicit conversion. I will add it as a separate commit. The other two, are about theuint16_t payload_size
parameter ofblisp_send_command
.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.
OK. I'm done :)
If you think it's OK to merge with the two warnings only MSVC raises, I'm OK too.
I can work on these warnings in the near future. I promise it won't take me 2 years to come back to it (check the age of this PR 😅).
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.
I'm also to blame for the age, no one was really monitoring PR's well and I forgot about it 😓
I think its good to go indeeed