From e435beb1ea5380a90774dbf51fdc8c941e486551 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Thu, 15 Dec 2016 12:46:03 +0100 Subject: [PATCH] crypto: consistently use size_t as type for length parameters size_t is the correct type to use for sizes. --- doc/APIchanges | 4 ++++ libavutil/md5.c | 8 ++++++++ libavutil/md5.h | 8 +++++++- libavutil/sha.c | 6 +++++- libavutil/sha.h | 9 +++++++-- libavutil/version.h | 3 +++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7633c991813..942337903f1 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,10 @@ libavutil: 2015-08-28 API changes, most recent first: +2016-xx-xx - xxxxxxx + Change av_sha_update() and av_md5_sum()/av_md5_update() length + parameter type to size_t at next major bump. + 2016-xx-xx - xxxxxxx - lavc 57.29.0 - avcodec.h Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping information from containers. diff --git a/libavutil/md5.c b/libavutil/md5.c index 94f068109c0..1946d783172 100644 --- a/libavutil/md5.c +++ b/libavutil/md5.c @@ -146,7 +146,11 @@ void av_md5_init(AVMD5 *ctx) ctx->ABCD[3] = 0x67452301; } +#if FF_API_CRYPTO_SIZE_T void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len) +#else +void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len) +#endif { int i, j; @@ -177,7 +181,11 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst) AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]); } +#if FF_API_CRYPTO_SIZE_T void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len) +#else +void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len) +#endif { AVMD5 ctx; diff --git a/libavutil/md5.h b/libavutil/md5.h index c26318c01d9..55e7c234179 100644 --- a/libavutil/md5.h +++ b/libavutil/md5.h @@ -21,6 +21,7 @@ #ifndef AVUTIL_MD5_H #define AVUTIL_MD5_H +#include #include #include "attributes.h" @@ -36,9 +37,14 @@ struct AVMD5; struct AVMD5 *av_md5_alloc(void); void av_md5_init(struct AVMD5 *ctx); -void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); +#if FF_API_CRYPTO_SIZE_T +void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len); +#else +void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, size_t len); +void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len); +#endif /** * @} diff --git a/libavutil/sha.c b/libavutil/sha.c index 404effade2e..03f93aed8ce 100644 --- a/libavutil/sha.c +++ b/libavutil/sha.c @@ -290,7 +290,11 @@ av_cold int av_sha_init(AVSHA *ctx, int bits) return 0; } -void av_sha_update(AVSHA* ctx, const uint8_t* data, unsigned int len) +#if FF_API_CRYPTO_SIZE_T +void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len) +#else +void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len) +#endif { unsigned int i, j; diff --git a/libavutil/sha.h b/libavutil/sha.h index 86ea0b065ea..c0c7cd1af15 100644 --- a/libavutil/sha.h +++ b/libavutil/sha.h @@ -21,6 +21,7 @@ #ifndef AVUTIL_SHA_H #define AVUTIL_SHA_H +#include #include #include "attributes.h" @@ -51,11 +52,15 @@ int av_sha_init(struct AVSHA* context, int bits); /** * Update hash value. * - * @param context hash function context + * @param ctx hash function context * @param data input data to update hash with * @param len input data length */ -void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len); +#if FF_API_CRYPTO_SIZE_T +void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len); +#else +void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len); +#endif /** * Finish hashing and output digest value. diff --git a/libavutil/version.h b/libavutil/version.h index f1102312bac..3733fea8102 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -105,6 +105,9 @@ #ifndef FF_API_PKT_PTS #define FF_API_PKT_PTS (LIBAVUTIL_VERSION_MAJOR < 56) #endif +#ifndef FF_API_CRYPTO_SIZE_T +#define FF_API_CRYPTO_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 56) +#endif /** -- 2.39.2