diff options
Diffstat (limited to 'src/gsm/gsm23236.c')
-rw-r--r-- | src/gsm/gsm23236.c | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/gsm/gsm23236.c b/src/gsm/gsm23236.c index 01d0eb36..a80ecf46 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; } @@ -505,7 +487,7 @@ static int osmo_nri_parse_range(struct osmo_nri_range *nri_range, const char *fi int osmo_nri_ranges_vty_add(const char **message, struct osmo_nri_range *added_range, struct osmo_nri_ranges *nri_ranges, int argc, const char **argv, uint8_t nri_bitlen) { - struct osmo_nri_range add_range; + struct osmo_nri_range add_range = {}; if (osmo_nri_parse_range(&add_range, argv[0], argc > 1 ? argv[1] : NULL)) { *message = "Error: cannot parse NRI range"; return -1; @@ -541,7 +523,7 @@ int osmo_nri_ranges_vty_add(const char **message, struct osmo_nri_range *added_r int osmo_nri_ranges_vty_del(const char **message, struct osmo_nri_range *removed_range, struct osmo_nri_ranges *nri_ranges, int argc, const char **argv) { - struct osmo_nri_range del_range; + struct osmo_nri_range del_range = {}; if (osmo_nri_parse_range(&del_range, argv[0], argc > 1 ? argv[1] : NULL)) { *message = "Error: cannot parse NRI range"; return -1; |