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

compiler warnings after upgrading to release v0.6.0 #18

Closed
muehlke opened this issue Oct 12, 2023 · 3 comments
Closed

compiler warnings after upgrading to release v0.6.0 #18

muehlke opened this issue Oct 12, 2023 · 3 comments

Comments

@muehlke
Copy link

muehlke commented Oct 12, 2023

Hello @driftregion again,

after upgrading to the new release v0.6.0 and compiling with the flags -Wall and -Werror I get these two errors:

  1. [-Werror=int-to-pointer-cast]
 iso14229/iso14229.c:517:22: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
 517 |     *memoryAddress = (void *)tmp;

Regarding this error, does the tmp variable has to be of the type long long unsigned int? When I remove one long to make it long unsigned int, it compiles with no warnings (errors) - when using the -Werror flag warnings are made to errors. I would highly recommend to keep the standard of the library to compile with no warnings, no matter how "trivial".

  1. [-Werror=stringop-truncation]
armv7vet2hf-neon-poky-linux-gnueabi/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));

First, I appreciate changing to the more secure variant strncpy(). I could fix this warning by changing the line 239 of iso14229.c from:

strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name));

to

strncpy(ifr.ifr_name, if_name, sizeof(ifr.ifr_name) - 1);

Let me know what you think about these warnings and whether you think these changes are worth making.

@muehlke muehlke changed the title Compiler warnings after upgrading to release v0.6.0 compiler warnings after upgrading to release v0.6.0 Oct 12, 2023
@muehlke
Copy link
Author

muehlke commented Oct 25, 2023

You addressed the second warning ([-Werror=stringop-truncation]) in #20 with commit fb401496, while the first warning ([-Werror=int-to-pointer-cast]) unfortunately remained unsolved. Would it be fine to change tmp in line 483 in iso14229.c from a long long unsigned int to a long unsigned int? Or are you working on a 64 bit system?

@driftregion
Copy link
Owner

this is also fixed in #21

@muehlke
Copy link
Author

muehlke commented Dec 20, 2023

I see the change in line 181 from src/server.c, you changed it from long long unsigned int to uintptr_t

Thanks for addressing this issue! The project is growing, kudos for the hard work!

@muehlke muehlke closed this as completed Dec 20, 2023
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

No branches or pull requests

2 participants