Commit 69c186ab6c6c635a5f381d23c3744d211e1722b0

Authored by animetosho
1 parent 4bddd5d8

Replace bzero() with memset()

Improves compiler compatibility
src/gf.c
... ... @@ -870,7 +870,7 @@ void gf_do_final_region_alignment(gf_region_data *rd)
870 870 void gf_multby_zero(void *dest, int bytes, int xor)
871 871 {
872 872 if (xor) return;
873   - bzero(dest, bytes);
  873 + memset(dest, 0, bytes);
874 874 return;
875 875 }
876 876  
... ...
src/gf_w16.c
... ... @@ -1884,7 +1884,7 @@ int gf_w16_log_zero_init(gf_t *gf)
1884 1884  
1885 1885 ltd->log_tbl[0] = (-GF_MULT_GROUP_SIZE) + 1;
1886 1886  
1887   - bzero(&(ltd->_antilog_tbl[0]), sizeof(ltd->_antilog_tbl));
  1887 + memset(&(ltd->_antilog_tbl[0]), 0, sizeof(ltd->_antilog_tbl));
1888 1888  
1889 1889 ltd->antilog_tbl = &(ltd->_antilog_tbl[GF_FIELD_SIZE * 2]);
1890 1890  
... ...
src/gf_w4.c
... ... @@ -433,8 +433,8 @@ int gf_w4_single_table_init(gf_t *gf)
433 433 h = (gf_internal_t *) gf->scratch;
434 434 std = (struct gf_single_table_data *)h->private;
435 435  
436   - bzero(std->mult, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
437   - bzero(std->div, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  436 + memset(std->mult, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  437 + memset(std->div, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
438 438  
439 439 for (a = 1; a < GF_FIELD_SIZE; a++) {
440 440 for (b = 1; b < GF_FIELD_SIZE; b++) {
... ... @@ -528,8 +528,8 @@ int gf_w4_double_table_init(gf_t *gf)
528 528 h = (gf_internal_t *) gf->scratch;
529 529 std = (struct gf_double_table_data *)h->private;
530 530  
531   - bzero(mult, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
532   - bzero(std->div, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  531 + memset(mult, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  532 + memset(std->div, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
533 533  
534 534 for (a = 1; a < GF_FIELD_SIZE; a++) {
535 535 for (b = 1; b < GF_FIELD_SIZE; b++) {
... ... @@ -538,7 +538,7 @@ int gf_w4_double_table_init(gf_t *gf)
538 538 std->div[prod][b] = a;
539 539 }
540 540 }
541   - bzero(std->mult, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE * GF_FIELD_SIZE);
  541 + memset(std->mult, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE * GF_FIELD_SIZE);
542 542 for (a = 0; a < GF_FIELD_SIZE; a++) {
543 543 for (b = 0; b < GF_FIELD_SIZE; b++) {
544 544 ab = mult[a][b];
... ... @@ -655,8 +655,8 @@ int gf_w4_quad_table_init(gf_t *gf)
655 655 h = (gf_internal_t *) gf->scratch;
656 656 std = (struct gf_quad_table_data *)h->private;
657 657  
658   - bzero(mult, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
659   - bzero(std->div, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  658 + memset(mult, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  659 + memset(std->div, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
660 660  
661 661 for (a = 1; a < GF_FIELD_SIZE; a++) {
662 662 for (b = 1; b < GF_FIELD_SIZE; b++) {
... ... @@ -711,8 +711,8 @@ int gf_w4_quad_table_lazy_init(gf_t *gf)
711 711 }
712 712 }
713 713  
714   - bzero(std->smult, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
715   - bzero(std->div, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  714 + memset(std->smult, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  715 + memset(std->div, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
716 716  
717 717 for (a = 1; a < GF_FIELD_SIZE; a++) {
718 718 loga = log_tbl[a];
... ...
src/gf_w8.c
... ... @@ -791,10 +791,10 @@ int gf_w8_log_init(gf_t *gf)
791 791 return 0;
792 792 }
793 793  
794   - if (h->mult_type == GF_MULT_LOG_ZERO) bzero(alt+510, 255);
  794 + if (h->mult_type == GF_MULT_LOG_ZERO) memset(alt+510, 0, 255);
795 795  
796 796 if (h->mult_type == GF_MULT_LOG_ZERO_EXT) {
797   - bzero(alt+512, 255);
  797 + memset(alt+512, 0, 255);
798 798 alt[512+512] = 0;
799 799 }
800 800  
... ... @@ -1092,8 +1092,8 @@ int gf_w8_split_init(gf_t *gf)
1092 1092 h = (gf_internal_t *) gf->scratch;
1093 1093 htd = (struct gf_w8_half_table_data *)h->private;
1094 1094  
1095   - bzero(htd->high, sizeof(uint8_t)*GF_FIELD_SIZE*GF_HALF_SIZE);
1096   - bzero(htd->low, sizeof(uint8_t)*GF_FIELD_SIZE*GF_HALF_SIZE);
  1095 + memset(htd->high, 0, sizeof(uint8_t)*GF_FIELD_SIZE*GF_HALF_SIZE);
  1096 + memset(htd->low, 0, sizeof(uint8_t)*GF_FIELD_SIZE*GF_HALF_SIZE);
1097 1097  
1098 1098 for (a = 1; a < GF_FIELD_SIZE; a++) {
1099 1099 for (b = 1; b < GF_HALF_SIZE; b++) {
... ... @@ -1147,25 +1147,25 @@ int gf_w8_table_init(gf_t *gf)
1147 1147 if (h->mult_type == GF_MULT_DEFAULT && use_simd) {
1148 1148 dd = (struct gf_w8_default_data *)h->private;
1149 1149 scase = 3;
1150   - bzero(dd->high, sizeof(uint8_t) * GF_FIELD_SIZE * GF_HALF_SIZE);
1151   - bzero(dd->low, sizeof(uint8_t) * GF_FIELD_SIZE * GF_HALF_SIZE);
1152   - bzero(dd->divtable, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
1153   - bzero(dd->multtable, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  1150 + memset(dd->high, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_HALF_SIZE);
  1151 + memset(dd->low, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_HALF_SIZE);
  1152 + memset(dd->divtable, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  1153 + memset(dd->multtable, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
1154 1154 } else if (h->mult_type == GF_MULT_DEFAULT ||
1155 1155 h->region_type == 0 || (h->region_type & GF_REGION_CAUCHY)) {
1156 1156 ftd = (struct gf_w8_single_table_data *)h->private;
1157   - bzero(ftd->divtable, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
1158   - bzero(ftd->multtable, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  1157 + memset(ftd->divtable, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  1158 + memset(ftd->multtable, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
1159 1159 scase = 0;
1160 1160 } else if (h->region_type == GF_REGION_DOUBLE_TABLE) {
1161 1161 dtd = (struct gf_w8_double_table_data *)h->private;
1162   - bzero(dtd->div, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
1163   - bzero(dtd->mult, sizeof(uint16_t) * GF_FIELD_SIZE * GF_FIELD_SIZE * GF_FIELD_SIZE);
  1162 + memset(dtd->div, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  1163 + memset(dtd->mult, 0, sizeof(uint16_t) * GF_FIELD_SIZE * GF_FIELD_SIZE * GF_FIELD_SIZE);
1164 1164 scase = 1;
1165 1165 } else if (h->region_type == (GF_REGION_DOUBLE_TABLE | GF_REGION_LAZY)) {
1166 1166 ltd = (struct gf_w8_double_table_lazy_data *)h->private;
1167   - bzero(ltd->div, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
1168   - bzero(ltd->smult, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  1167 + memset(ltd->div, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
  1168 + memset(ltd->smult, 0, sizeof(uint8_t) * GF_FIELD_SIZE * GF_FIELD_SIZE);
1169 1169 scase = 2;
1170 1170 } else {
1171 1171 fprintf(stderr, "Internal error in gf_w8_table_init\n");
... ... @@ -1246,7 +1246,7 @@ gf_w8_composite_multiply_region_alt(gf_t *gf, void *src, void *dest, gf_val_32_t
1246 1246  
1247 1247 if (val == 0) {
1248 1248 if (xor) return;
1249   - bzero(dest, bytes);
  1249 + memset(dest, 0, bytes);
1250 1250 return;
1251 1251 }
1252 1252  
... ... @@ -1387,7 +1387,7 @@ gf_w8_composite_multiply_region(gf_t *gf, void *src, void *dest, gf_val_32_t val
1387 1387  
1388 1388 if (val == 0) {
1389 1389 if (xor) return;
1390   - bzero(dest, bytes);
  1390 + memset(dest, 0, bytes);
1391 1391 return;
1392 1392 }
1393 1393  
... ...