From: Martin Willi Date: Fri, 6 Jul 2012 06:39:15 +0000 (+0200) Subject: Add a return value to prf_plus_t.get_bytes() X-Git-Tag: 5.0.1~366 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8207fe3eb3ec300cf992a021a960f91cca8a109c;p=thirdparty%2Fstrongswan.git Add a return value to prf_plus_t.get_bytes() --- diff --git a/src/libstrongswan/crypto/prf_plus.c b/src/libstrongswan/crypto/prf_plus.c index 8ddacfe6e6..2e7f87d1f5 100644 --- a/src/libstrongswan/crypto/prf_plus.c +++ b/src/libstrongswan/crypto/prf_plus.c @@ -57,7 +57,7 @@ struct private_prf_plus_t { chunk_t buffer; }; -METHOD(prf_plus_t, get_bytes, void, +METHOD(prf_plus_t, get_bytes, bool, private_prf_plus_t *this, size_t length, u_int8_t *buffer) { size_t round, written = 0; @@ -87,6 +87,7 @@ METHOD(prf_plus_t, get_bytes, void, this->used += round; written += round; } + return TRUE; } METHOD(prf_plus_t, allocate_bytes, bool, @@ -95,12 +96,9 @@ METHOD(prf_plus_t, allocate_bytes, bool, if (length) { *chunk = chunk_alloc(length); - get_bytes(this, length, chunk->ptr); - } - else - { - *chunk = chunk_empty; + return get_bytes(this, length, chunk->ptr); } + *chunk = chunk_empty; return TRUE; } diff --git a/src/libstrongswan/crypto/prf_plus.h b/src/libstrongswan/crypto/prf_plus.h index 72009da895..1f668edf25 100644 --- a/src/libstrongswan/crypto/prf_plus.h +++ b/src/libstrongswan/crypto/prf_plus.h @@ -36,8 +36,10 @@ struct prf_plus_t { * * @param length number of bytes to get * @param buffer pointer where the generated bytes will be written + * @return TRUE if bytes generated successfully */ - void (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer); + __attribute__((warn_unused_result)) + bool (*get_bytes) (prf_plus_t *this, size_t length, u_int8_t *buffer); /** * Allocate pseudo random bytes.