From 21c81fbcf5607a4244d0d7c23526d18de643c93b Mon Sep 17 00:00:00 2001 From: Wiktor Lawski Date: Mon, 3 Sep 2012 11:57:22 +0200 Subject: [PATCH] plugins: Fix some whitespace issues --- plugins/handover.c | 7 ++++--- plugins/nfctype1.c | 34 +++++++++++++++++----------------- plugins/nfctype2.c | 21 ++++++++++----------- plugins/nfctype3.c | 54 +++++++++++++++++++++++++++--------------------------- plugins/nfctype4.c | 42 +++++++++++++++++++++--------------------- plugins/p2p.c | 8 ++++---- plugins/snep.c | 4 ++-- 7 files changed, 85 insertions(+), 85 deletions(-) diff --git a/plugins/handover.c b/plugins/handover.c index 8ba550a..e14cba6 100644 --- a/plugins/handover.c +++ b/plugins/handover.c @@ -90,6 +90,7 @@ static void free_hr_ndef(gpointer data) if (ndef != NULL) g_free(ndef->ndef); + g_free(ndef); } @@ -134,7 +135,7 @@ static int handover_ndef_parse(int client_fd, struct hr_ndef *ndef) * exchange with a Hr), so we have to do some actions (e.g.: * pairing with bluetooth) */ - if (strncmp((char *)(ndef->ndef + FRAME_TYPE_OFFSET), "Hr", 2) == 0) { + if (strncmp((char *) (ndef->ndef + FRAME_TYPE_OFFSET), "Hr", 2) == 0) { /* * The first entry on the record list is the Hr record. * We build the Hs based on it. @@ -375,7 +376,7 @@ static near_bool_t handover_read(int client_fd, ndef = g_hash_table_lookup(hr_ndef_hash, GINT_TO_POINTER(client_fd)); if (ndef == NULL) { - /* First call: allocate and read header bytes*/ + /* First call: allocate and read header bytes */ return handover_read_initialize(client_fd, adapter_idx, target_idx, cb); } @@ -408,7 +409,7 @@ static gboolean handover_push_event(GIOChannel *channel, GIOCondition condition, gpointer data) { near_bool_t ret; - struct hr_push_client *client = (struct hr_push_client *)data; + struct hr_push_client *client = (struct hr_push_client *) data; DBG("condition 0x%x", condition); diff --git a/plugins/nfctype1.c b/plugins/nfctype1.c index 4b78a35..d21584c 100644 --- a/plugins/nfctype1.c +++ b/plugins/nfctype1.c @@ -132,7 +132,7 @@ static void t1_cookie_release(struct t1_cookie *cookie) cookie = NULL; } -/* Read segments (128 bytes)and store them to the tag data block */ +/* Read segments (128 bytes) and store them to the tag data block */ static int segment_read_recv(uint8_t *resp, int length, void *data) { struct type1_tag *t1_tag = data; @@ -151,9 +151,9 @@ static int segment_read_recv(uint8_t *resp, int length, void *data) length = length - LEN_STATUS_BYTE; /* ignore first byte */ - /* Add data to tag mem*/ + /* Add data to tag mem */ tagdata = near_tag_get_data(t1_tag->tag, &data_length); - memcpy(tagdata + t1_tag->data_read, resp+1, length); + memcpy(tagdata + t1_tag->data_read, resp + 1, length); /* Next segment */ t1_tag->data_read = t1_tag->data_read + length; @@ -167,7 +167,7 @@ static int segment_read_recv(uint8_t *resp, int length, void *data) t1_cmd.addr = (t1_tag->current_seg << 4) & 0xFF; err = near_adapter_send(t1_tag->adapter_idx, - (uint8_t *)&t1_cmd, sizeof(t1_cmd), + (uint8_t *) &t1_cmd, sizeof(t1_cmd), segment_read_recv, t1_tag); if (err < 0) goto out_err; @@ -253,7 +253,7 @@ static int meta_recv(uint8_t *resp, int length, void *data) /* First byte is cmd status */ if (resp[OFFSET_STATUS_CMD] != 0) { - DBG("Command failed: 0x%x",resp[OFFSET_STATUS_CMD]); + DBG("Command failed: 0x%x", resp[OFFSET_STATUS_CMD]); err = -EIO; goto out_err; } @@ -331,7 +331,7 @@ static int meta_recv(uint8_t *resp, int length, void *data) near_tag_set_memory_layout(tag, NEAR_TAG_MEMORY_DYNAMIC); err = read_dynamic_tag(cc, length, t1_tag); } else { - err = -EOPNOTSUPP ; + err = -EOPNOTSUPP; } out_err: @@ -361,7 +361,7 @@ static int rid_resp(uint8_t *resp, int length, void *data) /* First byte is cmd status */ if (resp[OFFSET_STATUS_CMD] != 0) { - DBG("Command failed: 0x%x",resp[OFFSET_STATUS_CMD]); + DBG("Command failed: 0x%x", resp[OFFSET_STATUS_CMD]); err = -EIO; goto out_err; } @@ -430,7 +430,7 @@ static int nfctype1_read(uint32_t adapter_idx, cookie->cb = cb; return near_adapter_send(adapter_idx, - (uint8_t *)&t1_cmd, sizeof(t1_cmd), + (uint8_t *) &t1_cmd, sizeof(t1_cmd), rid_resp, cookie); } @@ -452,8 +452,8 @@ static int nfctype1_read(uint32_t adapter_idx, g_free(uid); - return near_adapter_send(adapter_idx, (uint8_t *)&t1_cmd, sizeof(t1_cmd), - meta_recv, cookie); + return near_adapter_send(adapter_idx, (uint8_t *) &t1_cmd, + sizeof(t1_cmd), meta_recv, cookie); } static int write_nmn_e1_resp(uint8_t *resp, int length, void *data) @@ -489,7 +489,7 @@ static int write_nmn_e1(struct t1_cookie *cookie) cmd.data[0] = TYPE1_MAGIC; memcpy(cmd.uid, cookie->uid, UID_LENGTH); - return near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + return near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, sizeof(cmd), write_nmn_e1_resp, cookie); } @@ -528,7 +528,7 @@ static int data_write(uint8_t *resp, int length, void *data) cookie->ndef->offset++; cookie->current_byte++; - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, sizeof(cmd), data_write, cookie); if (err < 0) goto out; @@ -582,7 +582,7 @@ static int write_nmn_0(uint32_t adapter_idx, uint32_t target_idx, g_free(uid); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, sizeof(cmd), data_write, cookie); if (err < 0) goto out; @@ -683,8 +683,8 @@ static int nfctype1_check_presence(uint32_t adapter_idx, cookie->target_idx = target_idx; cookie->cb = cb; - err = near_adapter_send(adapter_idx, (uint8_t *)&t1_cmd, sizeof(t1_cmd), - check_presence, cookie); + err = near_adapter_send(adapter_idx, (uint8_t *) &t1_cmd, + sizeof(t1_cmd), check_presence, cookie); if (err < 0) goto out; @@ -719,7 +719,7 @@ static int format_resp(uint8_t *resp, int length, void *data) cookie->current_byte++; memcpy(cmd.uid, cookie->uid, UID_LENGTH); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, sizeof(cmd), format_resp, cookie); if (err < 0) goto out; @@ -795,7 +795,7 @@ static int nfctype1_format(uint32_t adapter_idx, uint32_t target_idx, memcpy(cmd.uid, cookie->uid, UID_LENGTH); g_free(uid); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, sizeof(cmd), format_resp, cookie); if (err < 0) goto out; diff --git a/plugins/nfctype2.c b/plugins/nfctype2.c index 2858f24..ff684c5 100644 --- a/plugins/nfctype2.c +++ b/plugins/nfctype2.c @@ -162,7 +162,7 @@ static int data_recv(uint8_t *resp, int length, void *data) DBG("adapter %d", adapter_idx); return near_adapter_send(adapter_idx, - (uint8_t *)&cmd, CMD_READ_SIZE, + (uint8_t *) &cmd, CMD_READ_SIZE, data_recv, tag); } @@ -181,7 +181,7 @@ static int data_read(struct type2_tag *tag) adapter_idx = near_tag_get_adapter_idx(tag->tag); return near_adapter_send(adapter_idx, - (uint8_t *)&cmd, CMD_READ_SIZE, + (uint8_t *) &cmd, CMD_READ_SIZE, data_recv, tag); } @@ -283,7 +283,7 @@ static int nfctype2_read_meta(uint32_t adapter_idx, uint32_t target_idx, cookie->target_idx = target_idx; cookie->cb = cb; - err = near_adapter_send(adapter_idx, (uint8_t *)&cmd, CMD_READ_SIZE, + err = near_adapter_send(adapter_idx, (uint8_t *) &cmd, CMD_READ_SIZE, meta_recv, cookie); if (err < 0) g_free(cookie); @@ -309,7 +309,7 @@ static int nfctype2_read(uint32_t adapter_idx, /* Specific Mifare read access */ case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K: case NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K: - err= mifare_read( adapter_idx, target_idx, + err = mifare_read(adapter_idx, target_idx, cb, tgt_subtype); break; @@ -361,10 +361,9 @@ static int data_write_resp(uint8_t *resp, int length, void *data) cookie->ndef->offset = cookie->ndef->length + 1; } - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, sizeof(cmd), data_write_resp, cookie); - if (err < 0) goto out; @@ -405,7 +404,7 @@ static int data_write(uint32_t adapter_idx, uint32_t target_idx, cookie->ndef->offset += BLOCK_SIZE; cookie->current_block++; - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, sizeof(cmd), data_write_resp, cookie); if (err < 0) @@ -493,7 +492,7 @@ static int nfctype2_check_presence(uint32_t adapter_idx, uint32_t target_idx, cookie->target_idx = target_idx; cookie->cb = cb; - err = near_adapter_send(adapter_idx, (uint8_t *)&cmd, CMD_READ_SIZE, + err = near_adapter_send(adapter_idx, (uint8_t *) &cmd, CMD_READ_SIZE, check_presence, cookie); if (err < 0) goto out; @@ -580,14 +579,14 @@ static int nfctype2_format(uint32_t adapter_idx, uint32_t target_idx, cookie->target_idx = target_idx; cookie->current_block = CC_BLOCK_START; cookie->ndef = cc_ndef; - cookie->ndef->data = (uint8_t *)t2_cc; + cookie->ndef->data = (uint8_t *) t2_cc; cookie->cb = cb; cmd.cmd = CMD_WRITE; cmd.block = CC_BLOCK_START; - memcpy(cmd.data, (uint8_t *)t2_cc, BLOCK_SIZE); + memcpy(cmd.data, (uint8_t *) t2_cc, BLOCK_SIZE); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, sizeof(cmd), format_resp, cookie); out: diff --git a/plugins/nfctype3.c b/plugins/nfctype3.c index b23c230..c3f72be 100644 --- a/plugins/nfctype3.c +++ b/plugins/nfctype3.c @@ -170,9 +170,9 @@ static void prepare_write_block(uint8_t *UID, struct type3_cmd *cmd, /* common: Initialize structure to read block */ static void prepare_read_block(uint8_t cur_block, uint8_t *UID, - struct type3_cmd *cmd ) + struct type3_cmd *cmd) { - cmd->cmd = CMD_READ_WO_ENCRYPT; /* command */ + cmd->cmd = CMD_READ_WO_ENCRYPT; /* command */ memcpy(cmd->data, UID, LEN_ID); /* IDm */ cmd->data[LEN_ID] = 1; /* number of service */ @@ -192,11 +192,11 @@ static int check_recv_frame(uint8_t *resp, uint8_t reply_code) int err = 0; if (resp[OFS_NFC_STATUS] != 0) { - DBG("NFC Command failed: 0x%x",resp[OFS_NFC_STATUS]); + DBG("NFC Command failed: 0x%x", resp[OFS_NFC_STATUS]); err = -EIO; } - if (resp[OFS_CMD_RESP] != reply_code ) { + if (resp[OFS_CMD_RESP] != reply_code) { DBG("Felica cmd failed: 0x%x", resp[OFS_CMD_RESP]); err = -EIO; } @@ -226,7 +226,7 @@ static int nfctype3_data_recv(uint8_t *resp, int length, void *data) } nfc_data = near_tag_get_data(tag->tag, &data_length); - length_read = length - OFS_READ_DATA ; + length_read = length - OFS_READ_DATA; current_length = tag->current_block * BLOCK_SIZE; if (current_length + (length - OFS_READ_DATA) > data_length) length_read = data_length - current_length; @@ -252,9 +252,9 @@ static int nfctype3_data_recv(uint8_t *resp, int length, void *data) tag->current_block += read_blocks; prepare_read_block(DATA_BLOCK_START + tag->current_block, - tag->IDm, &cmd ); + tag->IDm, &cmd); - err = near_adapter_send(adapter_idx, (uint8_t *)&cmd, cmd.len, + err = near_adapter_send(adapter_idx, (uint8_t *) &cmd, cmd.len, nfctype3_data_recv, tag); if (err < 0) goto out; @@ -296,7 +296,7 @@ static int nfctype3_recv_block_0(uint8_t *resp, int length, void *data) int err = 0; struct near_tag *tag; struct type3_tag *t3_tag = NULL; - uint32_t ndef_data_length; + uint32_t ndef_data_length; DBG("%d", length); @@ -345,7 +345,7 @@ static int nfctype3_recv_block_0(uint8_t *resp, int length, void *data) goto out; } - memcpy(t3_tag->IDm, cookie->IDm , LEN_ID); + memcpy(t3_tag->IDm, cookie->IDm, LEN_ID); near_tag_set_idm(tag, cookie->IDm, LEN_ID); near_tag_set_attr_block(tag, resp + OFS_READ_DATA, BLOCK_SIZE); @@ -391,7 +391,7 @@ static int poll_ndef_system_code(uint8_t *resp, int length, void *data) prepare_read_block(META_BLOCK_START, cookie->IDm, &cmd); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, nfctype3_recv_block_0, cookie); if (err < 0) goto out; @@ -463,7 +463,7 @@ static int check_sys_op_in_mc_block(uint8_t *resp, int length, void *data) /* data len + 2 bytes */ cmd.len = LEN_CMD + LEN_CMD_LEN + 4 ; - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len , poll_ndef_system_code, cookie); } @@ -501,13 +501,13 @@ static int receive_system_code(uint8_t *resp, int length, void *data) cookie->ic_type = resp[IC_TYPE_OFFSET]; memcpy(cookie->IDm, resp + OFS_IDM, LEN_ID); - system_code = ((uint16_t)(resp[length - 2])) << 8; + system_code = ((uint16_t) (resp[length - 2])) << 8; system_code |= resp[length - 1]; switch (resp[IC_TYPE_OFFSET]) { case FELICA_LITE_IC_TYPE: prepare_read_block(FELICA_LITE_MC_BLOCK, cookie->IDm, &cmd); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, check_sys_op_in_mc_block, cookie); break; @@ -523,7 +523,7 @@ static int receive_system_code(uint8_t *resp, int length, void *data) /* data len + 2 bytes */ cmd.len = LEN_CMD + LEN_CMD_LEN + 4 ; - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, poll_ndef_system_code, cookie); } @@ -558,7 +558,7 @@ static int nfctype3_read(uint32_t adapter_idx, cmd.data[3] = 0x00; /* time slot */ /* data len + 2 bytes */ - cmd.len = LEN_CMD + LEN_CMD_LEN + 4 ; + cmd.len = LEN_CMD + LEN_CMD_LEN + 4; cookie = g_try_malloc0(sizeof(struct t3_cookie)); if (cookie == NULL) @@ -568,8 +568,8 @@ static int nfctype3_read(uint32_t adapter_idx, cookie->target_idx = target_idx; cookie->cb = cb; - err = near_adapter_send(adapter_idx, (uint8_t *)&cmd, - cmd.len , receive_system_code, cookie); + err = near_adapter_send(adapter_idx, (uint8_t *) &cmd, + cmd.len, receive_system_code, cookie); if (err < 0) g_free(cookie); @@ -669,7 +669,7 @@ static int data_write_resp(uint8_t *resp, int length, void *data) cookie->current_block++; cookie->ndef->offset += BLOCK_SIZE; - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, cmd.len, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, data_write_resp, cookie); if (err < 0) goto out; @@ -726,7 +726,7 @@ static int data_write(uint32_t adapter_idx, uint32_t target_idx, } memcpy(cookie->attr, attr, len); - nmaxb = (((uint16_t)(cookie->attr[3])) << 8) | cookie->attr[4]; + nmaxb = (((uint16_t) (cookie->attr[3])) << 8) | cookie->attr[4]; if (cookie->ndef->length > (nmaxb * BLOCK_SIZE)) { near_error("not enough space on tag"); @@ -740,14 +740,14 @@ static int data_write(uint32_t adapter_idx, uint32_t target_idx, for (i = 0; i < 14; i++) checksum += cookie->attr[i]; - cookie->attr[14] = (uint8_t)(checksum >> 8); - cookie->attr[15] = (uint8_t)(checksum); + cookie->attr[14] = (uint8_t) (checksum >> 8); + cookie->attr[15] = (uint8_t) checksum; prepare_write_block(cookie->IDm, &cmd, cookie->current_block, cookie->attr); cookie->current_block++; - err = near_adapter_send(adapter_idx, (uint8_t *)&cmd, cmd.len, + err = near_adapter_send(adapter_idx, (uint8_t *) &cmd, cmd.len, data_write_resp, cookie); if (err < 0) goto out; @@ -824,8 +824,8 @@ static int nfctype3_check_presence(uint32_t adapter_idx, cookie->target_idx = target_idx; cookie->cb = cb; - err = near_adapter_send(adapter_idx, (uint8_t *)&cmd, - cmd.len , nfctype3_check_recv_UID, cookie); + err = near_adapter_send(adapter_idx, (uint8_t *) &cmd, + cmd.len, nfctype3_check_recv_UID, cookie); if (err < 0) goto out; @@ -918,7 +918,7 @@ static int write_attr_block(uint8_t *resp, int length , void *data) prepare_write_block(cookie->IDm, &cmd, META_BLOCK_START, cookie->attr); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, format_resp, cookie); if (err < 0) goto out; @@ -965,7 +965,7 @@ static int write_mc_block(uint8_t *resp, int length, void *data) cookie->mc_block[3] = 1; prepare_write_block(cookie->IDm, &cmd, FELICA_LITE_MC_BLOCK, cookie->mc_block); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, write_attr_block, cookie); if (err < 0) goto out; @@ -1019,7 +1019,7 @@ static int nfctype3_format(uint32_t adapter_idx, memcpy(cookie->IDm, idm, len); prepare_read_block(FELICA_LITE_MC_BLOCK, cookie->IDm, &cmd); - err = near_adapter_send(cookie->adapter_idx, (uint8_t *)&cmd, + err = near_adapter_send(cookie->adapter_idx, (uint8_t *) &cmd, cmd.len, write_mc_block, cookie); if (err < 0) goto out; diff --git a/plugins/nfctype4.c b/plugins/nfctype4.c index 76289a5..f9bb2aa 100644 --- a/plugins/nfctype4.c +++ b/plugins/nfctype4.c @@ -40,7 +40,7 @@ #include #include -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define NFC_STATUS 0 #define NFC_STATUS_BYTE_LEN 1 @@ -207,7 +207,7 @@ static int ISO_send_cmd(uint8_t class, cmd->data[cmd_data_length] = 0; } - err = near_adapter_send(in_rcv->adapter_idx, (uint8_t *)cmd, + err = near_adapter_send(in_rcv->adapter_idx, (uint8_t *) cmd, total_cmd_length, cb, in_rcv); if (err < 0) g_free(in_rcv); @@ -248,8 +248,8 @@ static int ISO_ReadBinary(uint16_t offset, uint8_t readsize, return ISO_send_cmd( 0x00, /* CLA */ 0xB0, /* INS: Select file */ - (uint8_t)((offset & 0xFF00)>>8), - (uint8_t)(offset & 0xFF), + (uint8_t) ((offset & 0xFF00) >> 8), + (uint8_t) (offset & 0xFF), 0, /* no data send */ readsize, /* bytes to read */ FALSE, @@ -265,8 +265,8 @@ static int ISO_Update(uint16_t offset, uint8_t nlen, return ISO_send_cmd( 0x00, /* CLA */ 0xD6, /* INS: Select file */ - (uint8_t)((offset & 0xFF00) >> 8), - (uint8_t)(offset & 0xFF), + (uint8_t) ((offset & 0xFF00) >> 8), + (uint8_t) (offset & 0xFF), data, /* length of NDEF data */ nlen, /* NLEN + NDEF data */ FALSE, @@ -342,7 +342,7 @@ static int data_read_cb(uint8_t *resp, int length, void *data) cookie->r_apdu_max_size, data_read_cb, cookie); else err = ISO_ReadBinary(cookie->read_data + 2, - (uint8_t)remain_bytes, data_read_cb, cookie); + (uint8_t) remain_bytes, data_read_cb, cookie); if (err < 0) goto out_err; @@ -354,7 +354,7 @@ out_err: static int t4_readbin_NDEF_ID(uint8_t *resp, int length, void *data) { - struct t4_cookie *cookie = data ; + struct t4_cookie *cookie = data; struct near_tag *tag; int err = 0; @@ -397,7 +397,7 @@ static int t4_readbin_NDEF_ID(uint8_t *resp, int length, void *data) near_tag_set_ro(tag, FALSE); /* TODO: see how we can get the UID value: - * near_tag_set_uid(tag, resp + NFC_HEADER_SIZE, 8); + * near_tag_set_uid(tag, resp + NFC_HEADER_SIZE, 8); * */ /* Read 1st block */ @@ -445,8 +445,8 @@ out_err: static int t4_readbin_cc(uint8_t *resp, int length, void *data) { - struct t4_cookie *cookie = data ; - struct type4_cc *read_cc ; + struct t4_cookie *cookie = data; + struct type4_cc *read_cc; int err = 0; DBG("%d", length); @@ -474,22 +474,22 @@ static int t4_readbin_cc(uint8_t *resp, int length, void *data) memcpy(read_cc, &resp[1], length - 2 - NFC_STATUS_BYTE_LEN) ; cookie->r_apdu_max_size = g_ntohs(read_cc->max_R_apdu_data_size) - - APDU_HEADER_LEN ; + APDU_HEADER_LEN; cookie->c_apdu_max_size = g_ntohs(read_cc->max_C_apdu_data_size); cookie->max_ndef_size = g_ntohs(read_cc->tlv_fc.max_ndef_size); - /* TODO 5.1.1 :TLV blocks can be zero, one or more... */ - /* TODO 5.1.2 :Must ignore proprietary blocks (x05)... */ - if (read_cc->tlv_fc.tag != 0x4) { - DBG("NDEF File Control tag not found !") ; - err = -EINVAL ; - goto out_err ; + /* TODO 5.1.1: TLV blocks can be zero, one or more... */ + /* TODO 5.1.2: Must ignore proprietary blocks (x05)... */ + if (read_cc->tlv_fc.tag != 0x4) { + DBG("NDEF File Control tag not found !"); + err = -EINVAL; + goto out_err; } /* save rw conditions */ cookie->write_access = read_cc->tlv_fc.write_access; - err = ISO_Select((uint8_t *)&read_cc->tlv_fc.file_id, + err = ISO_Select((uint8_t *) &read_cc->tlv_fc.file_id, LEN_ISO_CC_FILEID, 0, t4_select_NDEF_ID, cookie); if (err < 0) goto out_err; @@ -550,7 +550,7 @@ out_err: static int t4_select_file_by_name_v1(uint8_t *resp, int length, void *data) { struct t4_cookie *cookie = data; - int err = 0 ; + int err = 0; DBG("%d", length); @@ -586,7 +586,7 @@ out_err: static int t4_select_file_by_name_v2(uint8_t *resp, int length, void *data) { struct t4_cookie *cookie = data; - int err = 0 ; + int err = 0; DBG("%d", length); diff --git a/plugins/p2p.c b/plugins/p2p.c index f6352a1..97db657 100644 --- a/plugins/p2p.c +++ b/plugins/p2p.c @@ -106,7 +106,7 @@ static void free_client_data(gpointer data) DBG(""); - client_data = (struct p2p_data *)data; + client_data = (struct p2p_data *) data; if (client_data->driver->close != NULL) client_data->driver->close(client_data->fd, 0); @@ -165,7 +165,7 @@ static gboolean p2p_listener_event(GIOChannel *channel, GIOCondition condition, } client_addr_len = sizeof(client_addr); - client_fd = accept(server_fd, (struct sockaddr *)&client_addr, + client_fd = accept(server_fd, (struct sockaddr *) &client_addr, &client_addr_len); if (client_fd < 0) { near_error("accept failed %d", client_fd); @@ -224,7 +224,7 @@ static int p2p_bind(struct near_p2p_driver *driver, uint32_t adapter_idx, addr.service_name_len = strlen(driver->service_name); strcpy(addr.service_name, driver->service_name); - err = bind(fd, (struct sockaddr *)&addr, + err = bind(fd, (struct sockaddr *) &addr, sizeof(struct sockaddr_nfc_llcp)); if (err < 0) { if (errno == EADDRINUSE) { @@ -305,7 +305,7 @@ static int p2p_connect(uint32_t adapter_idx, uint32_t target_idx, addr.service_name_len = strlen(driver->service_name); strcpy(addr.service_name, driver->service_name); - err = connect(fd, (struct sockaddr *)&addr, + err = connect(fd, (struct sockaddr *) &addr, sizeof(struct sockaddr_nfc_llcp)); if (err < 0) { near_error("Connect failed %d", err); diff --git a/plugins/snep.c b/plugins/snep.c index 488b765..4a2367a 100644 --- a/plugins/snep.c +++ b/plugins/snep.c @@ -289,7 +289,7 @@ static void free_snep_push_data(gpointer userdata, int status) DBG(""); - data = (struct p2p_snep_put_req_data *)userdata; + data = (struct p2p_snep_put_req_data *) userdata; close(data->fd); @@ -477,7 +477,7 @@ static int snep_push(int fd, uint32_t adapter_idx, uint32_t target_idx, goto error; } - memcpy(fragment->data, (uint8_t *)&header, + memcpy(fragment->data, (uint8_t *) &header, SNEP_REQ_PUT_HEADER_LENGTH); if (fragmenting == TRUE) { -- 2.7.4