diff options
author | Guy Harris <guy@alum.mit.edu> | 2007-04-30 08:33:44 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2007-04-30 08:33:44 +0000 |
commit | 3485b6810a8b5827eb6012e2b3881f9f8251cb8c (patch) | |
tree | db827c73074b7eae0e40133651a1a1891320f045 /epan/dissectors | |
parent | 2f88e4ca818072353adcebf06fa90e1a924d0979 (diff) |
Thou shalt not squelch compiler complaints about an assignment
discarding a qualifier by explicitly casting away the qualifier;
constness should persist, so that attempts to, for example, modify
something you got with tvb_get_ptr() get complained about (as we don't,
and won't, guarantee that you will get correct behavior if you do that).
Just make the pointer to which a const pointer is being assigned const
itself.
Yet *AGAIN* work around GArray's brokenness of having its data pointer
be a guint8 * rather than a void *.
svn path=/trunk/; revision=21623
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/packet-rmt-lct.c | 25 | ||||
-rw-r--r-- | epan/dissectors/packet-rmt-lct.h | 2 |
2 files changed, 23 insertions, 4 deletions
diff --git a/epan/dissectors/packet-rmt-lct.c b/epan/dissectors/packet-rmt-lct.c index fc57c7c062..8c1ff9c02e 100644 --- a/epan/dissectors/packet-rmt-lct.c +++ b/epan/dissectors/packet-rmt-lct.c @@ -407,7 +407,7 @@ void lct_dissector(struct _lct_ptr l, struct _fec_ptr f, tvbuff_t *tvb, proto_tr break; } - l.lct->toi_extended = (guint8*) tvb_get_ptr(tvb, *offset, l.lct->toi_size); + l.lct->toi_extended = tvb_get_ptr(tvb, *offset, l.lct->toi_size); if (tree) { @@ -461,8 +461,27 @@ void lct_dissector(struct _lct_ptr l, struct _fec_ptr f, tvbuff_t *tvb, proto_tr lct_ext_tree = NULL; /* Add the extensions to the subtree */ - for (i = 0; i < l.lct->ext->len; i++) - lct_ext_decode(&g_array_index(l.lct->ext, struct _ext, i), l.prefs, tvb, lct_ext_tree, l.ett->ext_ext, f); + for (i = 0; i < l.lct->ext->len; i++) { + /* + * The data member of a GArray isn't a void *, as + * it should be; it's a guint8 *, so GCC will + * warn about attempts to cast it to the type of + * an array member if -Wcast-align is specified. + * + * The code in GLib that allocates the data + * presumably arranges that it's aligned + * strictly enough for any data type (as that's + * how most memory allocators work), so that warning + * is bogus. + * + * We work around this by not using g_array_index(), + * but doing the indexing ourselves, and casting + * to the data pointer to void * first. + */ + struct _ext *ext_array = (void *)l.lct->ext->data; + + lct_ext_decode(&ext_array[i], l.prefs, tvb, lct_ext_tree, l.ett->ext_ext, f); + } } } diff --git a/epan/dissectors/packet-rmt-lct.h b/epan/dissectors/packet-rmt-lct.h index d0dfa5f9bd..5b6d02053a 100644 --- a/epan/dissectors/packet-rmt-lct.h +++ b/epan/dissectors/packet-rmt-lct.h @@ -51,7 +51,7 @@ struct _lct guint8 *cci; guint64 tsi; guint64 toi; - guint8 *toi_extended; + const guint8 *toi_extended; nstime_t sct; nstime_t ert; GArray *ext; |