Commit a0ae760ed39c54e9ed63dae1e65dfb31dff44260

Authored by Loic Dachary
1 parent 564f019f
Exists in master and in 2 other branches v2, v3

prefer uint8_t to char in pointer arithmetic

Signed-off-by: Loic Dachary <loic@dachary.org>
src/gf.c
... ... @@ -482,7 +482,7 @@ int gf_init_hard(gf_t *gf, int w, int mult_type,
482 482 h->arg2 = arg2;
483 483 h->base_gf = base_gf;
484 484 h->private = (void *) gf->scratch;
485   - h->private = (char*)h->private + (sizeof(gf_internal_t));
  485 + h->private = (uint8_t *)h->private + (sizeof(gf_internal_t));
486 486 gf->extract_word.w32 = NULL;
487 487  
488 488 switch(w) {
... ... @@ -687,8 +687,8 @@ static void gf_slow_multiply_region(gf_region_data *rd, void *src, void *dest, v
687 687 fprintf(stderr, "Error: gf_slow_multiply_region: w=%d not implemented.\n", h->w);
688 688 exit(1);
689 689 }
690   - src = (char*)src + wb;
691   - dest = (char*)dest + wb;
  690 + src = (uint8_t *)src + wb;
  691 + dest = (uint8_t *)dest + wb;
692 692 }
693 693 }
694 694  
... ... @@ -803,8 +803,8 @@ void gf_set_region_data(gf_region_data *rd,
803 803  
804 804 rd->s_start = src;
805 805 rd->d_start = dest;
806   - rd->s_top = (char*)src + bytes;
807   - rd->d_top = (char*)src + bytes;
  806 + rd->s_top = (uint8_t *)src + bytes;
  807 + rd->d_top = (uint8_t *)src + bytes;
808 808 return;
809 809 }
810 810  
... ... @@ -833,12 +833,12 @@ void gf_set_region_data(gf_region_data *rd,
833 833  
834 834 uls %= a;
835 835 if (uls != 0) uls = (a-uls);
836   - rd->s_start = (char*)rd->src + uls;
837   - rd->d_start = (char*)rd->dest + uls;
  836 + rd->s_start = (uint8_t *)rd->src + uls;
  837 + rd->d_start = (uint8_t *)rd->dest + uls;
838 838 bytes -= uls;
839 839 bytes -= (bytes % align);
840   - rd->s_top = (char*)rd->s_start + bytes;
841   - rd->d_top = (char*)rd->d_start + bytes;
  840 + rd->s_top = (uint8_t *)rd->s_start + bytes;
  841 + rd->d_top = (uint8_t *)rd->d_start + bytes;
842 842  
843 843 }
844 844  
... ... @@ -849,7 +849,7 @@ void gf_do_initial_region_alignment(gf_region_data *rd)
849 849  
850 850 void gf_do_final_region_alignment(gf_region_data *rd)
851 851 {
852   - gf_slow_multiply_region(rd, rd->s_top, rd->d_top, (char*)rd->src+rd->bytes);
  852 + gf_slow_multiply_region(rd, rd->s_top, rd->d_top, (uint8_t *)rd->src+rd->bytes);
853 853 }
854 854  
855 855 void gf_multby_zero(void *dest, int bytes, int xor)
... ... @@ -1018,7 +1018,7 @@ static void gf_unaligned_xor(void *src, void *dest, int bytes)
1018 1018 }
1019 1019  
1020 1020 d8 = (uint8_t *) d64;
1021   - while (d8 < (uint8_t *) ((char*)dest+bytes)) {
  1021 + while (d8 < (uint8_t *) ((uint8_t *)dest+bytes)) {
1022 1022 *d8 ^= *s8;
1023 1023 d8++;
1024 1024 s8++;
... ...
src/gf_general.c
... ... @@ -326,7 +326,7 @@ void gf_general_set_up_single_timing_test(int w, void *ra, void *rb, int size)
326 326 uint64_t *r64;
327 327 int i;
328 328  
329   - top = (char*)rb+size;
  329 + top = (uint8_t *)rb+size;
330 330  
331 331 /* If w is 8, 16, 32, 64 or 128, fill the regions with random bytes.
332 332 However, don't allow for zeros in rb, because that will screw up
... ... @@ -365,7 +365,7 @@ void gf_general_set_up_single_timing_test(int w, void *ra, void *rb, int size)
365 365 r64[1] = g.w128[1];
366 366 break;
367 367 }
368   - rb = (char*)rb + (w/8);
  368 + rb = (uint8_t *)rb + (w/8);
369 369 }
370 370 } else if (w == 4) {
371 371 r8a = (uint8_t *) ra;
... ... @@ -407,7 +407,7 @@ int gf_general_do_single_timing_test(gf_t *gf, void *ra, void *rb, int size, cha
407 407  
408 408 h = (gf_internal_t *) gf->scratch;
409 409 w = h->w;
410   - top = (char*)ra + size;
  410 + top = (uint8_t *)ra + size;
411 411  
412 412 if (w == 8 || w == 4) {
413 413 r8a = (uint8_t *) ra;
... ...
src/gf_w128.c
... ... @@ -620,7 +620,7 @@ gf_w128_split_4_128_sse_multiply_region(gf_t *gf, void *src, void *dest, gf_val_
620 620  
621 621 /* Doing this instead of gf_do_initial_region_alignment() because that doesn't hold 128-bit vals */
622 622  
623   - gf_w128_multiply_region_from_single(gf, src, dest, val, ((char*)rd.s_start-(char*)src), xor);
  623 + gf_w128_multiply_region_from_single(gf, src, dest, val, ((uint8_t *)rd.s_start-(uint8_t *)src), xor);
624 624  
625 625 s64 = (uint64_t *) rd.s_start;
626 626 d64 = (uint64_t *) rd.d_start;
... ... @@ -690,7 +690,7 @@ gf_w128_split_4_128_sse_multiply_region(gf_t *gf, void *src, void *dest, gf_val_
690 690  
691 691 /* Doing this instead of gf_do_final_region_alignment() because that doesn't hold 128-bit vals */
692 692  
693   - gf_w128_multiply_region_from_single(gf, rd.s_top, rd.d_top, val, ((char*)src+bytes)-(char*)rd.s_top, xor);
  693 + gf_w128_multiply_region_from_single(gf, rd.s_top, rd.d_top, val, ((uint8_t *)src+bytes)-(uint8_t *)rd.s_top, xor);
694 694 }
695 695 #endif
696 696  
... ... @@ -720,7 +720,7 @@ gf_w128_split_4_128_sse_altmap_multiply_region(gf_t *gf, void *src, void *dest,
720 720  
721 721 /* Doing this instead of gf_do_initial_region_alignment() because that doesn't hold 128-bit vals */
722 722  
723   - gf_w128_multiply_region_from_single(gf, src, dest, val, ((char*)rd.s_start-(char*)src), xor);
  723 + gf_w128_multiply_region_from_single(gf, src, dest, val, ((uint8_t *)rd.s_start-(uint8_t *)src), xor);
724 724  
725 725 s64 = (uint64_t *) rd.s_start;
726 726 d64 = (uint64_t *) rd.d_start;
... ... @@ -800,7 +800,7 @@ gf_w128_split_4_128_sse_altmap_multiply_region(gf_t *gf, void *src, void *dest,
800 800 }
801 801 /* Doing this instead of gf_do_final_region_alignment() because that doesn't hold 128-bit vals */
802 802  
803   - gf_w128_multiply_region_from_single(gf, rd.s_top, rd.d_top, val, ((char*)src+bytes)-(char*)rd.s_top, xor);
  803 + gf_w128_multiply_region_from_single(gf, rd.s_top, rd.d_top, val, ((uint8_t *)src+bytes)-(uint8_t *)rd.s_top, xor);
804 804 }
805 805 #endif
806 806  
... ... @@ -1382,7 +1382,7 @@ gf_w128_composite_multiply_region_alt(gf_t *gf, void *src, void *dest, gf_val_12
1382 1382 gf_region_data rd;
1383 1383  
1384 1384 gf_set_region_data(&rd, gf, src, dest, bytes, 0, xor, 64);
1385   - gf_w128_multiply_region_from_single(gf, src, dest, val, ((char*)rd.s_start-(char*)src), xor);
  1385 + gf_w128_multiply_region_from_single(gf, src, dest, val, ((uint8_t *)rd.s_start-(uint8_t *)src), xor);
1386 1386  
1387 1387 slow = (uint8_t *) rd.s_start;
1388 1388 dlow = (uint8_t *) rd.d_start;
... ... @@ -1398,7 +1398,7 @@ gf_w128_composite_multiply_region_alt(gf_t *gf, void *src, void *dest, gf_val_12
1398 1398 base_gf->multiply_region.w64(base_gf, shigh, dhigh, base_gf->multiply.w64(base_gf, h->prim_poly, val1
1399 1399 ), sub_reg_size, 1);
1400 1400  
1401   - gf_w128_multiply_region_from_single(gf, rd.s_top, rd.d_top, val, ((char*)src+bytes)-(char*)rd.s_top, xor);
  1401 + gf_w128_multiply_region_from_single(gf, rd.s_top, rd.d_top, val, ((uint8_t *)src+bytes)-(uint8_t *)rd.s_top, xor);
1402 1402 }
1403 1403  
1404 1404  
... ... @@ -1584,7 +1584,7 @@ int gf_w128_group_init(gf_t *gf)
1584 1584 g_r = scratch->arg2;
1585 1585 size_r = (1 << g_r);
1586 1586  
1587   - gt->r_table = (gf_val_128_t)((char*)scratch->private + (2 * sizeof(uint64_t *)));
  1587 + gt->r_table = (gf_val_128_t)((uint8_t *)scratch->private + (2 * sizeof(uint64_t *)));
1588 1588 gt->m_table = gt->r_table + size_r;
1589 1589 gt->m_table[2] = 0;
1590 1590 gt->m_table[3] = 0;
... ...
src/gf_w8.c
... ... @@ -1319,13 +1319,13 @@ gf_w8_composite_multiply_region_alt(gf_t *gf, void *src, void *dest, gf_val_32_t
1319 1319 gf_set_region_data(&rd, gf, src, dest, bytes, val, xor, 32);
1320 1320 gf_do_initial_region_alignment(&rd);
1321 1321  
1322   - sub_reg_size = ((char*)rd.d_top - (char*)rd.d_start) / 2;
  1322 + sub_reg_size = ((uint8_t *)rd.d_top - (uint8_t *)rd.d_start) / 2;
1323 1323  
1324 1324 base_gf->multiply_region.w32(base_gf, rd.s_start, rd.d_start, val0, sub_reg_size, xor);
1325   - base_gf->multiply_region.w32(base_gf, (char*)rd.s_start+sub_reg_size, rd.d_start, val1, sub_reg_size, 1);
1326   - base_gf->multiply_region.w32(base_gf, rd.s_start, (char*)rd.d_start+sub_reg_size, val1, sub_reg_size, xor);
1327   - base_gf->multiply_region.w32(base_gf, (char*)rd.s_start+sub_reg_size, (char*)rd.d_start+sub_reg_size, val0, sub_reg_size, 1);
1328   - base_gf->multiply_region.w32(base_gf, (char*)rd.s_start+sub_reg_size, (char*)rd.d_start+sub_reg_size, base_gf->multiply.w32(base_gf, h->prim_poly, val1), sub_reg_size, 1);
  1325 + base_gf->multiply_region.w32(base_gf, (uint8_t *)rd.s_start+sub_reg_size, rd.d_start, val1, sub_reg_size, 1);
  1326 + base_gf->multiply_region.w32(base_gf, rd.s_start, (uint8_t *)rd.d_start+sub_reg_size, val1, sub_reg_size, xor);
  1327 + base_gf->multiply_region.w32(base_gf, (uint8_t *)rd.s_start+sub_reg_size, (uint8_t *)rd.d_start+sub_reg_size, val0, sub_reg_size, 1);
  1328 + base_gf->multiply_region.w32(base_gf, (uint8_t *)rd.s_start+sub_reg_size, (uint8_t *)rd.d_start+sub_reg_size, base_gf->multiply.w32(base_gf, h->prim_poly, val1), sub_reg_size, 1);
1329 1329  
1330 1330 gf_do_final_region_alignment(&rd);
1331 1331 }
... ...
src/gf_wgen.c
... ... @@ -916,11 +916,11 @@ gf_wgen_cauchy_region(gf_t *gf, void *src, void *dest, gf_val_32_t val, int byte
916 916 for (i = 0; i < h->w; i++) {
917 917 for (j = 0; j < h->w; j++) {
918 918 if (val & (1 << j)) {
919   - gf_multby_one(src, ((char*)dest) + j*rs, rs, (written & (1 << j)));
  919 + gf_multby_one(src, ((uint8_t *)dest) + j*rs, rs, (written & (1 << j)));
920 920 written |= (1 << j);
921 921 }
922 922 }
923   - src = (char*)src + rs;
  923 + src = (uint8_t *)src + rs;
924 924 val = gf->multiply.w32(gf, val, 2);
925 925 }
926 926 }
... ...