[PATCH] Avoid excessive function type casts with splay-trees
Jakub Jelinek
jakub@redhat.com
Fri Dec 15 10:51:00 GMT 2017
On Fri, Dec 15, 2017 at 10:44:54AM +0000, Bernd Edlinger wrote:
> when working on the -Wcast-function-type patch I noticed some rather
> ugly and non-portable function type casts that are necessary to accomplish
> some actually very simple tasks.
>
> Often functions taking pointer arguments are called with a different signature
> taking uintptr_t arguments, which is IMHO not really safe to do...
>
> The attached patch adds a context argument to the callback functions but
> keeps the existing interface as far as possible.
Just formatting nits, not full review:
> + return strcmp ((char*) k1, (char*) k2);
char * instead of char*, please.
> +void
> +splay_tree_delete_key_wrapper (splay_tree_key key, void *fn)
> +{
> + splay_tree_delete_key_fn delete_key = (splay_tree_delete_key_fn) (uintptr_t) fn;
Too long line, should be:
splay_tree_delete_key_fn delete_key
= (splay_tree_delete_key_fn) (uintptr_t) fn;
> +void
> +splay_tree_delete_value_wrapper (splay_tree_value value, void *fn)
> +{
> + splay_tree_delete_value_fn delete_value = (splay_tree_delete_value_fn) (uintptr_t) fn;
Ditto.
Jakub
More information about the Gcc-patches
mailing list