use assert(0) instead of exit(1)
When a fatal error (unaligned memory etc.) is detected, gf-complete should
assert(3) instead of exit(3) to give a chance to the calling program to
catch the exception and display a stack trace. Although it is possible
for gdb to display the stack trace and break on exit, libraries are not
usually expected to terminate the calling program in this way.
Signed-off-by: Loic Dachary <loic@dachary.org>
(cherry picked from commit 29427efac2
)
master
parent
70dd94ae38
commit
e7131cfd85
13
src/gf.c
13
src/gf.c
|
@ -11,6 +11,7 @@
|
|||
#include "gf_int.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
int _gf_errno = GF_E_DEFAULT;
|
||||
|
||||
|
@ -528,7 +529,7 @@ void gf_alignment_error(char *s, int a)
|
|||
fprintf(stderr, "Alignment error in %s:\n", s);
|
||||
fprintf(stderr, " The source and destination buffers must be aligned to each other,\n");
|
||||
fprintf(stderr, " and they must be aligned to a %d-byte address.\n", a);
|
||||
exit(1);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -551,7 +552,7 @@ void gf_invert_binary_matrix(uint32_t *mat, uint32_t *inv, int rows) {
|
|||
for (j = i+1; j < rows && (mat[j] & (1 << i)) == 0; j++) ;
|
||||
if (j == rows) {
|
||||
fprintf(stderr, "galois_invert_matrix: Matrix not invertible!!\n");
|
||||
exit(1);
|
||||
assert(0);
|
||||
}
|
||||
tmp = mat[i]; mat[i] = mat[j]; mat[j] = tmp;
|
||||
tmp = inv[i]; inv[i] = inv[j]; inv[j] = tmp;
|
||||
|
@ -812,7 +813,7 @@ void gf_set_region_data(gf_region_data *rd,
|
|||
if (h != NULL && bytes % h->w != 0) {
|
||||
fprintf(stderr, "Error in region multiply operation.\n");
|
||||
fprintf(stderr, "The size must be a multiple of %d bytes.\n", h->w);
|
||||
exit(1);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
rd->s_start = src;
|
||||
|
@ -828,7 +829,7 @@ void gf_set_region_data(gf_region_data *rd,
|
|||
fprintf(stderr, "to each other along a %d byte boundary.\n", a);
|
||||
fprintf(stderr, "Src = 0x%lx. Dest = 0x%lx\n", (unsigned long) src,
|
||||
(unsigned long) dest);
|
||||
exit(1);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (uls % wb != 0) {
|
||||
|
@ -836,13 +837,13 @@ void gf_set_region_data(gf_region_data *rd,
|
|||
fprintf(stderr, "The pointers must be aligned along a %d byte boundary.\n", wb);
|
||||
fprintf(stderr, "Src = 0x%lx. Dest = 0x%lx\n", (unsigned long) src,
|
||||
(unsigned long) dest);
|
||||
exit(1);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (bytes % wb != 0) {
|
||||
fprintf(stderr, "Error in region multiply operation.\n");
|
||||
fprintf(stderr, "The size must be a multiple of %d bytes.\n", wb);
|
||||
exit(1);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
uls %= a;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "gf_complete.h"
|
||||
#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
|
|||
if (xor) fprintf(stderr," XOR with target word: %s\n", sot);
|
||||
fprintf(stderr," Product word: %s\n", sft);
|
||||
fprintf(stderr," It should be: %s\n", ssb);
|
||||
exit(0);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "gf_w8.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define AB2(ip, am1 ,am2, b, t1, t2) {\
|
||||
t1 = (b << 1) & am1;\
|
||||
|
@ -1168,7 +1169,7 @@ int gf_w8_table_init(gf_t *gf)
|
|||
scase = 2;
|
||||
} else {
|
||||
fprintf(stderr, "Internal error in gf_w8_table_init\n");
|
||||
exit(0);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
for (a = 1; a < GF_FIELD_SIZE; a++) {
|
||||
|
|
Loading…
Reference in New Issue