aboutsummaryrefslogtreecommitdiffstats
path: root/src/sm-error.h
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-02-26 17:06:16 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-02-26 17:06:16 +0900
commit21560b8ca2f7cc803e0c288a9ec96aa68e9c19c6 (patch)
tree8a3efa1c7583e21c7cabc90fdbb4713c20ed9322 /src/sm-error.h
parent8ca504d9e1a94bf575b671d0492a2aff02725a2d (diff)
clean: Use function and remove duplicated code
Change-Id: If41193db78cb290d2d4a8bac9d164df502e7393a Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/sm-error.h')
-rw-r--r--src/sm-error.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/sm-error.h b/src/sm-error.h
index a963d47..bc60175 100644
--- a/src/sm-error.h
+++ b/src/sm-error.h
@@ -1,5 +1,11 @@
#ifndef SM_ERROR_H
#define SM_ERROR_H
+#include <glib.h>
+#define _GNU_SOURCE
+#define AFB_BINDING_VERSION 2
+#include <afb/afb-binding.h>
+#define IS_SEND_ERROR(...) is_send_error(__VA_ARGS__, __FUNCTION__)
+#define IS_SEND_ERROR_WITHOUT_RETURN(...) is_send_error_without_return(__VA_ARGS__, __FUNCTION__)
char* get_response_audiomanager_massage_error(int am_error_code)
{
@@ -31,7 +37,7 @@ char* get_response_audiomanager_massage_error(int am_error_code)
case 100:
return "desired event doesn't exist";
default:
- return "Audio Manager responsed unknown error number";
+ return "Audio Manager responsed unknown error number";
}
}
@@ -49,4 +55,19 @@ char* get_source_state_key(int am_source_state){
return "";
}
}
+
+void is_send_error_without_return(GError* result_of_send, const char* function){
+ if(result_of_send != NULL){
+ AFB_ERROR("Unable to call %s", function);
+ }
+}
+
+int is_send_error(GError* result_of_send, struct afb_req req, const char* function){
+ if(result_of_send != NULL)
+ {
+ afb_req_fail_f(req, "failed", "Unable to call %s", function);
+ return 0;
+ }
+ return -1;
+}
#endif