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 conversions between char and int #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mortie
Copy link

@mortie mortie commented Apr 11, 2023

This patch tries to fix some issues related to casting between int and char in the completion code. On systems where char is signed, the code used to consider it an error if the user pressed a character outside of the 0:127 range; with this patch, chars are casted to unsigned char before being casted to int, so valid characters are represented as the integers 0:255 instead of -127:128. On systems where char is unsigned, the error check after calling completeLine would never trigger, since a negative int would get mapped into the 0:255 range due to the cast. With this patch, the return value from completeLine is checked before it's casted to char.

I noticed these issues due to a "comparison always false due to limited range of data type" warning when compiling for aarch64, where chars are unsigned. I don't know if there are other similar issues in the code, but I did a quick check by compiling with -Wconversion and looking at places where stuff is converted from or to 'char' and didn't find anything suspicious.

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.

1 participant