From f3737e064849199071468eea8fe9fbf012d6ba7e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 29 Oct 1998 06:39:43 +0000 Subject: [PATCH] some minor optimisations --- flist.c | 4 +++- lib/mdfour.c | 21 ++++++++++++--------- rsync.h | 1 + 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/flist.c b/flist.c index 86bf4aa0..1a89a2fb 100644 --- a/flist.c +++ b/flist.c @@ -917,7 +917,9 @@ char *f_name(struct file_struct *f) n = (n+1)%10; if (f->dirname) { - slprintf(p, MAXPATHLEN-1, "%s/%s", f->dirname, f->basename); + strlcpy(p, f->dirname, MAXPATHLEN-1); + strlcat(p, "/", MAXPATHLEN-1); + strlcat(p, f->basename, MAXPATHLEN-1); } else { strlcpy(p, f->basename, MAXPATHLEN-1); } diff --git a/lib/mdfour.c b/lib/mdfour.c index 48dfc78f..c7aec27d 100644 --- a/lib/mdfour.c +++ b/lib/mdfour.c @@ -28,30 +28,34 @@ static struct mdfour *m; -static uint32 F(uint32 X, uint32 Y, uint32 Z) +static inline uint32 F(uint32 X, uint32 Y, uint32 Z) { return (X&Y) | ((~X)&Z); } -static uint32 G(uint32 X, uint32 Y, uint32 Z) +static inline uint32 G(uint32 X, uint32 Y, uint32 Z) { return (X&Y) | (X&Z) | (Y&Z); } -static uint32 H(uint32 X, uint32 Y, uint32 Z) +static inline uint32 H(uint32 X, uint32 Y, uint32 Z) { return X^Y^Z; } -static uint32 lshift(uint32 x, int s) +static inline uint32 lshift(uint32 x, int s) { +#ifdef LARGE_INT32 x &= 0xFFFFFFFF; return ((x<>(32-s)); +#else + return ((x<>(32-s))); +#endif } #define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s) -#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + (uint32)0x5A827999,s) -#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s) +#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + 0x5A827999,s) +#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + 0x6ED9EBA1,s) /* this applies md4 to 64 byte chunks */ static void mdfour64(uint32 *M) @@ -96,8 +100,10 @@ static void mdfour64(uint32 *M) A += AA; B += BB; C += CC; D += DD; +#ifdef LARGE_INT32 A &= 0xFFFFFFFF; B &= 0xFFFFFFFF; C &= 0xFFFFFFFF; D &= 0xFFFFFFFF; +#endif for (j=0;j<16;j++) X[j] = 0; @@ -157,9 +163,6 @@ static void mdfour_tail(unsigned char *in, int n) copy64(M, buf+64); mdfour64(M); } - - memset(buf, 0, 128); - copy64(M, buf); } void mdfour_update(struct mdfour *md, unsigned char *in, int n) diff --git a/rsync.h b/rsync.h index dc58e691..c7b43bdd 100644 --- a/rsync.h +++ b/rsync.h @@ -227,6 +227,7 @@ #else /* I hope this works */ #define int32 int +#define LARGE_INT32 #endif #endif -- 2.34.1