Fix a bunch of compiler warnings & linking errors#63
Conversation
This resolves: * missing-prototypes: Make clear that some functions are never exported by declaring them as static. This also fixes linking errors on newer versions of GCC. * shadow: Do not shadow variables, this makes code a bit cleaner and easier to read. * unused-but-set-variable: Drop unused-but-set variables, no need to compute values we don't use (and this will be optimized out anyway). * Some spurious whitespace fixes
aacuevas
left a comment
There was a problem hiding this comment.
Thank you for the commit!
The gcc version we have been using (admittedly far from the latest) did not report these warnings, but they are indeed the better practices.
As you point out, all internal functions should be static, thanks for the catch. As a note, the header that defines which functions need to be exported by an onidriver are in onidriver.h.
Regarding the r variable, it's a leftover from a previous way to check the alignment, we do it in a bitwise way in the lines just below the ones you deleted, they can be removed safely.
I will fix some conflicts with another internal commit we just merged and merge this PR.
|
Thank you! :-) On the Syntalos side, one thing that makes integration a little bit difficult is that this project statically embeds an x86_64 version of As far as I can see, the sources for the library are actually available, and I already wrote a bit of Meson integration for easy (cross)building. If I were to do the work, would you accept a patch that builds everything on the FT600/liboni side from source, using Meson, with CI integration to create Windows/Linux binaries on GitHub? (using MSYS2 for the former, this would still allow you to just fetch binaries for other OpenEphys components instead of using the sources) |
This was built using Things going via |
Hi everyone!
While working on the Syntalos plugin, I found a bunch of issues due to its quite strict compiler flags, that would be nice to address upstream:
The first issue actually fixes a pretty annoying linker issue:
This is caused because the ft600 driver declares stuff like
oni_ft600_reset_ctxas inline, so when the compiler chooses not to inline a call site there is no external symbol to link against. I can workaround that by switching to C89 (GNU89) inlining, which does emit an out-of-line definition as well, but that kind of sucks. This project can easily use C11 or an even newer C standard.This patch fixes the linker issue as well by solving the missing-prototypes warning by declaring internal functions as static. That way, the compiler can make better optimization choices and the linker issue goes away as a bonus.
Long-term, it might make sense to gather all explicitly exported stuff in a header and set explicit visibility, but i wanted to keep the changes minimal for now.
On the
r = ctx->max_read_frame_size % align;change: It feels like the intent was to validate the result here, but that has not been done. This felt safe to remove, but if there is some validation that should be done instead, please let me know!