Ethereal-dev: Re: [Ethereal-dev] Q: Variables pointing to functions

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Olivier Biot" <ethereal@xxxxxxxxxx>
Date: Sat, 10 Jan 2004 15:12:09 +0100
Hi Joerg,

I'd propose a fix where you first define the storage class for the
function with const guint8 * argument and returning a gchar *:

typedef gchar * string_handler_func(const guint8 *);

Then you can declare the pointer-to-func as:

string_handler_func str_handler = NULL;

I will check in a fix based on this approach.

Regards,

Olivier
----- Original Message ----- 
From: "Joerg Mayer"

I wass getting the following warnings when compiling packet-ldp.c:
packet-ldp.c:591: warning: ISO C forbids assignment between function
pointer and `void *'
packet-ldp.c:595: warning: ISO C forbids assignment between function
pointer and `void *'
packet-ldp.c:669: warning: ISO C forbids assignment between function
pointer and `void *'
packet-ldp.c:673: warning: ISO C forbids assignment between function
pointer and `void *'
packet-ldp.c:856: warning: ISO C forbids assignment between function
pointer and `void *'
packet-ldp.c:860: warning: ISO C forbids assignment between function
pointer and `void *'

As I'm not familiar with variables pointing to functions, can someone
please check whether the following patch is OK?

Thanks
    Jörg


Index: packet-ldp.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/packet-ldp.c,v
retrieving revision 1.48
diff -p -u -r1.48 packet-ldp.c
--- packet-ldp.c 28 Dec 2003 12:43:38 -0000 1.48
+++ packet-ldp.c 10 Jan 2004 12:51:52 -0000
@@ -555,7 +555,7 @@ dissect_tlv_fec(tvbuff_t *tvb, guint off
  guint16 family, ix=1, ax;
  guint8 addr_size=0, *addr, implemented, prefix_len_octets,
prefix_len, host_len, vc_len;
  guint8  intparam_len;
- void *str_handler=NULL;
+ gchar* (*str_handler) (const guint8 *) = NULL;
  char *str;

  if (tree) {
@@ -836,7 +836,7 @@ dissect_tlv_address_list(tvbuff_t *tvb,
  proto_tree *ti = NULL, *val_tree = NULL;
  guint16 family, ix;
  guint8 addr_size, *addr;
- void *str_handler;
+ gchar* (*str_handler) (const guint8 *);
  char *str;

  if (tree) {
-- 
Joerg Mayer
<jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff
that
works. Some say that should read Microsoft instead of technology.

_______________________________________________
Ethereal-dev mailing list
Ethereal-dev@xxxxxxxxxxxx
http://www.ethereal.com/mailman/listinfo/ethereal-dev