-
-
Notifications
You must be signed in to change notification settings - Fork 902
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 gcc warings - alternative to #2061 #2068
Conversation
../../../../ext/nokogiri/xml_document.c: In function ‘dealloc’: ../../../../ext/nokogiri/xml_document.c:58:25: warning: passing argument 2 of ‘rb_st_foreach’ from incompatible pointer type [-Wincompatible-pointer-types] 58 | st_foreach(node_hash, dealloc_node_i, (st_data_t)doc); | ^~~~~~~~~~~~~~ | | | int (*)(xmlNode *, xmlNode *, xmlDoc *) {aka int (*)(struct _xmlNode *, struct _xmlNode *, struct _xmlDoc *)}
Code Climate has analyzed commit 6c0af79 and detected 0 issues on this pull request. View more on Code Climate. |
I'm always cautious with casting function pointers. It disables all type checks and the compiler isn't aware about type casts for the values passed to and from the callback. @flavorjones Do you agree with me? |
✅ Build nokogiri 1.0.633 completed (commit c499f62dfb by @larskanis) |
@larskanis It builds successfully on Ruby build with Visual C++ and all tests pass (re-compiled my Ruby installation). Command Line Log from Compilation and Run of Test Suite
|
../../../../ext/nokogiri/xml_io.c: In function ‘io_read_callback’: ../../../../ext/nokogiri/xml_io.c:20:22: warning: passing argument 1 of ‘rb_rescue’ from incompatible pointer type [-Wincompatible-pointer-types] 20 | string = rb_rescue(read_check, (VALUE)args, read_failed, 0); | ^~~~~~~~~~ | | | VALUE (*)(VALUE *) {aka long unsigned int (*)(long unsigned int *)} and ../../../../ext/nokogiri/xml_io.c:20:47: warning: passing argument 3 of ‘rb_rescue’ from incompatible pointer type [-Wincompatible-pointer-types] 20 | string = rb_rescue(read_check, (VALUE)args, read_failed, 0); | ^~~~~~~~~~~ | | | VALUE (*)(void) {aka long unsigned int (*)(void)}
0026e33
to
6c0af79
Compare
✅ Build nokogiri 1.0.634 completed (commit bcecb2f760 by @larskanis) |
I like this approach - will merge shortly. |
What problem is this PR intended to solve?
GCC raises warnings for the function pointer mismatches and Visual-C raises errors in #2061 . Both should be fixed by this patch. In contrast to #2061 this patch ensures type safety for the single values to be passed to the callback.
Have you included adequate test coverage?
Visual-C is not tested.
Does this change affect the C or the Java implementations?
Only C.