aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs/gprs_sndcp.c
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-11-07 16:33:39 +0100
committerStefan Sperling <ssperling@sysmocom.de>2018-11-15 15:57:59 +0100
commitc5721545c6cd69effcef612a14c01aa4be89adde (patch)
tree97fd63dfe4a622a5a4385517ebbef68ca6a190bb /src/gprs/gprs_sndcp.c
parent60509688527efdf2a90b2d4241034a9775898940 (diff)
use enums consistently instead of falling back to int
The two existing enums defined in gprs_sndcp_xid.h, for protocol and data compression algorithm numbers respectively, were assigned to 'int' variables when their values were copied to other structures. This prevented the compiler from checking the enum value coverage during switch statements and also tripped up Coverity scans looking for enum value mismatch problems. So instead of copying enums to ints, make use of the enums throughout. Structures which can contain values from both enums now use a union of both, forcing us to be very explicit about which set of values we are dealing with. Change-Id: I3771a5c59f4e6fee24083b3c914965baf192cbd7 Depends: If6f3598cd6da4643ff2214e21c0d21f6eff0eb67 Depends: I8444c1ed052707c76a979fb06cb018ac678defa7 Related: CID#149102
Diffstat (limited to 'src/gprs/gprs_sndcp.c')
-rw-r--r--src/gprs/gprs_sndcp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gprs/gprs_sndcp.c b/src/gprs/gprs_sndcp.c
index 52eeb75..f0239cb 100644
--- a/src/gprs/gprs_sndcp.c
+++ b/src/gprs/gprs_sndcp.c
@@ -934,7 +934,7 @@ static int gprs_llc_gen_sndcp_xid(uint8_t *bytes, int bytes_len, uint8_t nsapi)
rfc1144_params.s01 = sgsn->cfg.pcomp_rfc1144.s01;
rfc1144_comp_field.p = 1;
rfc1144_comp_field.entity = entity;
- rfc1144_comp_field.algo = RFC_1144;
+ rfc1144_comp_field.algo.pcomp = RFC_1144;
rfc1144_comp_field.comp[RFC1144_PCOMP1] = 1;
rfc1144_comp_field.comp[RFC1144_PCOMP2] = 2;
rfc1144_comp_field.comp_len = RFC1144_PCOMP_NUM;
@@ -952,7 +952,7 @@ static int gprs_llc_gen_sndcp_xid(uint8_t *bytes, int bytes_len, uint8_t nsapi)
v42bis_params.p2 = sgsn->cfg.dcomp_v42bis.p2;
v42bis_comp_field.p = 1;
v42bis_comp_field.entity = entity;
- v42bis_comp_field.algo = V42BIS;
+ v42bis_comp_field.algo.dcomp = V42BIS;
v42bis_comp_field.comp[V42BIS_DCOMP1] = 1;
v42bis_comp_field.comp_len = V42BIS_DCOMP_NUM;
v42bis_comp_field.v42bis_params = &v42bis_params;
@@ -1021,7 +1021,7 @@ static int handle_pcomp_entities(struct gprs_sndcp_comp_field *comp_field,
comp_field->p = 0;
/* Process proposed parameters */
- switch (comp_field->algo) {
+ switch (comp_field->algo.pcomp) {
case RFC_1144:
if (sgsn->cfg.pcomp_rfc1144.passive
&& comp_field->rfc1144_params->nsapi_len > 0) {
@@ -1068,7 +1068,7 @@ static int handle_dcomp_entities(struct gprs_sndcp_comp_field *comp_field,
comp_field->p = 0;
/* Process proposed parameters */
- switch (comp_field->algo) {
+ switch (comp_field->algo.dcomp) {
case V42BIS:
if (sgsn->cfg.dcomp_v42bis.passive &&
comp_field->v42bis_params->nsapi_len > 0) {