String: bstrtoul macro expanded to bstrtoul10 and 16

This commit is contained in:
Maria Matejka 2019-06-13 14:27:58 +02:00
parent 87c82334a7
commit 5c864e2cfa
3 changed files with 8 additions and 9 deletions

View file

@ -168,7 +168,7 @@ WHITE [ \t]
char *e; char *e;
errno = 0; errno = 0;
l = bstrtoul(yytext, &e, 10); l = bstrtoul10(yytext, &e);
if (e && (*e != ':') || (errno == ERANGE) || (l >> 32)) if (e && (*e != ':') || (errno == ERANGE) || (l >> 32))
cf_error("ASN out of range"); cf_error("ASN out of range");
@ -186,7 +186,7 @@ WHITE [ \t]
} }
errno = 0; errno = 0;
l = bstrtoul(e+1, &e, 10); l = bstrtoul10(e+1, &e);
if (e && *e || (errno == ERANGE) || (l >> len2)) if (e && *e || (errno == ERANGE) || (l >> len2))
cf_error("Number out of range"); cf_error("Number out of range");
cf_lval.i64 |= l; cf_lval.i64 |= l;
@ -213,13 +213,13 @@ WHITE [ \t]
} }
errno = 0; errno = 0;
l = bstrtoul(yytext+2, &e, 10); l = bstrtoul10(yytext+2, &e);
if (e && (*e != ':') || (errno == ERANGE) || (l >> len1)) if (e && (*e != ':') || (errno == ERANGE) || (l >> len1))
cf_error("ASN out of range"); cf_error("ASN out of range");
cf_lval.i64 |= ((u64) l) << len2; cf_lval.i64 |= ((u64) l) << len2;
errno = 0; errno = 0;
l = bstrtoul(e+1, &e, 10); l = bstrtoul10(e+1, &e);
if (e && *e || (errno == ERANGE) || (l >> len2)) if (e && *e || (errno == ERANGE) || (l >> len2))
cf_error("Number out of range"); cf_error("Number out of range");
cf_lval.i64 |= l; cf_lval.i64 |= l;
@ -241,7 +241,7 @@ WHITE [ \t]
cf_lval.i64 |= ((u64) ip4_to_u32(ip4)) << 16; cf_lval.i64 |= ((u64) ip4_to_u32(ip4)) << 16;
errno = 0; errno = 0;
l = bstrtoul(e, &e, 10); l = bstrtoul10(e, &e);
if (e && *e || (errno == ERANGE) || (l >> 16)) if (e && *e || (errno == ERANGE) || (l >> 16))
cf_error("Number out of range"); cf_error("Number out of range");
cf_lval.i64 |= l; cf_lval.i64 |= l;
@ -265,7 +265,7 @@ WHITE [ \t]
char *e; char *e;
unsigned long int l; unsigned long int l;
errno = 0; errno = 0;
l = bstrtoul(yytext+2, &e, 16); l = bstrtoul16(yytext+2, &e);
if (e && *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l) if (e && *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l)
cf_error("Number out of range"); cf_error("Number out of range");
cf_lval.i = l; cf_lval.i = l;
@ -276,7 +276,7 @@ WHITE [ \t]
char *e; char *e;
unsigned long int l; unsigned long int l;
errno = 0; errno = 0;
l = bstrtoul(yytext, &e, 10); l = bstrtoul10(yytext, &e);
if (e && *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l) if (e && *e || errno == ERANGE || (unsigned long int)(unsigned int) l != l)
cf_error("Number out of range"); cf_error("Number out of range");
cf_lval.i = l; cf_lval.i = l;

View file

@ -245,7 +245,7 @@ ip4_pton(const char *a, ip4_addr *o)
char *d, *c = strchr(a, '.'); char *d, *c = strchr(a, '.');
if (!c != !i) if (!c != !i)
return 0; return 0;
l = bstrtoul(a, &d, 10); l = bstrtoul10(a, &d);
if (((d != c) && *d) || (l > 255)) if (((d != c) && *d) || (l > 255))
return 0; return 0;
ia = (ia << 8) | l; ia = (ia << 8) | l;

View file

@ -24,7 +24,6 @@ int buffer_vprint(buffer *buf, const char *fmt, va_list args);
int buffer_print(buffer *buf, const char *fmt, ...); int buffer_print(buffer *buf, const char *fmt, ...);
void buffer_puts(buffer *buf, const char *str); void buffer_puts(buffer *buf, const char *str);
#define bstrtoul(str, end, base) bstrtoul##base(str, end)
u64 bstrtoul10(const char *str, char **end); u64 bstrtoul10(const char *str, char **end);
u64 bstrtoul16(const char *str, char **end); u64 bstrtoul16(const char *str, char **end);