diff options
Diffstat (limited to 'fs/udf/crc.c')
-rw-r--r-- | fs/udf/crc.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/udf/crc.c b/fs/udf/crc.c index ef2bfaa19d75..ae3d49790941 100644 --- a/fs/udf/crc.c +++ b/fs/udf/crc.c | |||
@@ -79,8 +79,7 @@ static uint16_t crc_table[256] = { | |||
79 | * July 21, 1997 - Andrew E. Mileski | 79 | * July 21, 1997 - Andrew E. Mileski |
80 | * Adapted from OSTA-UDF(tm) 1.50 standard. | 80 | * Adapted from OSTA-UDF(tm) 1.50 standard. |
81 | */ | 81 | */ |
82 | uint16_t | 82 | uint16_t udf_crc(uint8_t * data, uint32_t size, uint16_t crc) |
83 | udf_crc(uint8_t *data, uint32_t size, uint16_t crc) | ||
84 | { | 83 | { |
85 | while (size--) | 84 | while (size--) |
86 | crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8); | 85 | crc = crc_table[(crc >> 8 ^ *(data++)) & 0xffU] ^ (crc << 8); |
@@ -112,7 +111,7 @@ int main(void) | |||
112 | return 0; | 111 | return 0; |
113 | } | 112 | } |
114 | 113 | ||
115 | #endif /* defined(TEST) */ | 114 | #endif /* defined(TEST) */ |
116 | 115 | ||
117 | /****************************************************************************/ | 116 | /****************************************************************************/ |
118 | #if defined(GENERATE) | 117 | #if defined(GENERATE) |
@@ -138,7 +137,7 @@ int main(int argc, char **argv) | |||
138 | 137 | ||
139 | /* Get the polynomial */ | 138 | /* Get the polynomial */ |
140 | sscanf(argv[1], "%lo", &poly); | 139 | sscanf(argv[1], "%lo", &poly); |
141 | if (poly & 0xffff0000U){ | 140 | if (poly & 0xffff0000U) { |
142 | fprintf(stderr, "polynomial is too large\en"); | 141 | fprintf(stderr, "polynomial is too large\en"); |
143 | exit(1); | 142 | exit(1); |
144 | } | 143 | } |
@@ -147,22 +146,22 @@ int main(int argc, char **argv) | |||
147 | 146 | ||
148 | /* Create a table */ | 147 | /* Create a table */ |
149 | printf("static unsigned short crc_table[256] = {\n"); | 148 | printf("static unsigned short crc_table[256] = {\n"); |
150 | for (n = 0; n < 256; n++){ | 149 | for (n = 0; n < 256; n++) { |
151 | if (n % 8 == 0) | 150 | if (n % 8 == 0) |
152 | printf("\t"); | 151 | printf("\t"); |
153 | crc = n << 8; | 152 | crc = n << 8; |
154 | for (i = 0; i < 8; i++){ | 153 | for (i = 0; i < 8; i++) { |
155 | if(crc & 0x8000U) | 154 | if (crc & 0x8000U) |
156 | crc = (crc << 1) ^ poly; | 155 | crc = (crc << 1) ^ poly; |
157 | else | 156 | else |
158 | crc <<= 1; | 157 | crc <<= 1; |
159 | crc &= 0xFFFFU; | 158 | crc &= 0xFFFFU; |
160 | } | 159 | } |
161 | if (n == 255) | 160 | if (n == 255) |
162 | printf("0x%04xU ", crc); | 161 | printf("0x%04xU ", crc); |
163 | else | 162 | else |
164 | printf("0x%04xU, ", crc); | 163 | printf("0x%04xU, ", crc); |
165 | if(n % 8 == 7) | 164 | if (n % 8 == 7) |
166 | printf("\n"); | 165 | printf("\n"); |
167 | } | 166 | } |
168 | printf("};\n"); | 167 | printf("};\n"); |
@@ -170,4 +169,4 @@ int main(int argc, char **argv) | |||
170 | return 0; | 169 | return 0; |
171 | } | 170 | } |
172 | 171 | ||
173 | #endif /* defined(GENERATE) */ | 172 | #endif /* defined(GENERATE) */ |