Fix Linux/Mac OS X erasure decoding failure with new Golang version 1.5.1

Fixes #871
master
Harshavardhana 9 years ago
parent e793431852
commit cd52d7a11c
  1. 24
      pkg/erasure/ec_minio_decode.c
  2. 2
      pkg/erasure/ec_minio_encode.c
  3. 1
      pkg/erasure/erasure_encode.go

@ -80,12 +80,18 @@ int minio_init_decoder (int32_t *error_index,
unsigned char **decode_tbls, unsigned char **decode_tbls,
uint32_t **decode_index) uint32_t **decode_index)
{ {
int i, j, r, s, l, z; int i, j, r, l;
unsigned char input_matrix[k * n];
unsigned char inverse_matrix[k * n]; uint32_t *tmp_decode_index = (uint32_t *) malloc(sizeof(uint32_t) * k);
unsigned char tmp_decode_matrix[k * n]; unsigned char *input_matrix;
unsigned char tmp_decode_tbls[k * n * 32]; unsigned char *inverse_matrix;
uint32_t tmp_decode_index[k]; unsigned char *tmp_decode_matrix;
unsigned char *tmp_decode_tbls;
input_matrix = (unsigned char *) malloc(sizeof(unsigned char) * k * n);
inverse_matrix = (unsigned char *) malloc(sizeof(unsigned char) * k * n);
tmp_decode_matrix = (unsigned char *) malloc(sizeof(unsigned char) * k * n);;
tmp_decode_tbls = (unsigned char *) malloc(sizeof(unsigned char) * k * n * 32);
for (i = 0, r = 0; i < k; i++, r++) { for (i = 0, r = 0; i < k; i++, r++) {
while (_minio_src_index_in_error(r, error_index, errs)) while (_minio_src_index_in_error(r, error_index, errs))
@ -98,6 +104,9 @@ int minio_init_decoder (int32_t *error_index,
// Not all vandermonde matrix can be inverted // Not all vandermonde matrix can be inverted
if (gf_invert_matrix(input_matrix, inverse_matrix, k) < 0) { if (gf_invert_matrix(input_matrix, inverse_matrix, k) < 0) {
free(tmp_decode_matrix);
free(tmp_decode_tbls);
free(tmp_decode_index);
return -1; return -1;
} }
@ -110,10 +119,9 @@ int minio_init_decoder (int32_t *error_index,
error_index[l] + j]; error_index[l] + j];
} }
} else { } else {
int s = 0;
// decoding matrix element for coding chunks // decoding matrix element for coding chunks
for (i = 0; i < k; i++) { for (i = 0; i < k; i++) {
s = 0; unsigned char s = 0;
for (j = 0; j < k; j++) { for (j = 0; j < k; j++) {
s ^= gf_mul(inverse_matrix[j * k + i], s ^= gf_mul(inverse_matrix[j * k + i],
encode_matrix[k * encode_matrix[k *

@ -28,8 +28,6 @@ int32_t minio_init_encoder (int technique, int k, int m,
unsigned char **encode_matrix, unsigned char **encode_matrix,
unsigned char **encode_tbls) unsigned char **encode_tbls)
{ {
size_t encode_matrix_size;
size_t encode_tbls_size;
unsigned char *tmp_matrix; unsigned char *tmp_matrix;
unsigned char *tmp_tbls; unsigned char *tmp_tbls;

@ -16,7 +16,6 @@
package erasure package erasure
// #cgo CFLAGS: -O0
// #include <stdlib.h> // #include <stdlib.h>
// #include "ec_isal-l.h" // #include "ec_isal-l.h"
// #include "ec_minio_common.h" // #include "ec_minio_common.h"

Loading…
Cancel
Save