diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2015-11-26 01:29:36 +0000 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2015-11-27 12:58:36 +0000 |
commit | 24d546353be7cf64787c4e6690f0bb5cedf43f5f (patch) | |
tree | cc48de1ace9ac6db267453773b2f9f8a7e3496da /wiretap | |
parent | bec2fc09540ee3c45c6a2483a1cdbc1bb63fb934 (diff) |
pcapng: Fix ISO C forbids conversion [-Wpedantic]
pcapng.c:461:31: warning: ISO C forbids passing argument 3 of 'g_hash_table_insert' between function pointer and 'void *' [-Wpedantic]
pcapng.c:1404:32: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
pcapng.c:1918:32: warning: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic]
Change-Id: I535633098cc5d37442732dd92e8c9d3cda36631a
Reviewed-on: https://code.wireshark.org/review/12161
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/pcapng.c | 27 | ||||
-rw-r--r-- | wiretap/pcapng_module.h | 4 |
2 files changed, 19 insertions, 12 deletions
diff --git a/wiretap/pcapng.c b/wiretap/pcapng.c index 146af3ba0a..d70da3170c 100644 --- a/wiretap/pcapng.c +++ b/wiretap/pcapng.c @@ -345,10 +345,10 @@ register_pcapng_block_type_handler(guint block_type, block_reader reader, g_direct_equal, NULL, g_free); } - handler = (block_handler *)g_malloc(sizeof *handler); + handler = g_new(block_handler, 1); handler->reader = reader; handler->writer = writer; - (void)g_hash_table_insert(block_handlers, GUINT_TO_POINTER(block_type), + g_hash_table_insert(block_handlers, GUINT_TO_POINTER(block_type), handler); } @@ -386,6 +386,10 @@ register_pcapng_block_type_handler(guint block_type, block_reader reader, #define NUM_BT_INDICES 6 +typedef struct { + option_handler_fn hfunc; +} option_handler; + static GHashTable *option_handlers[NUM_BT_INDICES]; static gboolean @@ -439,9 +443,10 @@ get_block_type_index(guint block_type, guint *bt_index) void register_pcapng_option_handler(guint block_type, guint option_code, - option_handler handler) + option_handler_fn hfunc) { guint bt_index; + option_handler *handler; if (!get_block_type_index(block_type, &bt_index)) return; @@ -457,7 +462,9 @@ register_pcapng_option_handler(guint block_type, guint option_code, g_direct_equal, NULL, g_free); } - (void)g_hash_table_insert(option_handlers[bt_index], + handler = g_new(option_handler, 1); + handler->hfunc = hfunc; + g_hash_table_insert(option_handlers[bt_index], GUINT_TO_POINTER(option_code), handler); } #endif /* HAVE_PLUGINS */ @@ -1085,7 +1092,7 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta int pseudo_header_len; int fcslen; #ifdef HAVE_PLUGINS - option_handler handler; + option_handler *handler; #endif /* Don't try to allocate memory for a huge number of options, as @@ -1401,10 +1408,10 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta * Do we have a handler for this packet block option code? */ if (option_handlers[BT_INDEX_PBS] != NULL && - (handler = (option_handler)g_hash_table_lookup(option_handlers[BT_INDEX_PBS], + (handler = (option_handler *)g_hash_table_lookup(option_handlers[BT_INDEX_PBS], GUINT_TO_POINTER((guint)oh->option_code))) != NULL) { /* Yes - call the handler. */ - if (!handler(pn->byte_swapped, oh->option_length, + if (!handler->hfunc(pn->byte_swapped, oh->option_length, option_content, err, err_info)) /* XXX - free anything? */ return FALSE; @@ -1646,7 +1653,7 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t pcapng_option_header_t oh; guint8 *option_content; #ifdef HAVE_PLUGINS - option_handler handler; + option_handler *handler; #endif /* @@ -1915,10 +1922,10 @@ read_options: * Do we have a handler for this network resolution block option code? */ if (option_handlers[BT_INDEX_NRB] != NULL && - (handler = (option_handler)g_hash_table_lookup(option_handlers[BT_INDEX_NRB], + (handler = (option_handler *)g_hash_table_lookup(option_handlers[BT_INDEX_NRB], GUINT_TO_POINTER((guint)oh.option_code))) != NULL) { /* Yes - call the handler. */ - if (!handler(pn->byte_swapped, oh.option_length, + if (!handler->hfunc(pn->byte_swapped, oh.option_length, option_content, err, err_info)) { g_free(option_content); diff --git a/wiretap/pcapng_module.h b/wiretap/pcapng_module.h index aa7f9c40c9..7cd33e356b 100644 --- a/wiretap/pcapng_module.h +++ b/wiretap/pcapng_module.h @@ -58,7 +58,7 @@ void register_pcapng_block_type_handler(guint block_type, block_reader read, /* * Handler routine for pcap-ng option type. */ -typedef gboolean (*option_handler)(gboolean, guint, guint8 *, int *, gchar **); +typedef gboolean (*option_handler_fn)(gboolean, guint, guint8 *, int *, gchar **); /* * Register a handler for a pcap-ng option code for a particular block @@ -66,7 +66,7 @@ typedef gboolean (*option_handler)(gboolean, guint, guint8 *, int *, gchar **); */ WS_DLL_PUBLIC void register_pcapng_option_handler(guint block_type, guint option_code, - option_handler handle); + option_handler_fn hfunc); #endif /* __PCAP_MODULE_H__ */ |