diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-04-30 20:03:39 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-05-01 06:50:36 +0000 |
commit | b84972635117aa5cac7f8e6296d07ceb51bfe5e2 (patch) | |
tree | 89f3c0baff68f63dcadb737de9e4da3c2b97bdfc /asn1 | |
parent | 91515a008143901473e018033a76933abfec3c1f (diff) |
Fix some cases where we're shifting a signed 1 left.
Shift 1U instead, to make sure it's unsigned; the result of, for
example, the result of shifting a signed value left is undefined if the
value times 2^{shift count} doesn't fit in the *signed* type of the
shifted value. That means, in particular, that the result of shifting 1
left by {number of bits in an int - 1} is undefined. (In *practice*,
it'll probably be -2^32, with the bit you want set, but that's not
guaranteed, and GCC 5.1 seems not to like it.)
Make some other left-hand operands of <<, and some variables holding
results from shifts of that sort, unsigned, while we're at it.
Change-Id: Ie72a9d0d518f59b35948267d10c80735d162e8bb
Reviewed-on: https://code.wireshark.org/review/8264
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/ess/packet-ess-template.c | 2 | ||||
-rw-r--r-- | asn1/ranap/packet-ranap-template.c | 6 | ||||
-rw-r--r-- | asn1/rrc/rrc.cnf | 16 | ||||
-rw-r--r-- | asn1/sv/packet-sv-template.c | 42 |
4 files changed, 33 insertions, 33 deletions
diff --git a/asn1/ess/packet-ess-template.c b/asn1/ess/packet-ess-template.c index 23a6854c8f..b9c20eb7c1 100644 --- a/asn1/ess/packet-ess-template.c +++ b/asn1/ess/packet-ess-template.c @@ -126,7 +126,7 @@ ess_dissect_attribute_flags (tvbuff_t *tvb, asn1_ctx_t *actx) if ((strcmp (u->oid, object_identifier_id) == 0) && ((u->lacv / 8) < tvb_captured_length (tvb)) && - (value[u->lacv / 8] & (1 << (7 - (u->lacv % 8))))) + (value[u->lacv / 8] & (1U << (7 - (u->lacv % 8))))) { proto_tree_add_string_format (tree, hf_ess_Category_attribute, tvb, u->lacv / 8, 1, u->name, diff --git a/asn1/ranap/packet-ranap-template.c b/asn1/ranap/packet-ranap-template.c index e20cc7b967..446fd8374c 100644 --- a/asn1/ranap/packet-ranap-template.c +++ b/asn1/ranap/packet-ranap-template.c @@ -104,9 +104,9 @@ static gboolean glbl_dissect_container = FALSE; * * Only these two needed currently */ -#define IMSG (1<<16) -#define SOUT (2<<16) -#define SPECIAL (4<<16) +#define IMSG (1U<<16) +#define SOUT (2U<<16) +#define SPECIAL (4U<<16) int pdu_type = 0; /* 0 means wildcard */ diff --git a/asn1/rrc/rrc.cnf b/asn1/rrc/rrc.cnf index 35059a634b..bf164f486e 100644 --- a/asn1/rrc/rrc.cnf +++ b/asn1/rrc/rrc.cnf @@ -737,8 +737,8 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE /*Here we try to figure out which HS-DSCH channels are multiplexed*/ #.FN_BODY DL-TransportChannelType-r5 VAL_PTR = &type - gint *flowd_p; - gint *cur_val=NULL; + guint *flowd_p; + guint *cur_val=NULL; struct rrc_info *rrcinf; %(DEFAULT_BODY)s @@ -757,11 +757,11 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE if( (cur_val=(gint *)g_tree_lookup(hsdsch_muxed_flows, GUINT_TO_POINTER((guint)rrcinf->hrnti[actx->pinfo->fd->subnum]))) == NULL ){ flowd_p = (guint*)g_malloc0(sizeof(gint)); - *flowd_p = (1<<flowd); /*Set the bit to mark it as true*/ + *flowd_p = (1U<<flowd); /*Set the bit to mark it as true*/ g_tree_insert(hsdsch_muxed_flows, GUINT_TO_POINTER((guint)rrcinf->hrnti[actx->pinfo->fd->subnum]), flowd_p); }else{ - *cur_val = (1<<flowd) | *cur_val; + *cur_val = (1U<<flowd) | *cur_val; } } @@ -772,8 +772,8 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE /*Here we try to figure out which HS-DSCH channels are multiplexed*/ #.FN_BODY DL-TransportChannelType-r7 VAL_PTR = &type - gint *flowd_p; - gint *cur_val=NULL; + guint *flowd_p; + guint *cur_val=NULL; struct rrc_info *rrcinf; %(DEFAULT_BODY)s @@ -793,11 +793,11 @@ HNBName TYPE=FT_STRING DISPLAY=STR_UNICODE if( (cur_val=(gint *)g_tree_lookup(hsdsch_muxed_flows, GUINT_TO_POINTER((guint)rrcinf->hrnti[actx->pinfo->fd->subnum]))) == NULL ){ flowd_p = (guint*)g_malloc0(sizeof(gint)); - *flowd_p = (1<<flowd); /* Set the bit to mark it as true*/ + *flowd_p = (1U<<flowd); /* Set the bit to mark it as true*/ g_tree_insert(hsdsch_muxed_flows, GUINT_TO_POINTER((guint)rrcinf->hrnti[actx->pinfo->fd->subnum]), flowd_p); }else{ - *cur_val = (1<<flowd) | *cur_val; + *cur_val = (1U<<flowd) | *cur_val; } } diff --git a/asn1/sv/packet-sv-template.c b/asn1/sv/packet-sv-template.c index eb428b5020..3a13b50aef 100644 --- a/asn1/sv/packet-sv-template.c +++ b/asn1/sv/packet-sv-template.c @@ -40,29 +40,29 @@ #define PFNAME "sv" /* see IEC61850-8-1 8.2 */ -#define Q_VALIDITY_GOOD (0x0 << 0) -#define Q_VALIDITY_INVALID (0x1 << 0) -#define Q_VALIDITY_QUESTIONABLE (0x3 << 0) -#define Q_VALIDITY_MASK (0x3 << 0) - -#define Q_OVERFLOW (1 << 2) -#define Q_OUTOFRANGE (1 << 3) -#define Q_BADREFERENCE (1 << 4) -#define Q_OSCILLATORY (1 << 5) -#define Q_FAILURE (1 << 6) -#define Q_OLDDATA (1 << 7) -#define Q_INCONSISTENT (1 << 8) -#define Q_INACCURATE (1 << 9) - -#define Q_SOURCE_PROCESS (0 << 10) -#define Q_SOURCE_SUBSTITUTED (1 << 10) -#define Q_SOURCE_MASK (1 << 10) - -#define Q_TEST (1 << 11) -#define Q_OPERATORBLOCKED (1 << 12) +#define Q_VALIDITY_GOOD (0x0U << 0) +#define Q_VALIDITY_INVALID (0x1U << 0) +#define Q_VALIDITY_QUESTIONABLE (0x3U << 0) +#define Q_VALIDITY_MASK (0x3U << 0) + +#define Q_OVERFLOW (1U << 2) +#define Q_OUTOFRANGE (1U << 3) +#define Q_BADREFERENCE (1U << 4) +#define Q_OSCILLATORY (1U << 5) +#define Q_FAILURE (1U << 6) +#define Q_OLDDATA (1U << 7) +#define Q_INCONSISTENT (1U << 8) +#define Q_INACCURATE (1U << 9) + +#define Q_SOURCE_PROCESS (0U << 10) +#define Q_SOURCE_SUBSTITUTED (1U << 10) +#define Q_SOURCE_MASK (1U << 10) + +#define Q_TEST (1U << 11) +#define Q_OPERATORBLOCKED (1U << 12) /* see UCA Implementation Guideline for IEC 61850-9-2 */ -#define Q_DERIVED (1 << 13) +#define Q_DERIVED (1U << 13) void proto_register_sv(void); void proto_reg_handoff_sv(void); |