aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm/gsm23236.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gsm/gsm23236.c')
-rw-r--r--src/gsm/gsm23236.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/gsm/gsm23236.c b/src/gsm/gsm23236.c
index 01d0eb36..4a83ec82 100644
--- a/src/gsm/gsm23236.c
+++ b/src/gsm/gsm23236.c
@@ -17,10 +17,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
*/
#include <errno.h>
@@ -436,27 +432,13 @@ char *osmo_nri_ranges_to_str_c(void *ctx, const struct osmo_nri_ranges *nri_rang
*/
static int osmo_nri_parse(int16_t *dst, const char *str)
{
- char *endp;
- int64_t val;
+ int val;
int base = 10;
-
- if (osmo_str_startswith(str, "0x")) {
- str += 2;
+ if (osmo_str_startswith(str, "0x"))
base = 16;
- }
-
- if (!str || !str[0])
+ if (osmo_str_to_int(&val, str, base, 0, INT16_MAX))
return -1;
-
- errno = 0;
- val = strtoull(str, &endp, base);
- if (errno || *endp != '\0')
- return -1;
-
- if (val < 0 || val > INT16_MAX)
- return -1;
-
- *dst = val;
+ *dst = (int16_t)val;
return 0;
}