* grub-core/lib/reed_solomon.c (init_powx): Set gf_powx_inv[0] just to

be deterministic.
	(syndroms): Compute 0 syndrom.
	(rs_recover): Use 0 syndrom.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-12-15 02:20:21 +01:00
parent 7a7f7cc9c3
commit ee9c2e7a97
2 changed files with 12 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2011-12-14 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/lib/reed_solomon.c (init_powx): Set gf_powx_inv[0] just to
be deterministic.
(syndroms): Compute 0 syndrom.
(rs_recover): Use 0 syndrom.
2011-12-14 Vladimir Serbinenko <phcoder@gmail.com> 2011-12-14 Vladimir Serbinenko <phcoder@gmail.com>
* include/grub/kernel.h (FOR_MODULES): Make it a bit faster. * include/grub/kernel.h (FOR_MODULES): Make it a bit faster.

View file

@ -89,6 +89,7 @@ init_powx (void)
int i; int i;
grub_uint8_t cur = 1; grub_uint8_t cur = 1;
gf_powx_inv[0] = 0;
for (i = 0; i < 255; i++) for (i = 0; i < 255; i++)
{ {
gf_powx[i] = cur; gf_powx[i] = cur;
@ -165,7 +166,8 @@ syndroms (gf_single_t *m, grub_size_t s, grub_size_t rs,
{ {
gf_single_t xn = 1; gf_single_t xn = 1;
unsigned i; unsigned i;
for (i = 0; i < rs; i++) sy[0] = pol_evaluate (m, s + rs - 1, xn);
for (i = 1; i < rs; i++)
{ {
if (xn & (1 << (GF_SIZE - 1))) if (xn & (1 << (GF_SIZE - 1)))
{ {
@ -344,7 +346,7 @@ rs_recover (gf_single_t *m, grub_size_t s, grub_size_t rs)
#endif #endif
for (j = 0; j < errnum; j++) for (j = 0; j < errnum; j++)
eq[j] = errpot[j]; eq[j] = 1;
eq[errnum] = sy[0]; eq[errnum] = sy[0];
for (i = 1; i < (int) rs; i++) for (i = 1; i < (int) rs; i++)
{ {
@ -530,7 +532,7 @@ main (int argc, char **argv)
out = fopen ("tst_rs.bin", "wb"); out = fopen ("tst_rs.bin", "wb");
fwrite (buf, 1, s + rs, out); fwrite (buf, 1, s + rs, out);
fclose (out); fclose (out);
#if 0 #if 1
grub_memset (buf + 512 * 15, 0, 512); grub_memset (buf + 512 * 15, 0, 512);
#endif #endif