-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
int (also literals as it seems) are signed by default #1575
Conversation
I'm in favor of the syntax change in this commit, ie of moving the variable definition from the function scope into the smaller scope of the for loop, with definition in the for loop itself. However, this conflicts with a bug in our RTAI debs for Buster that @dngarrett pointed out recently: The ideal way to fix this would be to fix that version of our RTAI packages so that we can use a modern (well, a less ancient) C standard. I think @andypugh or @NTULINUX prepared those RTAI debs, do you have input for us on this topic? |
@SebKuzminsky Together with the additional instance if a (signed int) << shifted I have also moved the initialization of i and j back up to the start of the function. @andypugh The effect of compiler-whatever options on RTAI is interesting, though. Not that I would understand this. Link-time optimization would be close to my heart since this reduces the memory footprint which I could imagine to reduce the jitter. |
The RTAI CFLAGS outside of LIBM (musl math libm math library) are:
For the math library, it is the above CFLAGS but with these appended:
https://en.wikipedia.org/wiki/Position-independent_code
|
@NTULINUX Thanks for that run-down. Do you have any idea about the source of the The ancient Wheezy RTAI does not have this problem, it builds LinuxCNC with |
My guess is: RTAI legacy (RTAI 4 releases) goes up to only the 3.16 kernel series, LinuxCNC's ancient RTAI kernel version is 3.4.55 I believe. RTAI currently only supports the 4.19 series, and the above commit, explicitly adding Cheers! |
This (too long) video https://www.youtube.com/watch?v=-G1FuEQqxVI just informed me that apparently the Linux kernel is about to upgrade to C99 . |
Where are we with this? Master/2.9 is currently not targeting any OS older than Buster, so we may have the opportunity to drop some legacy limitations. |
I think this is fine. I had undone my compiler-incompatibility as mentioned in #1575 (comment) . |
src/hal/drivers/hal_gm.c
Outdated
card *pCard = device->pCard; | ||
int i; | ||
hal_u32_t temp; | ||
|
||
unsigned int i; |
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.
Why do you change location of the declaration?
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 wish you had asked me a few months ago. Looking at it now I feel like i may have ordered the variables by their "localness", i.e. these are declared function-wide but used over different regions of the code and i I may have perceived as the most local.
[Steffen Möller]
I wish you had asked me a few months ago. Looking at it now I feel
like i may have ordered the variables by their "localness", i.e. these
are declared function-wide but used over different regions of the code
and i I may have perceived as the most local.
Is the idea that the compiler can not figure this out on its own? Tried
to consult docs/src/code/style-guide.adoc to see if it had something
useful on the topic, but alas.
…--
Happy hacking
Petter Reinholdtsen
|
I likely have edited it back in after having tried this within the for loop itself and forgot where I got it from. While I tend to think this is an improvement as it is, this is not meant to have an effect on the compiler but solely beween us devs. |
These patches eliminate an error found by cppcheck: src/hal/drivers/opto_ac5.c:432:13: error: Signed integer overflow for expression '1<<(31-i)'. [integerOverflow] mask=1<<(31-i);
Also reacted to @seb's comments in PR 1575.
Brought the declaration of local variables back into the original order as suggested in #1575 (comment) |
The updated pull request look good to me, even if it fail to clean up
some already existing white space issues (reported as red in 'git diff')
against marster in the lines it touces. The code in question compile
without any compiler warnings, and all tests succeed.
…--
Happy hacking
Petter Reinholdtsen
|
The change look good to me. The current failing build tests are due to a transient error on github, and not related to the patch. I guess a rebase and rebuild will show success. |
a matter of style "1u" also works when you want an unsigned literal value. |
These patches eliminate an error found by cppcheck:
src/hal/drivers/opto_ac5.c:432:13: error: Signed integer overflow for expression '1<<(31-i)'. [integerOverflow]
mask=1<<(31-i);
This is just a pilot PR to test my thought to have cppcheck integral to the continuous integration (#1574).
Many thanks!
Steffen