char *endp;
intmax_t ret;
- *errpp = NULL;
+ if (errpp != NULL)
+ *errpp = NULL;
if (minval > maxval || np == NULL) {
errno = EINVAL;
- *errpp = "invalid";
+ if (errpp != NULL)
+ *errpp = "invalid";
return (0);
}
errno = 0;
ret = strtoimax(np, &endp, 10);
if (endp == np || *endp != '\0') {
errno = EINVAL;
- *errpp = "invalid";
+ if (errpp != NULL)
+ *errpp = "invalid";
return (0);
}
if (ret < minval) {
errno = ERANGE;
- *errpp = "too small";
+ if (errpp != NULL)
+ *errpp = "too small";
return (0);
}
if (errno == ERANGE || ret > maxval) {
errno = ERANGE;
- *errpp = "too large";
+ if (errpp != NULL)
+ *errpp = "too large";
return (0);
}
return (ret);
char *endp;
uintmax_t ret;
- *errpp = NULL;
+ if (errpp != NULL)
+ *errpp = NULL;
if (minval > maxval || np == NULL) {
errno = EINVAL;
- *errpp = "invalid";
+ if (errpp != NULL)
+ *errpp = "invalid";
return (0);
}
errno = 0;
ret = strtoumax(np, &endp, 10);
if (endp == np || *endp != '\0') {
errno = EINVAL;
- *errpp = "invalid";
+ if (errpp != NULL)
+ *errpp = "invalid";
return (0);
}
if (ret < minval) {
errno = ERANGE;
- *errpp = "too small";
+ if (errpp != NULL)
+ *errpp = "too small";
return (0);
}
if (errno == ERANGE || ret > maxval) {
errno = ERANGE;
- *errpp = "too large";
+ if (errpp != NULL)
+ *errpp = "too large";
return (0);
}
return (ret);
ATF_REQUIRE_EQ(errno, EINVAL);
ATF_REQUIRE(errp != NULL);
ATF_REQUIRE_STREQ(errp, "invalid");
-
+ ATF_REQUIRE_EQ(strtoim("ba12", 0, 9, NULL), 0);
ATF_REQUIRE_EQ(strtouim(NULL, 0, 10, &errp), 0);
ATF_REQUIRE(errp != NULL);
ATF_REQUIRE_EQ(errno, EINVAL);
ATF_REQUIRE(errp != NULL);
ATF_REQUIRE_STREQ(errp, "invalid");
+ ATF_REQUIRE_EQ(strtouim("ba12", 0, 9, NULL), 0);
}
ATF_TC_BODY(write_ehlo, tc)