aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/hashes.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-07-12 23:21:28 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-12 23:21:28 -0400
commitbd4c625c061c2a38568d0add3478f59172455159 (patch)
tree1c44a17c55bce2ee7ad5ea3d15a208ecc0955f74 /fs/reiserfs/hashes.c
parent7fa94c8868edfef8cb6a201fcc9a5078b7b961da (diff)
reiserfs: run scripts/Lindent on reiserfs code
This was a pure indentation change, using: scripts/Lindent fs/reiserfs/*.c include/linux/reiserfs_*.h to make reiserfs match the regular Linux indentation style. As Jeff Mahoney <jeffm@suse.com> writes: The ReiserFS code is a mix of a number of different coding styles, sometimes different even from line-to-line. Since the code has been relatively stable for quite some time and there are few outstanding patches to be applied, it is time to reformat the code to conform to the Linux style standard outlined in Documentation/CodingStyle. This patch contains the result of running scripts/Lindent against fs/reiserfs/*.c and include/linux/reiserfs_*.h. There are places where the code can be made to look better, but I'd rather keep those patches separate so that there isn't a subtle by-hand hand accident in the middle of a huge patch. To be clear: This patch is reformatting *only*. A number of patches may follow that continue to make the code more consistent with the Linux coding style. Hans wasn't particularly enthusiastic about these patches, but said he wouldn't really oppose them either. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/reiserfs/hashes.c')
-rw-r--r--fs/reiserfs/hashes.c193
1 files changed, 83 insertions, 110 deletions
diff --git a/fs/reiserfs/hashes.c b/fs/reiserfs/hashes.c
index 08d0508c2d39..37c1306eb9b7 100644
--- a/fs/reiserfs/hashes.c
+++ b/fs/reiserfs/hashes.c
@@ -22,7 +22,6 @@
22#include <asm/types.h> 22#include <asm/types.h>
23#include <asm/bug.h> 23#include <asm/bug.h>
24 24
25
26#define DELTA 0x9E3779B9 25#define DELTA 0x9E3779B9
27#define FULLROUNDS 10 /* 32 is overkill, 16 is strong crypto */ 26#define FULLROUNDS 10 /* 32 is overkill, 16 is strong crypto */
28#define PARTROUNDS 6 /* 6 gets complete mixing */ 27#define PARTROUNDS 6 /* 6 gets complete mixing */
@@ -48,105 +47,75 @@
48 h1 += b1; \ 47 h1 += b1; \
49 } while(0) 48 } while(0)
50 49
51
52u32 keyed_hash(const signed char *msg, int len) 50u32 keyed_hash(const signed char *msg, int len)
53{ 51{
54 u32 k[] = { 0x9464a485, 0x542e1a94, 0x3e846bff, 0xb75bcfc3}; 52 u32 k[] = { 0x9464a485, 0x542e1a94, 0x3e846bff, 0xb75bcfc3 };
55 53
56 u32 h0 = k[0], h1 = k[1]; 54 u32 h0 = k[0], h1 = k[1];
57 u32 a, b, c, d; 55 u32 a, b, c, d;
58 u32 pad; 56 u32 pad;
59 int i; 57 int i;
60
61 // assert(len >= 0 && len < 256);
62 58
63 pad = (u32)len | ((u32)len << 8); 59 // assert(len >= 0 && len < 256);
60
61 pad = (u32) len | ((u32) len << 8);
64 pad |= pad << 16; 62 pad |= pad << 16;
65 63
66 while(len >= 16) 64 while (len >= 16) {
67 { 65 a = (u32) msg[0] |
68 a = (u32)msg[ 0] | 66 (u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
69 (u32)msg[ 1] << 8 | 67 b = (u32) msg[4] |
70 (u32)msg[ 2] << 16| 68 (u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
71 (u32)msg[ 3] << 24; 69 c = (u32) msg[8] |
72 b = (u32)msg[ 4] | 70 (u32) msg[9] << 8 |
73 (u32)msg[ 5] << 8 | 71 (u32) msg[10] << 16 | (u32) msg[11] << 24;
74 (u32)msg[ 6] << 16| 72 d = (u32) msg[12] |
75 (u32)msg[ 7] << 24; 73 (u32) msg[13] << 8 |
76 c = (u32)msg[ 8] | 74 (u32) msg[14] << 16 | (u32) msg[15] << 24;
77 (u32)msg[ 9] << 8 | 75
78 (u32)msg[10] << 16|
79 (u32)msg[11] << 24;
80 d = (u32)msg[12] |
81 (u32)msg[13] << 8 |
82 (u32)msg[14] << 16|
83 (u32)msg[15] << 24;
84
85 TEACORE(PARTROUNDS); 76 TEACORE(PARTROUNDS);
86 77
87 len -= 16; 78 len -= 16;
88 msg += 16; 79 msg += 16;
89 } 80 }
90 81
91 if (len >= 12) 82 if (len >= 12) {
92 { 83 a = (u32) msg[0] |
93 a = (u32)msg[ 0] | 84 (u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
94 (u32)msg[ 1] << 8 | 85 b = (u32) msg[4] |
95 (u32)msg[ 2] << 16| 86 (u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
96 (u32)msg[ 3] << 24; 87 c = (u32) msg[8] |
97 b = (u32)msg[ 4] | 88 (u32) msg[9] << 8 |
98 (u32)msg[ 5] << 8 | 89 (u32) msg[10] << 16 | (u32) msg[11] << 24;
99 (u32)msg[ 6] << 16|
100 (u32)msg[ 7] << 24;
101 c = (u32)msg[ 8] |
102 (u32)msg[ 9] << 8 |
103 (u32)msg[10] << 16|
104 (u32)msg[11] << 24;
105 90
106 d = pad; 91 d = pad;
107 for(i = 12; i < len; i++) 92 for (i = 12; i < len; i++) {
108 {
109 d <<= 8; 93 d <<= 8;
110 d |= msg[i]; 94 d |= msg[i];
111 } 95 }
112 } 96 } else if (len >= 8) {
113 else if (len >= 8) 97 a = (u32) msg[0] |
114 { 98 (u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
115 a = (u32)msg[ 0] | 99 b = (u32) msg[4] |
116 (u32)msg[ 1] << 8 | 100 (u32) msg[5] << 8 | (u32) msg[6] << 16 | (u32) msg[7] << 24;
117 (u32)msg[ 2] << 16|
118 (u32)msg[ 3] << 24;
119 b = (u32)msg[ 4] |
120 (u32)msg[ 5] << 8 |
121 (u32)msg[ 6] << 16|
122 (u32)msg[ 7] << 24;
123 101
124 c = d = pad; 102 c = d = pad;
125 for(i = 8; i < len; i++) 103 for (i = 8; i < len; i++) {
126 {
127 c <<= 8; 104 c <<= 8;
128 c |= msg[i]; 105 c |= msg[i];
129 } 106 }
130 } 107 } else if (len >= 4) {
131 else if (len >= 4) 108 a = (u32) msg[0] |
132 { 109 (u32) msg[1] << 8 | (u32) msg[2] << 16 | (u32) msg[3] << 24;
133 a = (u32)msg[ 0] |
134 (u32)msg[ 1] << 8 |
135 (u32)msg[ 2] << 16|
136 (u32)msg[ 3] << 24;
137 110
138 b = c = d = pad; 111 b = c = d = pad;
139 for(i = 4; i < len; i++) 112 for (i = 4; i < len; i++) {
140 {
141 b <<= 8; 113 b <<= 8;
142 b |= msg[i]; 114 b |= msg[i];
143 } 115 }
144 } 116 } else {
145 else
146 {
147 a = b = c = d = pad; 117 a = b = c = d = pad;
148 for(i = 0; i < len; i++) 118 for (i = 0; i < len; i++) {
149 {
150 a <<= 8; 119 a <<= 8;
151 a |= msg[i]; 120 a |= msg[i];
152 } 121 }
@@ -155,55 +124,59 @@ u32 keyed_hash(const signed char *msg, int len)
155 TEACORE(FULLROUNDS); 124 TEACORE(FULLROUNDS);
156 125
157/* return 0;*/ 126/* return 0;*/
158 return h0^h1; 127 return h0 ^ h1;
159} 128}
160 129
161/* What follows in this file is copyright 2000 by Hans Reiser, and the 130/* What follows in this file is copyright 2000 by Hans Reiser, and the
162 * licensing of what follows is governed by reiserfs/README */ 131 * licensing of what follows is governed by reiserfs/README */
163 132
164u32 yura_hash (const signed char *msg, int len) 133u32 yura_hash(const signed char *msg, int len)
165{ 134{
166 int j, pow; 135 int j, pow;
167 u32 a, c; 136 u32 a, c;
168 int i; 137 int i;
169 138
170 for (pow=1,i=1; i < len; i++) pow = pow * 10; 139 for (pow = 1, i = 1; i < len; i++)
171 140 pow = pow * 10;
172 if (len == 1) 141
173 a = msg[0]-48; 142 if (len == 1)
174 else 143 a = msg[0] - 48;
175 a = (msg[0] - 48) * pow; 144 else
176 145 a = (msg[0] - 48) * pow;
177 for (i=1; i < len; i++) { 146
178 c = msg[i] - 48; 147 for (i = 1; i < len; i++) {
179 for (pow=1,j=i; j < len-1; j++) pow = pow * 10; 148 c = msg[i] - 48;
180 a = a + c * pow; 149 for (pow = 1, j = i; j < len - 1; j++)
181 } 150 pow = pow * 10;
182 151 a = a + c * pow;
183 for (; i < 40; i++) { 152 }
184 c = '0' - 48; 153
185 for (pow=1,j=i; j < len-1; j++) pow = pow * 10; 154 for (; i < 40; i++) {
186 a = a + c * pow; 155 c = '0' - 48;
187 } 156 for (pow = 1, j = i; j < len - 1; j++)
188 157 pow = pow * 10;
189 for (; i < 256; i++) { 158 a = a + c * pow;
190 c = i; 159 }
191 for (pow=1,j=i; j < len-1; j++) pow = pow * 10; 160
192 a = a + c * pow; 161 for (; i < 256; i++) {
193 } 162 c = i;
194 163 for (pow = 1, j = i; j < len - 1; j++)
195 a = a << 7; 164 pow = pow * 10;
196 return a; 165 a = a + c * pow;
166 }
167
168 a = a << 7;
169 return a;
197} 170}
198 171
199u32 r5_hash (const signed char *msg, int len) 172u32 r5_hash(const signed char *msg, int len)
200{ 173{
201 u32 a=0; 174 u32 a = 0;
202 while(*msg) { 175 while (*msg) {
203 a += *msg << 4; 176 a += *msg << 4;
204 a += *msg >> 4; 177 a += *msg >> 4;
205 a *= 11; 178 a *= 11;
206 msg++; 179 msg++;
207 } 180 }
208 return a; 181 return a;
209} 182}