From: Davin McCall Date: Mon, 19 Jun 2017 09:06:47 +0000 (+0100) Subject: load_service: remove another TODO. X-Git-Tag: v0.06~49 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c6583e84d1d2f9e05ea2a0f99603713322a06e45;p=oweals%2Fdinit.git load_service: remove another TODO. It's not worth writing a number parser just so we can error out if the user happens to specify a value of -0 (only >= 0 is allowed). --- diff --git a/src/load_service.cc b/src/load_service.cc index 8ebab76..b1f1227 100644 --- a/src/load_service.cc +++ b/src/load_service.cc @@ -278,9 +278,7 @@ static gid_t parse_gid_param(const std::string ¶m, const std::string &servic // is is probably safe to assume that valid values are positive. We'll also assume // that the value range fits with "unsigned long long" since it seems unlikely // that would ever not be the case. - // - // TODO perhaps write a number parser, since even the unsigned variants of the C/C++ - // functions accept a leading minus sign... + static_assert((uintmax_t)std::numeric_limits::max() <= (uintmax_t)std::numeric_limits::max(), "gid_t is too large"); unsigned long long v = std::stoull(param, &ind, 0); if (v > static_cast(std::numeric_limits::max()) || ind != param.length()) { throw service_description_exc(service_name, gid_err_msg);