diff options
author | Guy Harris <guy@alum.mit.edu> | 2000-11-13 05:11:16 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2000-11-13 05:11:16 +0000 |
commit | f9546764f0f61841505cf631f0d9386457190179 (patch) | |
tree | dd7257193e831067f68e46fabd4461b2f6a09a68 /packet-tr.c | |
parent | 5dd5670f42ae5baed1335994757d27851e49141f (diff) | |
download | wireshark-f9546764f0f61841505cf631f0d9386457190179.tar.gz wireshark-f9546764f0f61841505cf631f0d9386457190179.tar.bz2 wireshark-f9546764f0f61841505cf631f0d9386457190179.zip |
"It's pronounced 'volatile pointer to tvbuff_t' but it's spelled
'tvbuff_t *volatile'." Makes "Throat-Warbler Mangrove" vs.
"Luxury-Yacht" sound almost normal....
Type-qualified pointers to non-type-qualified objects are a barrel of
fun in C. The way you declare a volatile pointer named "bar" to a
*non-volatile* "foo" is
foo *volatile bar;
as opposed to a non-volatile pointer "bar" to a volatile "foo", which is
volatile foo *bar;
GCC's complaint about variables being clobbered by longjmp refers to the
fact that "longjmp()" isn't guaranteed to restore variables stored in
registers to the values they had at the time of the "longjmp()" (if
"setjmp()" stuffs the current register values in the "jmp_buf", and
"longjmp()" just reloads them rather than walking the stack to restore
all register values pushed onto the stack, the values at the time of the
"setjmp()" will be restored, clobbering any updates done after the
"setjmp()"); the workaround provided in ANSI C is to declare the
variables in question "volatile", which will keep them out of registers
(or any other place that "setjmp()"/"longjmp()" can't handle).
svn path=/trunk/; revision=2631
Diffstat (limited to 'packet-tr.c')
-rw-r--r-- | packet-tr.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/packet-tr.c b/packet-tr.c index 4c22637dde..f6451bd1a7 100644 --- a/packet-tr.c +++ b/packet-tr.c @@ -2,7 +2,7 @@ * Routines for Token-Ring packet disassembly * Gilbert Ramirez <gram@xiexie.org> * - * $Id: packet-tr.c,v 1.47 2000/10/17 11:05:23 gram Exp $ + * $Id: packet-tr.c,v 1.48 2000/11/13 05:11:16 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -307,11 +307,7 @@ dissect_tr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) volatile guint8 c1_nonsr; volatile guint8 c2_nonsr; volatile guint16 first2_sr; - - /* I make tr_tvb static because I need to set it before any TRY block. - * If tr_tvb were not static, the possibility exists that the value - * I give to tr_tvb would be clobbered. */ - static tvbuff_t *tr_tvb = NULL; + tvbuff_t *volatile tr_tvb; /* The trn_hdr struct, as separate variables */ guint8 trn_ac; /* access control field */ |