This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Avoid excessive function type casts with splay-trees
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 Dec 2017 11:51:17 +0100
- Subject: Re: [PATCH] Avoid excessive function type casts with splay-trees
- Authentication-results: sourceware.org; auth=none
- References: <DB6PR0701MB266437EB2B10745722CDB8B6E40B0@DB6PR0701MB2664.eurprd07.prod.outlook.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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