[PATCH spice-streaming-agent 2/6] Separate ERROR macro in a different utility header

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allows to reuse it.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 src/Makefile.am        |  1 +
 src/mjpeg-fallback.cpp |  7 +------
 src/utils.hpp          | 18 ++++++++++++++++++
 3 files changed, 20 insertions(+), 6 deletions(-)
 create mode 100644 src/utils.hpp

diff --git a/src/Makefile.am b/src/Makefile.am
index 3717b5c..ba3b1bf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -55,4 +55,5 @@ spice_streaming_agent_SOURCES = \
 	mjpeg-fallback.hpp \
 	jpeg.cpp \
 	jpeg.hpp \
+	utils.hpp \
 	$(NULL)
diff --git a/src/mjpeg-fallback.cpp b/src/mjpeg-fallback.cpp
index cf704c6..0f31834 100644
--- a/src/mjpeg-fallback.cpp
+++ b/src/mjpeg-fallback.cpp
@@ -6,6 +6,7 @@
 
 #include <config.h>
 #include "mjpeg-fallback.hpp"
+#include "utils.hpp"
 
 #include <cstring>
 #include <exception>
@@ -19,12 +20,6 @@
 
 using namespace spice::streaming_agent;
 
-#define ERROR(args) do { \
-    std::ostringstream _s; \
-    _s << args; \
-    throw std::runtime_error(_s.str()); \
-} while(0)
-
 static inline uint64_t get_time()
 {
     timespec now;
diff --git a/src/utils.hpp b/src/utils.hpp
new file mode 100644
index 0000000..1e43eff
--- /dev/null
+++ b/src/utils.hpp
@@ -0,0 +1,18 @@
+/* Miscellaneous utilities
+ *
+ * \copyright
+ * Copyright 2018 Red Hat Inc. All rights reserved.
+ */
+#ifndef SPICE_STREAMING_AGENT_UTILS_HPP
+#define SPICE_STREAMING_AGENT_UTILS_HPP
+
+#include <stdexcept>
+#include <sstream>
+
+#define ERROR(args) do { \
+    std::ostringstream _s; \
+    _s << args; \
+    throw std::runtime_error(_s.str()); \
+} while(0)
+
+#endif // SPICE_STREAMING_AGENT_UTILS_HPP
-- 
2.14.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]