more nhmd4.c formatting
Insert a space between cast operator and target. For 'x | y' expression spanning multiple lines, split with bitwise OR operator at the beginning of second line instead at the end of first. I changed a macro that was expanding to 'expr_1; expr_2' into '(expr_1, expr_2)'. Both expressions modify arg 'a' which would be a no-no within a single expression, but the comma operator provides a sequence point that guarantees that the first expression will be fully evaluated with side-effects--assignment to 'a'--completed before the second one starts, making both assignments be well defined.
This commit is contained in:
+12
-10
@@ -40,11 +40,14 @@ static const unsigned char *body(struct nhmd4_context *,
|
|||||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The MD4 transformation for all four rounds.
|
* STEP: the MD4 transformation used for all four rounds.
|
||||||
|
* (Joining two expressions with the comma operator provides a sequence
|
||||||
|
* point. C89/C90 and later guarantee that the first will be fully complete
|
||||||
|
* before the second starts, making both assignments to 'a' be well defined.)
|
||||||
*/
|
*/
|
||||||
#define STEP(f, a, b, c, d, x, s) \
|
#define STEP(f, a, b, c, d, x, s) \
|
||||||
(a) += f((b), (c), (d)) + (x); \
|
(((a) += f((b), (c), (d)) + (x)), \
|
||||||
(a) = ((a) << (s)) | ((a) >> (32 - (s)))
|
((a) = ((a) << (s)) | ((a) >> (32 - (s)))))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SET reads 4 input bytes in little-endian byte order and stores them
|
* SET reads 4 input bytes in little-endian byte order and stores them
|
||||||
@@ -55,17 +58,16 @@ static const unsigned char *body(struct nhmd4_context *,
|
|||||||
* doesn't work.
|
* doesn't work.
|
||||||
*/
|
*/
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
#define SET(n) (*(const quint32 *)&ptr[(n) * 4])
|
#define SET(n) (*(const quint32 *) &ptr[(n) * 4])
|
||||||
#define GET(n) SET(n)
|
#define GET(n) SET(n)
|
||||||
#else
|
#else
|
||||||
#define SET(n) \
|
#define SET(n) \
|
||||||
(ctx->block[(n)] = \
|
(ctx->block[(n)] = \
|
||||||
(quint32)ptr[(n) * 4] | \
|
((quint32) ptr[(n) * 4] \
|
||||||
((quint32)ptr[(n) * 4 + 1] << 8) | \
|
| ((quint32) ptr[(n) * 4 + 1] << 8) \
|
||||||
((quint32)ptr[(n) * 4 + 2] << 16) | \
|
| ((quint32) ptr[(n) * 4 + 2] << 16) \
|
||||||
((quint32)ptr[(n) * 4 + 3] << 24))
|
| ((quint32) ptr[(n) * 4 + 3] << 24)))
|
||||||
#define GET(n) \
|
#define GET(n) (ctx->block[(n)])
|
||||||
(ctx->block[(n)])
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user