Change in openbsc[master]: nat: ctrl: use strtol instead of atoi as it has explicit error docume...

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

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Jul 12 16:41:02 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/9979


Change subject: nat: ctrl: use strtol instead of atoi as it has explicit error documentation
......................................................................

nat: ctrl: use strtol instead of atoi as it has explicit error documentation

In some cases id can be non-digit such as "err" for ERROR cmds generated
from parsing failures.

Change-Id: Ief0b203efbcf2be04253b5056840be94d58a9994
---
M openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
1 file changed, 3 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/79/9979/1

diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
index af110a2..e244827 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
@@ -85,8 +85,9 @@
 static struct bsc_cmd_list *bsc_get_pending(struct bsc_connection *bsc, char *id_str)
 {
 	struct bsc_cmd_list *cmd_entry;
-	int id = atoi(id_str);
-	if (id == 0)
+	char * endptr = NULL;
+	int id = (long int) strtol(id_str, &endptr, 10);
+	if (id_str[0] == '\0' || endptr[0] != '\0')
 		return NULL;
 
 	llist_for_each_entry(cmd_entry, &bsc->cmd_pending, list_entry) {

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

Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ief0b203efbcf2be04253b5056840be94d58a9994
Gerrit-Change-Number: 9979
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180712/eedd261e/attachment.htm>


More information about the gerrit-log mailing list