diff --git a/Examples/reed_sol_01.c b/Examples/reed_sol_01.c index ff7f477..1de63c7 100644 --- a/Examples/reed_sol_01.c +++ b/Examples/reed_sol_01.c @@ -37,12 +37,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ - -/* - revised by S. Simmerman - 2/25/08 -*/ +/* Part of this code was revised by Scott Simmerman 2/25/08 */ + #include #include #include @@ -56,8 +53,8 @@ usage(char *s) fprintf(stderr, "usage: reed_sol_01 k m w - Does a simple Reed-Solomon coding example in GF(2^w).\n"); fprintf(stderr, " \n"); fprintf(stderr, " w must be 8, 16 or 32. k+m must be <= 2^w. It sets up a classic\n"); - fprintf(stderr, " Vandermonde-based distribution matrix and encodes k devices of\n"); - fprintf(stderr, " %d bytes each with it. Then it decodes.\n", sizeof(long)); + fprintf(stderr, " Vandermonde-based generator matrix and encodes k devices of\n"); + fprintf(stderr, " %ld bytes each with it. Then it decodes.\n", sizeof(long)); fprintf(stderr, " \n"); fprintf(stderr, "This demonstrates: jerasure_matrix_encode()\n"); fprintf(stderr, " jerasure_matrix_decode()\n"); @@ -111,6 +108,7 @@ int main(int argc, char **argv) int k, w, i, j, m; int *matrix; char **data, **coding; + unsigned char uc; int *erasures, *erased; int *decoding_matrix, *dm_ids; @@ -130,8 +128,10 @@ int main(int argc, char **argv) data = talloc(char *, k); for (i = 0; i < k; i++) { data[i] = talloc(char, sizeof(long)); - l = lrand48(); - memcpy(data[i], &l, sizeof(long)); + for (j = 0; j < sizeof(long); j++) { + uc = lrand48()%256; + data[i][j] = (char) uc; + } } coding = talloc(char *, m); diff --git a/Examples/reed_sol_03.c b/Examples/reed_sol_03.c index 2070aa5..49321d9 100644 --- a/Examples/reed_sol_03.c +++ b/Examples/reed_sol_03.c @@ -57,7 +57,7 @@ usage(char *s) fprintf(stderr, " \n"); fprintf(stderr, " w must be 8, 16 or 32. k+2 must be <= 2^w. It sets up a classic\n"); fprintf(stderr, " RAID-6 coding matrix based on Anvin's optimization and encodes\n"); - fprintf(stderr, " %d-byte devices with it. Then it decodes.\n", sizeof(long)); + fprintf(stderr, " %ld-byte devices with it. Then it decodes.\n", sizeof(long)); fprintf(stderr, " \n"); fprintf(stderr, "This demonstrates: reed_sol_r6_encode()\n"); fprintf(stderr, " reed_sol_r6_coding_matrix()\n"); @@ -109,6 +109,7 @@ static void print_data_and_coding(int k, int m, int w, int size, int main(int argc, char **argv) { long l; + unsigned char uc; int k, w, i, j, m; int *matrix; char **data, **coding; @@ -123,7 +124,7 @@ int main(int argc, char **argv) matrix = reed_sol_r6_coding_matrix(k, w); - printf("Last 2 rows of the Distribution Matrix:\n\n"); + printf("Last 2 rows of the Generator Matrix:\n\n"); jerasure_print_matrix(matrix, m, k, w); printf("\n"); @@ -131,8 +132,10 @@ int main(int argc, char **argv) data = talloc(char *, k); for (i = 0; i < k; i++) { data[i] = talloc(char, sizeof(long)); - l = lrand48(); - memcpy(data[i], &l, sizeof(long)); + for (j = 0; j < sizeof(long); j++) { + uc = lrand48()%256; + data[i][j] = (char) uc; + } } coding = talloc(char *, m); diff --git a/Examples/reed_sol_hard_time_gf.c b/Examples/reed_sol_hard_time_gf.c index e3cf6a2..e214956 100644 --- a/Examples/reed_sol_hard_time_gf.c +++ b/Examples/reed_sol_hard_time_gf.c @@ -234,7 +234,7 @@ timer_split (const double *t) usage(char *s) { - fprintf(stderr, "usage: reed_sol_hard_test_gf k m w [additional GF args]- Test and time Reed-Solomon in a particular GF(2^w).\n"); + fprintf(stderr, "usage: reed_sol_hard_test_gf k m w iterations bufsize [additional GF args]- Test and time Reed-Solomon in a particular GF(2^w).\n"); fprintf(stderr, " \n"); fprintf(stderr, " w must be 8, 16 or 32. k+m must be <= 2^w.\n"); fprintf(stderr, " See the README for information on the additional GF args.\n"); diff --git a/Examples/reed_sol_time_gf.c b/Examples/reed_sol_time_gf.c index 6c9d54d..36645c8 100644 --- a/Examples/reed_sol_time_gf.c +++ b/Examples/reed_sol_time_gf.c @@ -81,7 +81,7 @@ timer_split (const double *t) usage(char *s) { - fprintf(stderr, "usage: reed_sol_test_gf k m w [additional GF args]- Test and time Reed-Solomon in a particular GF(2^w).\n"); + fprintf(stderr, "usage: reed_sol_time_gf k m w iterations bufsize [additional GF args]- Test and time Reed-Solomon in a particular GF(2^w).\n"); fprintf(stderr, " \n"); fprintf(stderr, " w must be 8, 16 or 32. k+m must be <= 2^w.\n"); fprintf(stderr, " See the README for information on the additional GF args.\n");