History

crypto: consistently use size_t as type for length parameters

size_t is the correct type to use for sizes.

Diego Biurrun committed 9 years ago

Commit e435beb1 parent f1af37b6 files · +34 −4Browse files

Unified · Split

6 files
  1. doc/APIchanges +4 −0
  2. libavutil/md5.c +8 −0
  3. libavutil/md5.h +7 −1
  4. libavutil/sha.c +5 −1
  5. libavutil/sha.h +7 −2
  6. libavutil/version.h +3 −0
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2015-08-28 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
16+2016-xx-xx - xxxxxxx
17+ Change av_sha_update() and av_md5_sum()/av_md5_update() length
18+ parameter type to size_t at next major bump.
19+
1620 2016-xx-xx - xxxxxxx - lavc 57.29.0 - avcodec.h
1721 Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping
1822 information from containers.
libavutil/md5.c+8−0
@@ -146,7 +146,11 @@ void av_md5_init(AVMD5 *ctx) · 145 unmodified lines
146146 ctx->ABCD[3] = 0x67452301;
147147 }
148148
149+#if FF_API_CRYPTO_SIZE_T
149150 void av_md5_update(AVMD5 *ctx, const uint8_t *src, const int len)
151+#else
152+void av_md5_update(AVMD5 *ctx, const uint8_t *src, size_t len)
153+#endif
150154 {
151155 int i, j;
152156
@@ -177,7 +181,11 @@ void av_md5_final(AVMD5 *ctx, uint8_t *dst) · 24 unmodified lines
177181 AV_WL32(dst + 4 * i, ctx->ABCD[3 - i]);
178182 }
179183
184+#if FF_API_CRYPTO_SIZE_T
180185 void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len)
186+#else
187+void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len)
188+#endif
181189 {
182190 AVMD5 ctx;
183191
libavutil/md5.h+7−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #ifndef AVUTIL_MD5_H
2222 #define AVUTIL_MD5_H
2323
24+#include <stddef.h>
2425 #include <stdint.h>
2526
2627 #include "attributes.h"
@@ -36,9 +37,14 @@ struct AVMD5; · 9 unmodified lines
3637
3738 struct AVMD5 *av_md5_alloc(void);
3839 void av_md5_init(struct AVMD5 *ctx);
39−void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
4040 void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
41+#if FF_API_CRYPTO_SIZE_T
42+void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len);
4143 void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
44+#else
45+void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, size_t len);
46+void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len);
47+#endif
4248
4349 /**
4450 * @}
libavutil/sha.c+5−1
@@ -290,7 +290,11 @@ av_cold int av_sha_init(AVSHA *ctx, int bits) · 289 unmodified lines
290290 return 0;
291291 }
292292
293−void av_sha_update(AVSHA* ctx, const uint8_t* data, unsigned int len)
293+#if FF_API_CRYPTO_SIZE_T
294+void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len)
295+#else
296+void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len)
297+#endif
294298 {
295299 unsigned int i, j;
296300
libavutil/sha.h+7−2
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #ifndef AVUTIL_SHA_H
2222 #define AVUTIL_SHA_H
2323
24+#include <stddef.h>
2425 #include <stdint.h>
2526
2627 #include "attributes.h"
@@ -51,11 +52,15 @@ int av_sha_init(struct AVSHA* context, int bits); · 24 unmodified lines
5152 /**
5253 * Update hash value.
5354 *
54− * @param context hash function context
55+ * @param ctx hash function context
5556 * @param data input data to update hash with
5657 * @param len input data length
5758 */
58−void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len);
59+#if FF_API_CRYPTO_SIZE_T
60+void av_sha_update(struct AVSHA *ctx, const uint8_t *data, unsigned int len);
61+#else
62+void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len);
63+#endif
5964
6065 /**
6166 * Finish hashing and output digest value.
libavutil/version.h+3−0
@@ -105,6 +105,9 @@ · 104 unmodified lines
105105 #ifndef FF_API_PKT_PTS
106106 #define FF_API_PKT_PTS (LIBAVUTIL_VERSION_MAJOR < 56)
107107 #endif
108+#ifndef FF_API_CRYPTO_SIZE_T
109+#define FF_API_CRYPTO_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 56)
110+#endif
108111
109112
110113 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t