char *p;
errno = 0;
val = strtoul (line, &p, 10);
- if (!errno && val >= maxval)
+ if (!errno && p > line && val >= maxval)
{
ret = l;
maxval = val;
}
if (getline (&line, &linelen, f) > 0)
{
- char *p = line;
+ char *p = line, *end;
void *pl = gomp_places_list[gomp_places_list_len];
if (level == this_level)
gomp_affinity_init_place (pl);
{
unsigned long first, last;
errno = 0;
- first = strtoul (p, &p, 10);
- if (errno)
+ first = strtoul (p, &end, 10);
+ if (errno || end == p)
break;
+ p = end;
last = first;
if (*p == '-')
{
errno = 0;
- last = strtoul (p + 1, &p, 10);
- if (errno || last < first)
+ last = strtoul (p + 1, &end, 10);
+ if (errno || end == p + 1 || last < first)
break;
+ p = end;
}
for (; first <= last; first++)
if (!CPU_ISSET_S (first, gomp_cpuset_size, copy))
while (*q && *q != '\n' && gomp_places_list_len < count)
{
unsigned long nfirst, nlast;
+ char *end;
errno = 0;
- nfirst = strtoul (q, &q, 10);
- if (errno)
+ nfirst = strtoul (q, &end, 10);
+ if (errno || end == q)
break;
+ q = end;
nlast = nfirst;
if (*q == '-')
{
errno = 0;
- nlast = strtoul (q + 1, &q, 10);
- if (errno || nlast < nfirst)
+ nlast = strtoul (q + 1, &end, 10);
+ if (errno || end == q + 1 || nlast < nfirst)
break;
+ q = end;
}
for (; nfirst <= nlast; nfirst++)
{
bool seen = false;
errno = 0;
- first = strtoul (p, &p, 10);
- if (errno)
+ first = strtoul (p, &end, 10);
+ if (errno || end == p)
break;
+ p = end;
last = first;
if (*p == '-')
{
errno = 0;
- last = strtoul (p + 1, &p, 10);
- if (errno || last < first)
+ last = strtoul (p + 1, &end, 10);
+ if (errno || end == p + 1 || last < first)
break;
+ p = end;
}
for (; first <= last; first++)
{
errno = 0;
value = strtoul (env, &end, 10);
- if (errno)
+ if (errno || end == env)
goto invalid;
while (isspace ((unsigned char) *end))
errno = 0;
value = strtoul (env, &end, 10);
- if (errno || (long) value <= 0 - allow_zero)
+ if (errno || end == env || (long) value <= 0 - allow_zero)
goto invalid;
while (isspace ((unsigned char) *end))
unsigned long this_num, this_len = 1;
long this_stride = 1;
bool this_negate = (*env == '!');
+ char *end;
if (this_negate)
{
if (gomp_places_list)
}
errno = 0;
- this_num = strtoul (env, &env, 10);
- if (errno)
+ this_num = strtoul (env, &end, 10);
+ if (errno || end == env)
return false;
+ env = end;
while (isspace ((unsigned char) *env))
++env;
if (*env == ':')
while (isspace ((unsigned char) *env))
++env;
errno = 0;
- this_stride = strtol (env, &env, 10);
- if (errno)
+ this_stride = strtol (env, &end, 10);
+ if (errno || end == env)
return false;
+ env = end;
while (isspace ((unsigned char) *env))
++env;
}
++env;
if (*env == ':')
{
+ char *end;
++env;
while (isspace ((unsigned char) *env))
++env;
while (isspace ((unsigned char) *env))
++env;
errno = 0;
- stride = strtol (env, &env, 10);
- if (errno)
+ stride = strtol (env, &end, 10);
+ if (errno || end == env)
return false;
+ env = end;
while (isspace ((unsigned char) *env))
++env;
}
errno = 0;
count = strtoul (env, &end, 10);
- if (errno)
+ if (errno || end == env)
goto invalid;
env = end;
while (isspace ((unsigned char) *env))
errno = 0;
value = strtoul (env, &end, 10);
- if (errno)
+ if (errno || end == env)
goto invalid;
while (isspace ((unsigned char) *end))
errno = 0;
value = strtoull (env, &end, 10);
- if (errno)
+ if (errno || end == env)
goto invalid;
while (isspace ((unsigned char) *end))
errno = 0;
cpu_beg = strtoul (env, &end, 0);
- if (errno || cpu_beg >= 65536)
+ if (errno || end == env || cpu_beg >= 65536)
goto invalid;
cpu_end = cpu_beg;
cpu_stride = 1;
{
errno = 0;
cpu_end = strtoul (++env, &end, 0);
- if (errno || cpu_end >= 65536 || cpu_end < cpu_beg)
+ if (errno || end == env || cpu_end >= 65536 || cpu_end < cpu_beg)
goto invalid;
env = end;
/* The syntax is the same as for the -fopenacc-dim compilation option. */
const char *var_name = "GOMP_OPENACC_DIM";
const char *env_var = getenv (var_name);
+ const char *pos = env_var;
+ int i;
+
if (!env_var)
return;
- const char *pos = env_var;
- int i;
for (i = 0; *pos && i != GOMP_DIM_MAX; i++)
{
+ char *eptr;
+ long val;
+
if (i && *pos++ != ':')
break;
if (*pos == ':')
continue;
- const char *eptr;
errno = 0;
- long val = strtol (pos, (char **)&eptr, 10);
- if (errno || val < 0 || (unsigned)val != val)
+ val = strtol (pos, &eptr, 10);
+ if (errno || eptr != pos || val < 0 || (unsigned)val != val)
break;
goacc_default_dims[i] = (int)val;
- pos = eptr;
+ pos = (const char *) eptr;
}
}