Add a return value to prf_plus_t.get_bytes()
authorMartin Willi <martin@revosec.ch>
Fri, 6 Jul 2012 06:39:15 +0000 (08:39 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 16 Jul 2012 12:53:33 +0000 (14:53 +0200)
src/libstrongswan/crypto/prf_plus.c
src/libstrongswan/crypto/prf_plus.h

index 8ddacfe..2e7f87d 100644 (file)
@@ -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;
 }
 
index 72009da..1f668ed 100644 (file)
@@ -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.