aboutsummaryrefslogtreecommitdiffstats
path: root/binding/afm-nfc-binding.c
diff options
context:
space:
mode:
authorRaquel Medina <raquel.medina@konsulko.com>2018-11-29 13:21:49 +0200
committerRaquel Medina <raquel.medina@konsulko.com>2018-11-30 01:43:45 +0200
commit807f399fb2923fbbdf516628a28215ddcdb9185e (patch)
tree3e91add664fa46ae28c725670e5c967f9cba7368 /binding/afm-nfc-binding.c
parentb7cae49a6d1b4c5dba12647e2b30e635b8993a92 (diff)
nfc: binding: fix formatting.guppy_6.99.2guppy/6.99.26.99.2
This commit includes the following changes resulting from code review of commit b7cae49a6d1b4c5dba12647e2b30e635b8993a92, and requested to be on a separate commit: - fixes indentation on several lines - substitutes malloc+return error for g_malloc0 Change-Id: I8591868b759a454be2ee2bfc21c88e9563fa2535 Signed-off-by: Raquel Medina <raquel.medina@konsulko.com>
Diffstat (limited to 'binding/afm-nfc-binding.c')
-rw-r--r--binding/afm-nfc-binding.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/binding/afm-nfc-binding.c b/binding/afm-nfc-binding.c
index 1037227..eb667de 100644
--- a/binding/afm-nfc-binding.c
+++ b/binding/afm-nfc-binding.c
@@ -55,7 +55,6 @@ static void __attribute__((unused)) dbg_dump_tag_records(neardal_tag *tag)
return;
}
-
static void __attribute__((unused)) dbg_dump_record_content(neardal_record record)
{
#define DBG_RECORD(__x) if (record.__x) \
@@ -108,7 +107,7 @@ static void record_found(const char *tag_name, void *ptr)
"%s tag, record %s= %s", tag_name, s, str);
json_object_object_add(jdict, s,
- json_object_new_string(str + 1));
+ json_object_new_string(str + 1));
g_free(str);
}
@@ -251,9 +250,7 @@ static int init(afb_api_t api)
pthread_t thread_id;
int ret;
- data = malloc(sizeof(nfc_binding_data));
- if (!data)
- return -ENOMEM;
+ data = g_malloc0(sizeof(nfc_binding_data));
presence_event = afb_api_make_event(api, "presence");
if (!afb_event_is_valid(presence_event)) {
@@ -284,21 +281,21 @@ static int init(afb_api_t api)
static void subscribe(afb_req_t request)
{
- if (afb_req_subscribe(request, presence_event) < 0) {
- AFB_REQ_ERROR(request, "subscribe to presence_event failed");
- afb_req_reply(request, NULL, "failed", "Invalid event");
+ if (afb_req_subscribe(request, presence_event) < 0) {
+ AFB_REQ_ERROR(request, "subscribe to presence_event failed");
+ afb_req_reply(request, NULL, "failed", "Invalid event");
return;
- }
+ }
afb_req_reply(request, NULL, NULL, NULL);
}
static void unsubscribe(afb_req_t request)
{
- if (afb_req_unsubscribe(request, presence_event) < 0) {
- AFB_REQ_ERROR(request, "unsubscribe to presence_event failed");
- afb_req_reply(request, NULL, "failed", "Invalid event");
+ if (afb_req_unsubscribe(request, presence_event) < 0) {
+ AFB_REQ_ERROR(request, "unsubscribe to presence_event failed");
+ afb_req_reply(request, NULL, "failed", "Invalid event");
return;
}
@@ -307,23 +304,20 @@ static void unsubscribe(afb_req_t request)
}
static const afb_verb_t binding_verbs[] = {
- { .verb = "subscribe", .callback = subscribe,
+ { .verb = "subscribe", .callback = subscribe,
.info = "Subscribe to NFC events" },
- { .verb = "unsubscribe", .callback = unsubscribe,
+ { .verb = "unsubscribe", .callback = unsubscribe,
.info = "Unsubscribe to NFC events" },
- { .verb = NULL }
+ { }
};
/*
* binder API description
*/
const afb_binding_t afbBindingExport = {
- .api = "nfc",
- .specification = "NFC service API",
- .info = "AGL nfc service",
- .verbs = binding_verbs,
- .preinit = NULL,
- .init = init,
- .onevent = NULL,
- .noconcurrency = 0
+ .api = "nfc",
+ .specification = "NFC service API",
+ .info = "AGL nfc service",
+ .verbs = binding_verbs,
+ .init = init,
};