aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs/gprs_sndcp_dcomp.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_dcomp.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_dcomp.c')
-rw-r--r--src/gprs/gprs_sndcp_dcomp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gprs/gprs_sndcp_dcomp.c b/src/gprs/gprs_sndcp_dcomp.c
index 04ff491f3..00e40a7ef 100644
--- a/src/gprs/gprs_sndcp_dcomp.c
+++ b/src/gprs/gprs_sndcp_dcomp.c
@@ -83,7 +83,7 @@ int gprs_sndcp_dcomp_init(const void *ctx, struct gprs_sndcp_comp *comp_entity,
OSMO_ASSERT(comp_field);
if (comp_entity->compclass == SNDCP_XID_DATA_COMPRESSION
- && comp_entity->algo == V42BIS) {
+ && comp_entity->algo.dcomp == V42BIS) {
OSMO_ASSERT(comp_field->v42bis_params);
comp_entity->state =
v42bis_init(ctx, NULL, comp_field->v42bis_params->p0,
@@ -114,7 +114,7 @@ void gprs_sndcp_dcomp_term(struct gprs_sndcp_comp *comp_entity)
OSMO_ASSERT(comp_entity);
if (comp_entity->compclass == SNDCP_XID_DATA_COMPRESSION
- && comp_entity->algo == V42BIS) {
+ && comp_entity->algo.dcomp == V42BIS) {
if (comp_entity->state) {
v42bis_free((v42bis_state_t *) comp_entity->state);
comp_entity->state = NULL;
@@ -293,7 +293,7 @@ int gprs_sndcp_dcomp_expand(uint8_t *data, unsigned int len, uint8_t pcomp,
/* Note: Currently V42BIS is the only compression method we
* support, so the only allowed algorithm is V42BIS */
- OSMO_ASSERT(comp_entity->algo == V42BIS);
+ OSMO_ASSERT(comp_entity->algo.dcomp == V42BIS);
/* Find pcomp_index */
pcomp_index = gprs_sndcp_comp_get_idx(comp_entity, pcomp);
@@ -339,7 +339,7 @@ int gprs_sndcp_dcomp_compress(uint8_t *data, unsigned int len, uint8_t *pcomp,
/* Note: Currently V42BIS is the only compression method we
* support, so the only allowed algorithm is V42BIS */
- OSMO_ASSERT(comp_entity->algo == V42BIS);
+ OSMO_ASSERT(comp_entity->algo.dcomp == V42BIS);
/* Run compression algo */
rc = v42bis_compress_unitdata(&pcomp_index, data, len,