-
Notifications
You must be signed in to change notification settings - Fork 100
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
Compile flag fixes #114
Compile flag fixes #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,7 +195,7 @@ format_error_string(void) | |
if (!__rcutils_error_is_set(__rcutils_error_state)) { | ||
return; | ||
} | ||
size_t bytes_it_would_have_written = snprintf( | ||
size_t bytes_it_would_have_written = (size_t)snprintf( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's actually a few problems here. |
||
NULL, 0, | ||
__error_format_string, | ||
__rcutils_error_state->message, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ rcutils_format_string_limit( | |
va_list args2; | ||
va_copy(args2, args1); | ||
// first calculate the output string | ||
size_t bytes_to_be_written = rcutils_vsnprintf(NULL, 0, format_string, args1); | ||
size_t bytes_to_be_written = (size_t)rcutils_vsnprintf(NULL, 0, format_string, args1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like in error_handling.c, the return value of |
||
va_end(args1); | ||
// allocate space for the return string | ||
if (bytes_to_be_written + 1 > limit) { | ||
|
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.
Looking around a bit, I think the basic problem here is that taking the difference between two pointers should be represented by
ptrdiff_t
, notsize_t
(in theory, the difference can be negative: https://bytes.com/topic/c/answers/460624-subtracting-pointers-type-use-store-result). While changing to this, you'll probably also have to change the type ofidx
to match.