static void configDoConfigure(void);
static void parse_refreshpattern(RefreshPattern **);
static uint64_t parseTimeUnits(const char *unit, bool allowMsec);
-static void parseTimeLine(time_msec_t * tptr, const char *units, bool allowMsec, bool expectMoreArguments);
static void parse_u_short(unsigned short * var);
static void parse_string(char **);
static void default_all(void);
/* Parse a time specification from the config file. Store the
* result in 'tptr', after converting it to 'units' */
-static void
-parseTimeLine(time_msec_t * tptr, const char *units, bool allowMsec, bool expectMoreArguments = false)
+static time_msec_t
+parseTimeLine(const char *units, bool allowMsec, bool expectMoreArguments = false)
{
time_msec_t u = parseTimeUnits(units, allowMsec);
if (u == 0) {
self_destruct();
- return;
+ return 0;
}
- char *token = ConfigParser::NextToken();;
+ char *token = ConfigParser::NextToken();
if (!token) {
self_destruct();
- return;
+ return 0;
}
double d = xatof(token);
} else if (!expectMoreArguments) {
self_destruct();
- return;
+ return 0;
} else {
token = NULL; // show default units if dying below
} else
token = NULL; // show default units if dying below.
- *tptr = static_cast<time_msec_t>(m * d);
+ const auto result = static_cast<time_msec_t>(m * d);
- if (static_cast<double>(*tptr) * 2 != m * d * 2) {
+ if (static_cast<double>(result) * 2 != m * d * 2) {
debugs(3, DBG_CRITICAL, "FATAL: Invalid value '" <<
d << " " << (token ? token : units) << ": integer overflow (time_msec_t).");
self_destruct();
}
+ return result;
}
static uint64_t
void
parse_time_t(time_t * var)
{
- time_msec_t tval;
- parseTimeLine(&tval, T_SECOND_STR, false);
+ time_msec_t tval = parseTimeLine(T_SECOND_STR, false);
*var = static_cast<time_t>(tval/1000);
}
void
parse_time_msec(time_msec_t * var)
{
- parseTimeLine(var, T_SECOND_STR, true);
+ *var = parseTimeLine(T_SECOND_STR, true);
}
static void
static void
parse_UrlHelperTimeout(SquidConfig::UrlHelperTimeout *config)
{
- time_msec_t tval;
- parseTimeLine(&tval, T_SECOND_STR, false, true);
+ const auto tval = parseTimeLine(T_SECOND_STR, false, true);
Config.Timeout.urlRewrite = static_cast<time_t>(tval/1000);
char *key, *value;