]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
log/Log: cast parameter of syslog() from unsigned to int
authorKefu Chai <kchai@redhat.com>
Mon, 16 Nov 2020 07:18:33 +0000 (15:18 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 16 Nov 2020 07:38:26 +0000 (15:38 +0800)
silences warning like:

../src/log/Log.cc:325:34: warning: field precision should have type 'int', but argument has type 'std::basic_string_view::size_type' (aka 'unsigned long') [-Wformat]
    syslog(LOG_USER|LOG_INFO, "%.*s", s.size(), s.data());
                               ~~^~   ~~~~~~~~
1 warning generated.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/log/Log.cc

index 0af1db8b6c3789b5a4f3ea57e05c52af2e204648..6d2647f579fe6fa9b1a3f039ef85afe1d3d13b43 100644 (file)
@@ -322,7 +322,7 @@ void Log::_log_message(std::string_view s, bool crash)
       std::cerr << "problem writing to " << m_log_file << ": " << cpp_strerror(r) << std::endl;
   }
   if ((crash ? m_syslog_crash : m_syslog_log) >= 0) {
-    syslog(LOG_USER|LOG_INFO, "%.*s", s.size(), s.data());
+    syslog(LOG_USER|LOG_INFO, "%.*s", static_cast<int>(s.size()), s.data());
   }
 
   if ((crash ? m_stderr_crash : m_stderr_log) >= 0) {