From f3a27169fce2442317c3afb3be2903cf0812c16d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 26 Jan 2015 12:21:56 -0800 Subject: [PATCH] Avoid 'clang' optimization, keep it -O0 --- pkg/storage/erasure/decode.c | 4 ++++ pkg/storage/erasure/decode.go | 7 ++++++- pkg/storage/erasure/encode.go | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/storage/erasure/decode.c b/pkg/storage/erasure/decode.c index 3a1bea00c..3f81cf799 100644 --- a/pkg/storage/erasure/decode.c +++ b/pkg/storage/erasure/decode.c @@ -46,6 +46,10 @@ int32_t minio_get_source_target (int errs, int k, int m, uint8_t *tmp_source[k]; uint8_t *tmp_target[m]; + if (k < 0 || m < 0) { + return -1; + } + memset (tmp_source, 0, k); memset (tmp_target, 0, m); diff --git a/pkg/storage/erasure/decode.go b/pkg/storage/erasure/decode.go index 2724637ce..572929fb8 100644 --- a/pkg/storage/erasure/decode.go +++ b/pkg/storage/erasure/decode.go @@ -19,6 +19,7 @@ package erasure // #cgo CPPFLAGS: -Iisal/include +// #cgo CFLAGS: -O0 // #include // #include // @@ -81,9 +82,13 @@ func (e *Encoder) Decode(chunks [][]byte, length int) ([]byte, error) { data := (**C.uint8_t)(unsafe.Pointer(&pointers[0])) - C.minio_get_source_target(C.int(err_count-1), e.k, e.m, error_index_ptr, + ret := C.minio_get_source_target(C.int(err_count-1), e.k, e.m, error_index_ptr, decode_index, data, &source, &target) + if int(ret) == -1 { + return nil, errors.New("Decoding source target failed") + } + C.ec_encode_data(C.int(chunk_size), e.k, C.int(err_count-1), decode_tbls, source, target) diff --git a/pkg/storage/erasure/encode.go b/pkg/storage/erasure/encode.go index 0467e0eed..270c0157b 100644 --- a/pkg/storage/erasure/encode.go +++ b/pkg/storage/erasure/encode.go @@ -20,6 +20,7 @@ package erasure // #cgo CPPFLAGS: -Iisal/include // #cgo LDFLAGS: isal/isa-l.a +// #cgo CFLAGS: -O0 // #include // #include //