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/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has posted comments on this change. ( https://gerrit.osmocom.org/12524 )
Change subject: gsm23003: add osmo_imei_str_valid()
......................................................................
Patch Set 3:
(2 comments)
https://gerrit.osmocom.org/#/c/12524/3/src/gsm/gsm23003.c
File src/gsm/gsm23003.c:
https://gerrit.osmocom.org/#/c/12524/3/src/gsm/gsm23003.c@83
PS3, Line 83: bool
I think it may be interesting to the caller *why* it failed validation. So a simple bool value may be too simple. Maybe return negative error codes and 0 on success? Then the negative error codes could have an enum or #defines differentiating the cause.
https://gerrit.osmocom.org/#/c/12524/3/src/gsm/gsm23003.c@93
PS3, Line 93: /* Verify Luhn algorithm (see Wikipedia)
: * digit id (i) | 00 01 02 03 04 05 06 07 08 09 10 11 12 13 CHK
: * double | x x x x x x x
: * do not double | x x x x x x x
: */
:
: /* Double every second digit and add it to sum */
: for (i = 1; i < 14; i += 2) {
: int check = 2 * (imei[i] - '0');
: if (check > 9)
: check -= 9;
: sum += check;
: }
the IMEI checksumming function should definitely be a separate function, as it may be useful in other purposes.
The osmo_imei_str_valid could then simply call that checksum-generation function and do the compare.
--
To view, visit https://gerrit.osmocom.org/12524
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id2d2a3a93b033bafc74c62e15297034bf4aafe61
Gerrit-Change-Number: 12524
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Comment-Date: Mon, 14 Jan 2019 12:52:12 +0000
Gerrit-HasComments: Yes
Gerrit-HasLabels: No
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190114/5f423f0b/attachment.htm>