diff options
Diffstat (limited to 'src/util/bio.c')
-rw-r--r-- | src/util/bio.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/src/util/bio.c b/src/util/bio.c index b27230240..39050bb87 100644 --- a/src/util/bio.c +++ b/src/util/bio.c | |||
@@ -260,7 +260,7 @@ read_from_buffer (struct GNUNET_BIO_ReadHandle *h, | |||
260 | char *result, | 260 | char *result, |
261 | size_t len) | 261 | size_t len) |
262 | { | 262 | { |
263 | if (h->size < len || h->size - h->pos < len) | 263 | if ((h->size < len) || (h->size - h->pos < len)) |
264 | { | 264 | { |
265 | GNUNET_asprintf (&h->emsg, | 265 | GNUNET_asprintf (&h->emsg, |
266 | _ ("Error while reading `%s' from buffer: %s"), | 266 | _ ("Error while reading `%s' from buffer: %s"), |
@@ -431,6 +431,7 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | |||
431 | return GNUNET_OK; | 431 | return GNUNET_OK; |
432 | } | 432 | } |
433 | 433 | ||
434 | |||
434 | /** | 435 | /** |
435 | * Read a float. | 436 | * Read a float. |
436 | * | 437 | * |
@@ -439,9 +440,9 @@ GNUNET_BIO_read_meta_data (struct GNUNET_BIO_ReadHandle *h, | |||
439 | * @param f address of float to read | 440 | * @param f address of float to read |
440 | */ | 441 | */ |
441 | int | 442 | int |
442 | GNUNET_BIO_read_float(struct GNUNET_BIO_ReadHandle *h, | 443 | GNUNET_BIO_read_float (struct GNUNET_BIO_ReadHandle *h, |
443 | const char *what, | 444 | const char *what, |
444 | float *f) | 445 | float *f) |
445 | { | 446 | { |
446 | int32_t *i = (int32_t *) f; | 447 | int32_t *i = (int32_t *) f; |
447 | return GNUNET_BIO_read_int32 (h, what, i); | 448 | return GNUNET_BIO_read_int32 (h, what, i); |
@@ -456,9 +457,9 @@ GNUNET_BIO_read_float(struct GNUNET_BIO_ReadHandle *h, | |||
456 | * @param f address of double to read | 457 | * @param f address of double to read |
457 | */ | 458 | */ |
458 | int | 459 | int |
459 | GNUNET_BIO_read_double(struct GNUNET_BIO_ReadHandle *h, | 460 | GNUNET_BIO_read_double (struct GNUNET_BIO_ReadHandle *h, |
460 | const char *what, | 461 | const char *what, |
461 | double *f) | 462 | double *f) |
462 | { | 463 | { |
463 | int64_t *i = (int64_t *) f; | 464 | int64_t *i = (int64_t *) f; |
464 | return GNUNET_BIO_read_int64 (h, what, i); | 465 | return GNUNET_BIO_read_int64 (h, what, i); |
@@ -692,7 +693,7 @@ GNUNET_BIO_get_buffer_contents (struct GNUNET_BIO_WriteHandle *h, | |||
692 | { | 693 | { |
693 | if (IO_BUFFER != h->type) | 694 | if (IO_BUFFER != h->type) |
694 | return GNUNET_SYSERR; | 695 | return GNUNET_SYSERR; |
695 | if (NULL == contents || NULL == size) | 696 | if ((NULL == contents) || (NULL == size)) |
696 | return GNUNET_SYSERR; | 697 | return GNUNET_SYSERR; |
697 | int ret = (NULL != h->emsg) ? GNUNET_SYSERR : GNUNET_OK; | 698 | int ret = (NULL != h->emsg) ? GNUNET_SYSERR : GNUNET_OK; |
698 | if (NULL != emsg) | 699 | if (NULL != emsg) |
@@ -897,9 +898,9 @@ GNUNET_BIO_write_meta_data (struct GNUNET_BIO_WriteHandle *h, | |||
897 | * @param f float to write | 898 | * @param f float to write |
898 | */ | 899 | */ |
899 | int | 900 | int |
900 | GNUNET_BIO_write_float(struct GNUNET_BIO_WriteHandle *h, | 901 | GNUNET_BIO_write_float (struct GNUNET_BIO_WriteHandle *h, |
901 | const char *what, | 902 | const char *what, |
902 | float f) | 903 | float f) |
903 | { | 904 | { |
904 | int32_t i = f; | 905 | int32_t i = f; |
905 | return GNUNET_BIO_write_int32 (h, what, i); | 906 | return GNUNET_BIO_write_int32 (h, what, i); |
@@ -914,9 +915,9 @@ GNUNET_BIO_write_float(struct GNUNET_BIO_WriteHandle *h, | |||
914 | * @param f double to write | 915 | * @param f double to write |
915 | */ | 916 | */ |
916 | int | 917 | int |
917 | GNUNET_BIO_write_double(struct GNUNET_BIO_WriteHandle *h, | 918 | GNUNET_BIO_write_double (struct GNUNET_BIO_WriteHandle *h, |
918 | const char *what, | 919 | const char *what, |
919 | double f) | 920 | double f) |
920 | { | 921 | { |
921 | int64_t i = f; | 922 | int64_t i = f; |
922 | return GNUNET_BIO_write_int64 (h, what, i); | 923 | return GNUNET_BIO_write_int64 (h, what, i); |
@@ -1196,7 +1197,7 @@ GNUNET_BIO_read_spec_int64 (const char *what, | |||
1196 | * @param f address of float to read | 1197 | * @param f address of float to read |
1197 | */ | 1198 | */ |
1198 | struct GNUNET_BIO_ReadSpec | 1199 | struct GNUNET_BIO_ReadSpec |
1199 | GNUNET_BIO_read_spec_float(const char *what, float *f) | 1200 | GNUNET_BIO_read_spec_float (const char *what, float *f) |
1200 | { | 1201 | { |
1201 | struct GNUNET_BIO_ReadSpec rs = { | 1202 | struct GNUNET_BIO_ReadSpec rs = { |
1202 | .rh = &read_spec_handler_int32, | 1203 | .rh = &read_spec_handler_int32, |
@@ -1216,7 +1217,7 @@ GNUNET_BIO_read_spec_float(const char *what, float *f) | |||
1216 | * @param f address of double to read | 1217 | * @param f address of double to read |
1217 | */ | 1218 | */ |
1218 | struct GNUNET_BIO_ReadSpec | 1219 | struct GNUNET_BIO_ReadSpec |
1219 | GNUNET_BIO_read_spec_double(const char *what, double *f) | 1220 | GNUNET_BIO_read_spec_double (const char *what, double *f) |
1220 | { | 1221 | { |
1221 | struct GNUNET_BIO_ReadSpec rs = { | 1222 | struct GNUNET_BIO_ReadSpec rs = { |
1222 | .rh = &read_spec_handler_int64, | 1223 | .rh = &read_spec_handler_int64, |
@@ -1243,7 +1244,7 @@ GNUNET_BIO_read_spec_commit (struct GNUNET_BIO_ReadHandle *h, | |||
1243 | { | 1244 | { |
1244 | int ret = GNUNET_OK; | 1245 | int ret = GNUNET_OK; |
1245 | 1246 | ||
1246 | for (size_t i=0; NULL!=rs[i].rh; ++i) | 1247 | for (size_t i = 0; NULL!=rs[i].rh; ++i) |
1247 | { | 1248 | { |
1248 | ret = rs[i].rh (rs[i].cls, h, rs[i].what, rs[i].target, rs[i].size); | 1249 | ret = rs[i].rh (rs[i].cls, h, rs[i].what, rs[i].target, rs[i].size); |
1249 | if (GNUNET_OK != ret) | 1250 | if (GNUNET_OK != ret) |
@@ -1490,7 +1491,7 @@ GNUNET_BIO_write_spec_int64 (const char *what, | |||
1490 | * @return the write spec | 1491 | * @return the write spec |
1491 | */ | 1492 | */ |
1492 | struct GNUNET_BIO_WriteSpec | 1493 | struct GNUNET_BIO_WriteSpec |
1493 | GNUNET_BIO_write_spec_float(const char *what, float *f) | 1494 | GNUNET_BIO_write_spec_float (const char *what, float *f) |
1494 | { | 1495 | { |
1495 | struct GNUNET_BIO_WriteSpec ws = { | 1496 | struct GNUNET_BIO_WriteSpec ws = { |
1496 | .wh = &write_spec_handler_int32, | 1497 | .wh = &write_spec_handler_int32, |
@@ -1512,7 +1513,7 @@ GNUNET_BIO_write_spec_float(const char *what, float *f) | |||
1512 | * @return the write spec | 1513 | * @return the write spec |
1513 | */ | 1514 | */ |
1514 | struct GNUNET_BIO_WriteSpec | 1515 | struct GNUNET_BIO_WriteSpec |
1515 | GNUNET_BIO_write_spec_double(const char *what, double *f) | 1516 | GNUNET_BIO_write_spec_double (const char *what, double *f) |
1516 | { | 1517 | { |
1517 | struct GNUNET_BIO_WriteSpec ws = { | 1518 | struct GNUNET_BIO_WriteSpec ws = { |
1518 | .wh = &write_spec_handler_int64, | 1519 | .wh = &write_spec_handler_int64, |
@@ -1540,7 +1541,7 @@ GNUNET_BIO_write_spec_commit (struct GNUNET_BIO_WriteHandle *h, | |||
1540 | { | 1541 | { |
1541 | int ret = GNUNET_OK; | 1542 | int ret = GNUNET_OK; |
1542 | 1543 | ||
1543 | for (size_t i=0; NULL!=ws[i].wh; ++i) | 1544 | for (size_t i = 0; NULL!=ws[i].wh; ++i) |
1544 | { | 1545 | { |
1545 | ret = ws[i].wh (ws[i].cls, h, ws[i].what, ws[i].source, ws[i].source_size); | 1546 | ret = ws[i].wh (ws[i].cls, h, ws[i].what, ws[i].source, ws[i].source_size); |
1546 | if (GNUNET_OK != ret) | 1547 | if (GNUNET_OK != ret) |