Change in libosmocore[master]: utils: add osmo_str_to_int() and osmo_str_to_int64()

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/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Sep 6 09:04:14 UTC 2021


pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/25345 )

Change subject: utils: add osmo_str_to_int() and osmo_str_to_int64()
......................................................................


Patch Set 1: Code-Review-1

(2 comments)

https://gerrit.osmocom.org/c/libosmocore/+/25345/1/src/utils.c 
File src/utils.c:

https://gerrit.osmocom.org/c/libosmocore/+/25345/1/src/utils.c@1419 
PS1, Line 1419: int osmo_str_to_int64(int64_t *result, const char *str, int base, int64_t min_val, int64_t max_val)
We probably want to have:
int _osmo_str_to_int64(int64_t *result, const char *str, int base, int64_t min_val, int64_t max_val);
#define osmo_str_to_int64(result, str, base) _osmo_str_to_int64(result, str, base, INT64_MIN, INT64_MAX)


https://gerrit.osmocom.org/c/libosmocore/+/25345/1/src/utils.c@1430 
PS1, Line 1430: 	if (val < INT64_MIN) {
This looks wrong. What if the string contains INT64_MIn or INT64_MAX? You'd return non-zero, which is wrong imho.
You should do this kind of tests later iirc.


BTW. How can a an int64_t variable hold a value smaller than INT64_MIN? Can you explain me?



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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4dac826aab00bc1780a5258b6b55d34ce7d50c60
Gerrit-Change-Number: 25345
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-Comment-Date: Mon, 06 Sep 2021 09:04:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210906/11de8c1c/attachment.htm>


More information about the gerrit-log mailing list