Commit 715443661c00558fe32f004a4be5f93f341b6e59

Authored by KMG
2 parents 0f3af8fe e7131cfd
Exists in v2

Merge branch 'wip-exit-v2' into 'v2'

use assert instead of exit

the previous merge request was incorrectly against master. It now is twice in master which is not a problem but it's not in v2.

See merge request !5
Showing 3 changed files with 11 additions and 8 deletions   Show diff stats
src/gf.c
... ... @@ -11,6 +11,7 @@
11 11 #include "gf_int.h"
12 12 #include <stdio.h>
13 13 #include <stdlib.h>
  14 +#include <assert.h>
14 15  
15 16 int _gf_errno = GF_E_DEFAULT;
16 17  
... ... @@ -528,7 +529,7 @@ void gf_alignment_error(char *s, int a)
528 529 fprintf(stderr, "Alignment error in %s:\n", s);
529 530 fprintf(stderr, " The source and destination buffers must be aligned to each other,\n");
530 531 fprintf(stderr, " and they must be aligned to a %d-byte address.\n", a);
531   - exit(1);
  532 + assert(0);
532 533 }
533 534  
534 535 static
... ... @@ -551,7 +552,7 @@ void gf_invert_binary_matrix(uint32_t *mat, uint32_t *inv, int rows) {
551 552 for (j = i+1; j < rows && (mat[j] & (1 << i)) == 0; j++) ;
552 553 if (j == rows) {
553 554 fprintf(stderr, "galois_invert_matrix: Matrix not invertible!!\n");
554   - exit(1);
  555 + assert(0);
555 556 }
556 557 tmp = mat[i]; mat[i] = mat[j]; mat[j] = tmp;
557 558 tmp = inv[i]; inv[i] = inv[j]; inv[j] = tmp;
... ... @@ -812,7 +813,7 @@ void gf_set_region_data(gf_region_data *rd,
812 813 if (h != NULL && bytes % h->w != 0) {
813 814 fprintf(stderr, "Error in region multiply operation.\n");
814 815 fprintf(stderr, "The size must be a multiple of %d bytes.\n", h->w);
815   - exit(1);
  816 + assert(0);
816 817 }
817 818  
818 819 rd->s_start = src;
... ... @@ -828,7 +829,7 @@ void gf_set_region_data(gf_region_data *rd,
828 829 fprintf(stderr, "to each other along a %d byte boundary.\n", a);
829 830 fprintf(stderr, "Src = 0x%lx. Dest = 0x%lx\n", (unsigned long) src,
830 831 (unsigned long) dest);
831   - exit(1);
  832 + assert(0);
832 833 }
833 834  
834 835 if (uls % wb != 0) {
... ... @@ -836,13 +837,13 @@ void gf_set_region_data(gf_region_data *rd,
836 837 fprintf(stderr, "The pointers must be aligned along a %d byte boundary.\n", wb);
837 838 fprintf(stderr, "Src = 0x%lx. Dest = 0x%lx\n", (unsigned long) src,
838 839 (unsigned long) dest);
839   - exit(1);
  840 + assert(0);
840 841 }
841 842  
842 843 if (bytes % wb != 0) {
843 844 fprintf(stderr, "Error in region multiply operation.\n");
844 845 fprintf(stderr, "The size must be a multiple of %d bytes.\n", wb);
845   - exit(1);
  846 + assert(0);
846 847 }
847 848  
848 849 uls %= a;
... ...
src/gf_general.c
... ... @@ -17,6 +17,7 @@
17 17 #include <string.h>
18 18 #include <stdlib.h>
19 19 #include <time.h>
  20 +#include <assert.h>
20 21  
21 22 #include "gf_complete.h"
22 23 #include "gf_int.h"
... ... @@ -311,7 +312,7 @@ void gf_general_do_region_check(gf_t *gf, gf_general_t *a, void *orig_a, void *o
311 312 if (xor) fprintf(stderr," XOR with target word: %s\n", sot);
312 313 fprintf(stderr," Product word: %s\n", sft);
313 314 fprintf(stderr," It should be: %s\n", ssb);
314   - exit(0);
  315 + assert(0);
315 316 }
316 317 }
317 318 }
... ...
src/gf_w8.c
... ... @@ -12,6 +12,7 @@
12 12 #include "gf_w8.h"
13 13 #include <stdio.h>
14 14 #include <stdlib.h>
  15 +#include <assert.h>
15 16  
16 17 #define AB2(ip, am1 ,am2, b, t1, t2) {\
17 18 t1 = (b << 1) & am1;\
... ... @@ -1168,7 +1169,7 @@ int gf_w8_table_init(gf_t *gf)
1168 1169 scase = 2;
1169 1170 } else {
1170 1171 fprintf(stderr, "Internal error in gf_w8_table_init\n");
1171   - exit(0);
  1172 + assert(0);
1172 1173 }
1173 1174  
1174 1175 for (a = 1; a < GF_FIELD_SIZE; a++) {
... ...