-
Notifications
You must be signed in to change notification settings - Fork 64
Conversation
Fix the number of clang compiler errors which are all of the same type: passing 'int32_t *' (aka 'int *') to parameter of type 'uint32_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign] Signed-off-by: Sakari Poussa <[email protected]>
@jprestwo PTAL and test that it does not effect the functionality. I did not have any code yet which I can test this with (so did no testing). |
@@ -65,7 +65,7 @@ void zjs_add_event_listener(jerry_value_t obj, const char* event, jerry_value_t | |||
event_obj = jerry_create_object(); | |||
} | |||
|
|||
int32_t callback_id = -1; | |||
uint32_t callback_id = 0; |
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 going to work. A callback ID of 0 is valid. -1 is invalid/error return code. All the callbacks are stored in a static array so unless we void out the 0th element (always) the only option is to treat -1 as the error return. That or make 0xFFFFFFFF the error return code, that way its still a uint32_t and we can just check for UINT32_MAX for example. So I am not sure of the best way to go from here, what/where exactly is the warning?
@jprestwo, the problem must be that right after these we're doing zjs_obj_get_uint32(..., &callback_id) into an in32_t, which is sketchy. |
Ya that must be it. The part that scares me is initializing callback_id to 0 instead of -1. The only solutions I can think of are checking for an error from zjs_obj_get_uint32(), changing callback's to have zero be invalid, or initializing callback_id to a very big number (which would also mean "invalid"). Looking at the actual implementation of zjs_obj_get_uint32(), we are just casting a double to a uint32_t anyways, which is just as bad as anywhere else. We could add a new API: zjs_obj_get_int32() which just does the same thing but cast to an int32_t instead. What about that? |
I wonder if it would make any sense to install a permanent "null" callback at id 0. Then 0 could be invalid, and if it ever gets called we could have a print() statement that would let us know. I think the get_int32 function should be okay too. I haven't looked in detail but I'm not sure we would actually create events with a callback_id of -1 or would we have aborted the attempt to create them in that case? |
@jprestwo do you want to try to rework this patch and see if it still removes the errors for Sakari before we merge it? |
It looks like we're nearing success on the alternate solution PR #206, so I'm closing this one. |
Fix the number of clang compiler errors which are all of the same type:
passing 'int32_t *' (aka 'int *') to parameter
of type 'uint32_t *' (aka 'unsigned int *') converts between pointers to
integer types with different sign [-Wpointer-sign]
Signed-off-by: Sakari Poussa [email protected]