summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/local_sighandler.cc
diff options
context:
space:
mode:
authorBrennan Ashton <bashton@brennanashton.com>2019-10-29 23:09:43 -0700
committerMarcus Müller <mmueller@gnuradio.org>2019-11-01 14:44:45 +0100
commita75f0c40fe0912535fe102792f27c13d01df8e3e (patch)
treed045ac2056eeb94aa2cf4f2502b370057684ce0c /gnuradio-runtime/lib/local_sighandler.cc
parentb1c588d78571c58b7e9953f4b841f8546ff9da06 (diff)
runtime: Purge snprintf
We are writting cpp for these operations we should be using std:string and boost:format. This also cleans up some compiler warnings about possible string truncation. Signed-off-by: Brennan Ashton <bashton@brennanashton.com> Also, removing the `HAVE_SNPRINT` check around the now snprintf-free handling Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Diffstat (limited to 'gnuradio-runtime/lib/local_sighandler.cc')
-rw-r--r--gnuradio-runtime/lib/local_sighandler.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/gnuradio-runtime/lib/local_sighandler.cc b/gnuradio-runtime/lib/local_sighandler.cc
index ffeaa9068b..7f96b2460d 100644
--- a/gnuradio-runtime/lib/local_sighandler.cc
+++ b/gnuradio-runtime/lib/local_sighandler.cc
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <string.h>
#include <stdexcept>
+#include <boost/format.hpp>
namespace gr {
@@ -70,7 +71,7 @@ void local_sighandler::throw_signal(int signum) { throw signal(signum); }
std::string signal::name() const
{
- char tmp[128];
+ std::string tmp;
switch (signum()) {
#ifdef SIGHUP
@@ -167,18 +168,14 @@ std::string signal::name() const
SIGNAME(SIGSYS);
#endif
default:
-#if defined(HAVE_SNPRINTF)
#if defined(SIGRTMIN) && defined(SIGRTMAX)
if (signum() >= SIGRTMIN && signum() <= SIGRTMAX) {
- snprintf(tmp, sizeof(tmp), "SIGRTMIN + %d", signum());
+ tmp = str(boost::format("SIGRTMIN + %d") % signum());
return tmp;
}
#endif
- snprintf(tmp, sizeof(tmp), "SIGNAL %d", signum());
+ tmp = str(boost::format("SIGNAL %d") % signum());
return tmp;
-#else
- return "Unknown signal";
-#endif
}
}