diff mbox

[1/4] api: random: replace ssize_t with int32_t

Message ID 1424869109-930-1-git-send-email-petri.savolainen@linaro.org
State Accepted
Commit b614e3c9f5e3f6e8ce3dc0a43ea7703caedf5a66
Headers show

Commit Message

Petri Savolainen Feb. 25, 2015, 12:58 p.m. UTC
ssize_t is a POSIX type. API definition must be pure C (C99).
Signed 32 bits can hold larger values than size_t (64k) and
ssize_t(32k) in minimum.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>
---
 example/ipsec/odp_ipsec_cache.c              | 4 ++--
 include/odp/api/random.h                     | 4 ++--
 platform/linux-generic/odp_crypto.c          | 6 +++---
 test/validation/crypto/odp_crypto_test_rng.c | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

Comments

Bill Fischofer Feb. 25, 2015, 1:20 p.m. UTC | #1
For this series:

Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>

On Wed, Feb 25, 2015 at 6:58 AM, Petri Savolainen <
petri.savolainen@linaro.org> wrote:

> ssize_t is a POSIX type. API definition must be pure C (C99).
> Signed 32 bits can hold larger values than size_t (64k) and
> ssize_t(32k) in minimum.
>
> Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>
> ---
>  example/ipsec/odp_ipsec_cache.c              | 4 ++--
>  include/odp/api/random.h                     | 4 ++--
>  platform/linux-generic/odp_crypto.c          | 6 +++---
>  test/validation/crypto/odp_crypto_test_rng.c | 2 +-
>  4 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/example/ipsec/odp_ipsec_cache.c
> b/example/ipsec/odp_ipsec_cache.c
> index 5a41cec..12b960d 100644
> --- a/example/ipsec/odp_ipsec_cache.c
> +++ b/example/ipsec/odp_ipsec_cache.c
> @@ -96,9 +96,9 @@ int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
>
>         /* Generate an IV */
>         if (params.iv.length) {
> -               ssize_t size = params.iv.length;
> +               int32_t size = params.iv.length;
>
> -               ssize_t ret = odp_random_data(params.iv.data, size, 1);
> +               int32_t ret = odp_random_data(params.iv.data, size, 1);
>                 if (ret != size)
>                         return -1;
>         }
> diff --git a/include/odp/api/random.h b/include/odp/api/random.h
> index 293043e..3451b0d 100644
> --- a/include/odp/api/random.h
> +++ b/include/odp/api/random.h
> @@ -35,8 +35,8 @@ extern "C" {
>   * @return Number of bytes written
>   * @retval <0 on failure
>   */
> -ssize_t
> -odp_random_data(uint8_t *buf, ssize_t size, odp_bool_t use_entropy);
> +int32_t
> +odp_random_data(uint8_t *buf, int32_t size, odp_bool_t use_entropy);
>
>  /**
>   * @}
> diff --git a/platform/linux-generic/odp_crypto.c
> b/platform/linux-generic/odp_crypto.c
> index 2df37e7..61dba6e 100644
> --- a/platform/linux-generic/odp_crypto.c
> +++ b/platform/linux-generic/odp_crypto.c
> @@ -458,10 +458,10 @@ int odp_crypto_term_global(void)
>         return ret;
>  }
>
> -ssize_t
> -odp_random_data(uint8_t *buf, ssize_t len, odp_bool_t use_entropy
> ODP_UNUSED)
> +int32_t
> +odp_random_data(uint8_t *buf, int32_t len, odp_bool_t use_entropy
> ODP_UNUSED)
>  {
> -       int rc;
> +       int32_t rc;
>         rc = RAND_bytes(buf, len);
>         return (1 == rc) ? len /*success*/: -1 /*failure*/;
>  }
> diff --git a/test/validation/crypto/odp_crypto_test_rng.c
> b/test/validation/crypto/odp_crypto_test_rng.c
> index a9e3db0..6a4ad17 100644
> --- a/test/validation/crypto/odp_crypto_test_rng.c
> +++ b/test/validation/crypto/odp_crypto_test_rng.c
> @@ -15,7 +15,7 @@
>  #define RNG_GET_SIZE   "RNG_GET_SIZE"
>  static void rng_get_size(void)
>  {
> -       int ret;
> +       int32_t ret;
>         uint8_t buf[TDES_CBC_IV_LEN];
>
>         ret = odp_random_data(buf, sizeof(buf), false);
> --
> 2.3.0
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov Feb. 25, 2015, 3:38 p.m. UTC | #2
Merged,
Maxim.

On 02/25/2015 04:20 PM, Bill Fischofer wrote:
> For this series:
>
> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>>
>
> On Wed, Feb 25, 2015 at 6:58 AM, Petri Savolainen 
> <petri.savolainen@linaro.org <mailto:petri.savolainen@linaro.org>> wrote:
>
>     ssize_t is a POSIX type. API definition must be pure C (C99).
>     Signed 32 bits can hold larger values than size_t (64k) and
>     ssize_t(32k) in minimum.
>
>     Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org
>     <mailto:petri.savolainen@linaro.org>>
>     ---
>      example/ipsec/odp_ipsec_cache.c              | 4 ++--
>      include/odp/api/random.h                     | 4 ++--
>      platform/linux-generic/odp_crypto.c          | 6 +++---
>      test/validation/crypto/odp_crypto_test_rng.c | 2 +-
>      4 files changed, 8 insertions(+), 8 deletions(-)
>
>     diff --git a/example/ipsec/odp_ipsec_cache.c
>     b/example/ipsec/odp_ipsec_cache.c
>     index 5a41cec..12b960d 100644
>     --- a/example/ipsec/odp_ipsec_cache.c
>     +++ b/example/ipsec/odp_ipsec_cache.c
>     @@ -96,9 +96,9 @@ int create_ipsec_cache_entry(sa_db_entry_t
>     *cipher_sa,
>
>             /* Generate an IV */
>             if (params.iv.length) {
>     -               ssize_t size = params.iv.length;
>     +               int32_t size = params.iv.length;
>
>     -               ssize_t ret = odp_random_data(params.iv.data,
>     size, 1);
>     +               int32_t ret = odp_random_data(params.iv.data,
>     size, 1);
>                     if (ret != size)
>                             return -1;
>             }
>     diff --git a/include/odp/api/random.h b/include/odp/api/random.h
>     index 293043e..3451b0d 100644
>     --- a/include/odp/api/random.h
>     +++ b/include/odp/api/random.h
>     @@ -35,8 +35,8 @@ extern "C" {
>       * @return Number of bytes written
>       * @retval <0 on failure
>       */
>     -ssize_t
>     -odp_random_data(uint8_t *buf, ssize_t size, odp_bool_t use_entropy);
>     +int32_t
>     +odp_random_data(uint8_t *buf, int32_t size, odp_bool_t use_entropy);
>
>      /**
>       * @}
>     diff --git a/platform/linux-generic/odp_crypto.c
>     b/platform/linux-generic/odp_crypto.c
>     index 2df37e7..61dba6e 100644
>     --- a/platform/linux-generic/odp_crypto.c
>     +++ b/platform/linux-generic/odp_crypto.c
>     @@ -458,10 +458,10 @@ int odp_crypto_term_global(void)
>             return ret;
>      }
>
>     -ssize_t
>     -odp_random_data(uint8_t *buf, ssize_t len, odp_bool_t use_entropy
>     ODP_UNUSED)
>     +int32_t
>     +odp_random_data(uint8_t *buf, int32_t len, odp_bool_t use_entropy
>     ODP_UNUSED)
>      {
>     -       int rc;
>     +       int32_t rc;
>             rc = RAND_bytes(buf, len);
>             return (1 == rc) ? len /*success*/: -1 /*failure*/;
>      }
>     diff --git a/test/validation/crypto/odp_crypto_test_rng.c
>     b/test/validation/crypto/odp_crypto_test_rng.c
>     index a9e3db0..6a4ad17 100644
>     --- a/test/validation/crypto/odp_crypto_test_rng.c
>     +++ b/test/validation/crypto/odp_crypto_test_rng.c
>     @@ -15,7 +15,7 @@
>      #define RNG_GET_SIZE   "RNG_GET_SIZE"
>      static void rng_get_size(void)
>      {
>     -       int ret;
>     +       int32_t ret;
>             uint8_t buf[TDES_CBC_IV_LEN];
>
>             ret = odp_random_data(buf, sizeof(buf), false);
>     --
>     2.3.0
>
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     http://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/example/ipsec/odp_ipsec_cache.c b/example/ipsec/odp_ipsec_cache.c
index 5a41cec..12b960d 100644
--- a/example/ipsec/odp_ipsec_cache.c
+++ b/example/ipsec/odp_ipsec_cache.c
@@ -96,9 +96,9 @@  int create_ipsec_cache_entry(sa_db_entry_t *cipher_sa,
 
 	/* Generate an IV */
 	if (params.iv.length) {
-		ssize_t size = params.iv.length;
+		int32_t size = params.iv.length;
 
-		ssize_t ret = odp_random_data(params.iv.data, size, 1);
+		int32_t ret = odp_random_data(params.iv.data, size, 1);
 		if (ret != size)
 			return -1;
 	}
diff --git a/include/odp/api/random.h b/include/odp/api/random.h
index 293043e..3451b0d 100644
--- a/include/odp/api/random.h
+++ b/include/odp/api/random.h
@@ -35,8 +35,8 @@  extern "C" {
  * @return Number of bytes written
  * @retval <0 on failure
  */
-ssize_t
-odp_random_data(uint8_t *buf, ssize_t size, odp_bool_t use_entropy);
+int32_t
+odp_random_data(uint8_t *buf, int32_t size, odp_bool_t use_entropy);
 
 /**
  * @}
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 2df37e7..61dba6e 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -458,10 +458,10 @@  int odp_crypto_term_global(void)
 	return ret;
 }
 
-ssize_t
-odp_random_data(uint8_t *buf, ssize_t len, odp_bool_t use_entropy ODP_UNUSED)
+int32_t
+odp_random_data(uint8_t *buf, int32_t len, odp_bool_t use_entropy ODP_UNUSED)
 {
-	int rc;
+	int32_t rc;
 	rc = RAND_bytes(buf, len);
 	return (1 == rc) ? len /*success*/: -1 /*failure*/;
 }
diff --git a/test/validation/crypto/odp_crypto_test_rng.c b/test/validation/crypto/odp_crypto_test_rng.c
index a9e3db0..6a4ad17 100644
--- a/test/validation/crypto/odp_crypto_test_rng.c
+++ b/test/validation/crypto/odp_crypto_test_rng.c
@@ -15,7 +15,7 @@ 
 #define RNG_GET_SIZE	"RNG_GET_SIZE"
 static void rng_get_size(void)
 {
-	int ret;
+	int32_t ret;
 	uint8_t buf[TDES_CBC_IV_LEN];
 
 	ret = odp_random_data(buf, sizeof(buf), false);