Change in osmo-sgsn[master]: use enums consistently instead of falling back to int

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Stefan Sperling gerrit-no-reply at lists.osmocom.org
Mon Nov 12 14:26:59 UTC 2018


Stefan Sperling has posted comments on this change. ( https://gerrit.osmocom.org/11656 )

Change subject: use enums consistently instead of falling back to int
......................................................................


Patch Set 1:

(4 comments)

https://gerrit.osmocom.org/#/c/11656/1/src/gprs/gprs_sndcp_xid.c
File src/gprs/gprs_sndcp_xid.c:

https://gerrit.osmocom.org/#/c/11656/1/src/gprs/gprs_sndcp_xid.c@538
PS1, Line 538: 		return SNDCP_XID_INVALID_COMPRESSION;
> before, there is a comparison " != -1" replaced with " != SNDCP_XID_INVALID_COMPRESSION". […]
Good point. See https://gerrit.osmocom.org/c/osmo-sgsn/+/11730


https://gerrit.osmocom.org/#/c/11656/1/src/gprs/gprs_sndcp_xid.c@1299
PS1, Line 1299: 		return SNDCP_XID_INVALID_COMPRESSION;
> not sure whether this makes sense. Above and below, -EINVAL is returned or a length when successful.
Indeed, that change is wrong.


https://gerrit.osmocom.org/#/c/11656/1/src/gprs/gprs_sndcp_xid.c@1444
PS1, Line 1444: 		if (compclass != SNDCP_XID_INVALID_COMPRESSION) {
> It's a bit awkward to follow this logic, both before and after this patch. […]
Before this patch, algo was set to -EINVAL on error in gprs_sndcp_get_compression_class().
I believe this is what this condition is supposed to check for.
List elements with algo -EINVAL are skipped silently.
Elements with an invalid compression class result in an erorr.

In the new code, algo is set to INVALID_COMPRESSION instead of -EINVAL upon error.
Also, we now need to know the compression class before reading the algorithm,
because the algo is now stored in a union and we select union members based on
the compression class.
But overall, I believe the new code keeps the existing behaviour intact.

I will tweak this slightly in the next patch set to avoid nesting the
switch-statement inside an if-statement.


https://gerrit.osmocom.org/#/c/11656/1/src/gprs/gprs_sndcp_xid.c@1474
PS1, Line 1474: 	compclass = gprs_sndcp_get_compression_class(comp_field_dst);
> what is the relation between gprs_sndcp_get_compression_class() and the gprs_sndcp_comp. […]
I sort of see what you're getting at but I don't see how to make it any better without blowing up the size of this patch even further.



-- 
To view, visit https://gerrit.osmocom.org/11656
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I3771a5c59f4e6fee24083b3c914965baf192cbd7
Gerrit-Change-Number: 11656
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Comment-Date: Mon, 12 Nov 2018 14:26:59 +0000
Gerrit-HasComments: Yes
Gerrit-HasLabels: No
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181112/51e1e3d4/attachment.htm>


More information about the gerrit-log mailing list