diff options
author | irungentoo <irungentoo@gmail.com> | 2015-07-14 22:19:04 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-07-14 22:19:04 -0400 |
commit | 0444829dde0f954e71d9b05875ef1ab4a1416255 (patch) | |
tree | cbf225e3c45f4fdfc1e4ea16f8a2e2a59ab1d19f | |
parent | 6f8aab0919a7730119ceff52e972479ee7a2acff (diff) |
Use size define instead of sizeof.
-rw-r--r-- | toxcore/DHT.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/toxcore/DHT.c b/toxcore/DHT.c index 1c6e767f..1b1c1bdf 100644 --- a/toxcore/DHT.c +++ b/toxcore/DHT.c | |||
@@ -207,26 +207,26 @@ int pack_nodes(uint8_t *data, uint16_t length, const Node_format *nodes, uint16_ | |||
207 | } | 207 | } |
208 | 208 | ||
209 | if (ipv6 == 0) { | 209 | if (ipv6 == 0) { |
210 | uint32_t size = 1 + sizeof(IP4) + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES; | 210 | uint32_t size = 1 + SIZE_IP4 + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES; |
211 | 211 | ||
212 | if (packed_length + size > length) | 212 | if (packed_length + size > length) |
213 | return -1; | 213 | return -1; |
214 | 214 | ||
215 | data[packed_length] = net_family; | 215 | data[packed_length] = net_family; |
216 | memcpy(data + packed_length + 1, &nodes[i].ip_port.ip.ip4, sizeof(IP4)); | 216 | memcpy(data + packed_length + 1, &nodes[i].ip_port.ip.ip4, SIZE_IP4); |
217 | memcpy(data + packed_length + 1 + sizeof(IP4), &nodes[i].ip_port.port, sizeof(uint16_t)); | 217 | memcpy(data + packed_length + 1 + SIZE_IP4, &nodes[i].ip_port.port, sizeof(uint16_t)); |
218 | memcpy(data + packed_length + 1 + sizeof(IP4) + sizeof(uint16_t), nodes[i].public_key, crypto_box_PUBLICKEYBYTES); | 218 | memcpy(data + packed_length + 1 + SIZE_IP4 + sizeof(uint16_t), nodes[i].public_key, crypto_box_PUBLICKEYBYTES); |
219 | packed_length += size; | 219 | packed_length += size; |
220 | } else if (ipv6 == 1) { | 220 | } else if (ipv6 == 1) { |
221 | uint32_t size = 1 + sizeof(IP6) + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES; | 221 | uint32_t size = 1 + SIZE_IP6 + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES; |
222 | 222 | ||
223 | if (packed_length + size > length) | 223 | if (packed_length + size > length) |
224 | return -1; | 224 | return -1; |
225 | 225 | ||
226 | data[packed_length] = net_family; | 226 | data[packed_length] = net_family; |
227 | memcpy(data + packed_length + 1, &nodes[i].ip_port.ip.ip6, sizeof(IP6)); | 227 | memcpy(data + packed_length + 1, &nodes[i].ip_port.ip.ip6, SIZE_IP6); |
228 | memcpy(data + packed_length + 1 + sizeof(IP6), &nodes[i].ip_port.port, sizeof(uint16_t)); | 228 | memcpy(data + packed_length + 1 + SIZE_IP6, &nodes[i].ip_port.port, sizeof(uint16_t)); |
229 | memcpy(data + packed_length + 1 + sizeof(IP6) + sizeof(uint16_t), nodes[i].public_key, crypto_box_PUBLICKEYBYTES); | 229 | memcpy(data + packed_length + 1 + SIZE_IP6 + sizeof(uint16_t), nodes[i].public_key, crypto_box_PUBLICKEYBYTES); |
230 | packed_length += size; | 230 | packed_length += size; |
231 | } else { | 231 | } else { |
232 | return -1; | 232 | return -1; |
@@ -275,27 +275,27 @@ int unpack_nodes(Node_format *nodes, uint16_t max_num_nodes, uint16_t *processed | |||
275 | } | 275 | } |
276 | 276 | ||
277 | if (ipv6 == 0) { | 277 | if (ipv6 == 0) { |
278 | uint32_t size = 1 + sizeof(IP4) + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES; | 278 | uint32_t size = 1 + SIZE_IP4 + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES; |
279 | 279 | ||
280 | if (len_processed + size > length) | 280 | if (len_processed + size > length) |
281 | return -1; | 281 | return -1; |
282 | 282 | ||
283 | nodes[num].ip_port.ip.family = host_family; | 283 | nodes[num].ip_port.ip.family = host_family; |
284 | memcpy(&nodes[num].ip_port.ip.ip4, data + len_processed + 1, sizeof(IP4)); | 284 | memcpy(&nodes[num].ip_port.ip.ip4, data + len_processed + 1, SIZE_IP4); |
285 | memcpy(&nodes[num].ip_port.port, data + len_processed + 1 + sizeof(IP4), sizeof(uint16_t)); | 285 | memcpy(&nodes[num].ip_port.port, data + len_processed + 1 + SIZE_IP4, sizeof(uint16_t)); |
286 | memcpy(nodes[num].public_key, data + len_processed + 1 + sizeof(IP4) + sizeof(uint16_t), crypto_box_PUBLICKEYBYTES); | 286 | memcpy(nodes[num].public_key, data + len_processed + 1 + SIZE_IP4 + sizeof(uint16_t), crypto_box_PUBLICKEYBYTES); |
287 | len_processed += size; | 287 | len_processed += size; |
288 | ++num; | 288 | ++num; |
289 | } else if (ipv6 == 1) { | 289 | } else if (ipv6 == 1) { |
290 | uint32_t size = 1 + sizeof(IP6) + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES; | 290 | uint32_t size = 1 + SIZE_IP6 + sizeof(uint16_t) + crypto_box_PUBLICKEYBYTES; |
291 | 291 | ||
292 | if (len_processed + size > length) | 292 | if (len_processed + size > length) |
293 | return -1; | 293 | return -1; |
294 | 294 | ||
295 | nodes[num].ip_port.ip.family = host_family; | 295 | nodes[num].ip_port.ip.family = host_family; |
296 | memcpy(&nodes[num].ip_port.ip.ip6, data + len_processed + 1, sizeof(IP6)); | 296 | memcpy(&nodes[num].ip_port.ip.ip6, data + len_processed + 1, SIZE_IP6); |
297 | memcpy(&nodes[num].ip_port.port, data + len_processed + 1 + sizeof(IP6), sizeof(uint16_t)); | 297 | memcpy(&nodes[num].ip_port.port, data + len_processed + 1 + SIZE_IP6, sizeof(uint16_t)); |
298 | memcpy(nodes[num].public_key, data + len_processed + 1 + sizeof(IP6) + sizeof(uint16_t), crypto_box_PUBLICKEYBYTES); | 298 | memcpy(nodes[num].public_key, data + len_processed + 1 + SIZE_IP6 + sizeof(uint16_t), crypto_box_PUBLICKEYBYTES); |
299 | len_processed += size; | 299 | len_processed += size; |
300 | ++num; | 300 | ++num; |
301 | } else { | 301 | } else { |