-
Notifications
You must be signed in to change notification settings - Fork 434
Commit
- Loading branch information
There are no files selected for viewing
8 comments
on commit e0f0819
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.
Can we not just use the code we had before the PR introducing the warning.
auto rc = strerror_r(errno, error_string, error_length);
if (rc) {
throw std::runtime_error("Failed to set SIGINT signal handler: (" + std::to_string(errno) + ") unable to retrieve error string");
}
I don't think any of our currently supported platforms requires the platform checking logic proposed in this patch.
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 don't think so because on some systems strerror_r
will return a string and leave the buffer unused (which in this case is error_string
) and in that case we have to do the strncpy
that @esteve added.
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.
Which of our platforms has which of the two (XSI-compliant vs. GNU-specific) behaviors?
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 don't know, but looking around on the internet it looks like Android might be different from Ubuntu (for example). Some things I found:
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.
Since we don't have a platform to test the proposed code I would choose to keep the code as simple as possible. Once we get to the point that we want to build on a platform which requires more we can update the code knowing that it will actually work. As your first link nicely shows: just adding the snippet without trying it on a real platform will very likely not work as expected.
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.
Apparently OSX requires the XSI version (albeit the ifdef logic doesn't seem to work):
http://ci.ros2.org/job/ci_osx/542
and Linux needs the GNU one, I'm going to keep this and apply @wjwwood's feedback and it should be ready for merging.
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.
OS X does use the XSI version. I just wrote a program to test it:
#include <string.h>
#include <stdio.h>
void check(int ret) { printf("XSI\n"); }
void check(char * ret) { printf("GNU\n"); }
int main() {
char buf[1024];
check(strerror_r(3, buf, 1024));
return 0;
}
Outputs:
% ./junk
XSI
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.
This isn't really setting the error message. Maybe something like
"Failed to get error string for errno: " + std::to_string(errno)
would be better?