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

unsigned expression < 0 is always false #24

Open
chriscamacho opened this issue Feb 13, 2020 · 2 comments
Open

unsigned expression < 0 is always false #24

chriscamacho opened this issue Feb 13, 2020 · 2 comments

Comments

@chriscamacho
Copy link

src/xml.c: In function 'xml_parser_error':
src/xml.c:318:24: error: comparison of unsigned expression < 0 is always false [-Werror=type-limits]
318 | #define max(X,Y) ((X) > (Y) ? (X) : (Y))
| ^
src/xml.c:319:21: note: in expansion of macro 'max'
319 | size_t character = max(0, min(parser->length, parser->position + offset));
|

@ooxi
Copy link
Owner

ooxi commented Feb 20, 2020

You are right, those calculations most likely have to be done using ssize_t instead of size_t. Would you like to propose a patch?

@chriscamacho
Copy link
Author

in my own project I just hacked the line to....
size_t character = min(parser->length, parser->position + offset);
but for all I know that might make things explode....

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