From 3e33c17d5d02b65ebfcf86d23219b5cb9cb3a617 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Wed, 7 Aug 2019 21:53:16 +1000 Subject: [PATCH] Avoid signed-unsigned comparison warning. --- src/proc-service.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/proc-service.cc b/src/proc-service.cc index 150f34d..9bdc2b3 100644 --- a/src/proc-service.cc +++ b/src/proc-service.cc @@ -1,4 +1,5 @@ #include +#include #include #include @@ -467,6 +468,12 @@ void scripted_service::exec_failed(run_proc_err errcode) noexcept } } +// Return a value as an unsigned-type value. +template typename std::make_unsigned::type make_unsigned_val(T val) +{ + return static_cast::type>(val); +} + bgproc_service::pid_result_t bgproc_service::read_pid_file(bp_sys::exit_status *exit_status) noexcept { @@ -492,7 +499,7 @@ bgproc_service::read_pid_file(bp_sys::exit_status *exit_status) noexcept bool valid_pid = false; try { unsigned long long v = std::stoull(pidbuf, nullptr, 0); - if (v <= std::numeric_limits::max()) { + if (v <= make_unsigned_val(std::numeric_limits::max())) { pid = (pid_t) v; valid_pid = true; } -- 2.25.1