From d5cf0404a08253f52c6ddf3f6d80e694b9de4e7a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 21 Jul 2021 15:20:51 +0200 Subject: read_cbf_data: Fix types 'buf' has to be char *, otherwise "buf+len" isn't portable. 'len_read' has to be int, because that's the return type of gzread. If the value is immediately put into a size_t, the sign information is lost and we can no longer tell if gzread() failed. --- libcrystfel/src/image-cbf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libcrystfel/src/image-cbf.c b/libcrystfel/src/image-cbf.c index 8a97cc6d..807141d3 100644 --- a/libcrystfel/src/image-cbf.c +++ b/libcrystfel/src/image-cbf.c @@ -263,7 +263,7 @@ static int convert_type(float *data_out, long nmemb_exp, static float *read_cbf_data(const char *filename, int gz, int *w, int *h) { FILE *fh; - void *buf = NULL; + char *buf = NULL; char *rval; size_t data_compressed_len = 0; float *data_out = NULL; @@ -285,7 +285,8 @@ static float *read_cbf_data(const char *filename, int gz, int *w, int *h) } else { gzFile gzfh; - size_t len, len_read; + int len_read; + size_t len; const size_t bufinc = 8*1024*1024; /* Allocate buffer in 8Mb chunks */ size_t bufsz = bufinc; -- cgit v1.2.3