commit 41db082e8acc77ae4946aef8ab7343f4c925ce48
parent 2f47f829dacf79d21735e5c541cfe14dae24d33c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Mon, 15 Apr 2019 22:14:06 +0300
MD5: replaced needless checks with asserts
Diffstat:
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c
@@ -19,6 +19,7 @@
#include "md5.h"
#include "mhd_byteorder.h"
+#include "mhd_assert.h"
#define PUT_64BIT_LE(cp, value) do { \
(cp)[7] = (uint8_t)((value) >> 56); \
@@ -54,8 +55,7 @@ MD5Init (void *ctx_)
{
struct MD5Context *ctx = ctx_;
- if (!ctx)
- return;
+ mhd_assert (ctx != NULL);
ctx->count = 0;
ctx->state[0] = 0x67452301;
ctx->state[1] = 0xefcdab89;
@@ -74,8 +74,7 @@ MD5Pad (struct MD5Context *ctx)
uint8_t count[8];
size_t padlen;
- if (!ctx)
- return;
+ mhd_assert (ctx != NULL);
/* Convert count to 8 bytes in little endian order. */
PUT_64BIT_LE(count, ctx->count);
@@ -102,8 +101,8 @@ MD5Final (void *ctx_,
struct MD5Context *ctx = ctx_;
int i;
- if (!ctx || !digest)
- return;
+ mhd_assert (ctx != NULL);
+ mhd_assert (digest != NULL);
MD5Pad(ctx);
for (i = 0; i < 4; i++)
@@ -241,8 +240,8 @@ MD5Update (void *ctx_,
struct MD5Context *ctx = ctx_;
size_t have, need;
- if (!ctx || !input)
- return;
+ mhd_assert (ctx != NULL);
+ mhd_assert ((ctx != NULL) || (len == 0));
/* Check how many bytes we already have and how many more we need. */
have = (size_t)((ctx->count >> 3) & (MD5_BLOCK_SIZE - 1));
@@ -282,5 +281,4 @@ MD5Update (void *ctx_,
}
-
/* end of md5.c */