From b5f7ccab2262439b99a9c880e3b00814f3c09ce6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 13 Sep 2015 09:23:48 +0200 Subject: [PATCH] Cleanups --- file_ops.c | 6 +++--- gfx/video_filters/lq2x.c | 15 ++++++--------- gfx/video_filters/scale2x.c | 6 +++--- gfx/video_filters/super2xsai.c | 19 +++++++++++-------- gfx/video_filters/supereagle.c | 11 ++++++----- 5 files changed, 29 insertions(+), 28 deletions(-) diff --git a/file_ops.c b/file_ops.c index 12583cd695..c0d0cca1aa 100644 --- a/file_ops.c +++ b/file_ops.c @@ -653,7 +653,7 @@ bool write_file(const char *path, const void *data, ssize_t size) */ static int read_generic_file(const char *path, void **buf, ssize_t *len) { - long ret = 0; + size_t bytes_read = 0; ssize_t content_buf_size = 0; void *content_buf = NULL; FILE *file = fopen(path, "rb"); @@ -675,7 +675,7 @@ static int read_generic_file(const char *path, void **buf, ssize_t *len) if (!content_buf) goto error; - if ((ret = fread(content_buf, 1, content_buf_size, file)) < content_buf_size) + if ((bytes_read = fread(content_buf, 1, content_buf_size, file)) < content_buf_size) RARCH_WARN("Didn't read whole file.\n"); *buf = content_buf; @@ -688,7 +688,7 @@ static int read_generic_file(const char *path, void **buf, ssize_t *len) RARCH_WARN("Failed to close file stream.\n"); if (len) - *len = ret; + *len = bytes_read; return 1; diff --git a/gfx/video_filters/lq2x.c b/gfx/video_filters/lq2x.c index b16dd2d3bd..6123bff5fc 100644 --- a/gfx/video_filters/lq2x.c +++ b/gfx/video_filters/lq2x.c @@ -109,15 +109,13 @@ static void lq2x_generic_rgb565(unsigned width, unsigned height, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned x, y; - uint16_t *out0, *out1; - out0 = (uint16_t*)dst; - out1 = (uint16_t*)(dst + dst_stride); + uint16_t *out0 = (uint16_t*)dst; + uint16_t *out1 = (uint16_t*)(dst + dst_stride); for(y = 0; y < height; y++) { - int prevline, nextline; - prevline = (y == 0 ? 0 : src_stride); - nextline = (y == height - 1 || last) ? 0 : src_stride; + int prevline = (y == 0 ? 0 : src_stride); + int nextline = (y == height - 1 || last) ? 0 : src_stride; for(x = 0; x < width; x++) { @@ -156,9 +154,8 @@ static void lq2x_generic_xrgb8888(unsigned width, unsigned height, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned x, y; - uint32_t *out0, *out1; - out0 = (uint32_t*)dst; - out1 = (uint32_t*)(dst + dst_stride); + uint32_t *out0 = (uint32_t*)dst; + uint32_t *out1 = (uint32_t*)(dst + dst_stride); for(y = 0; y < height; y++) { diff --git a/gfx/video_filters/scale2x.c b/gfx/video_filters/scale2x.c index 9841f4ed93..9bd69b8724 100644 --- a/gfx/video_filters/scale2x.c +++ b/gfx/video_filters/scale2x.c @@ -101,9 +101,9 @@ static void scale2x_generic_xrgb8888(unsigned width, unsigned height, uint32_t *dst, unsigned dst_stride) { unsigned x, y; - uint32_t *out0, *out1; - out0 = (uint32_t*)dst; - out1 = (uint32_t*)(dst + dst_stride); + uint32_t *out0 = (uint32_t*)dst; + uint32_t *out1 = (uint32_t*)(dst + dst_stride); + SCALE2X_GENERIC(uint32_t, width, height, first, last, src, src_stride, dst, dst_stride, out0, out1); } diff --git a/gfx/video_filters/super2xsai.c b/gfx/video_filters/super2xsai.c index 049e042ac1..2546cef57c 100644 --- a/gfx/video_filters/super2xsai.c +++ b/gfx/video_filters/super2xsai.c @@ -68,16 +68,18 @@ static void *supertwoxsai_generic_create(const struct softfilter_config *config, unsigned max_width, unsigned max_height, unsigned threads, softfilter_simd_mask_t simd, void *userdata) { + struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); + if (!filt) + return NULL; + (void)simd; (void)config; (void)userdata; - struct filter_data *filt = (struct filter_data*)calloc(1, sizeof(*filt)); - if (!filt) - return NULL; filt->workers = (struct softfilter_thread_data*)calloc(threads, sizeof(struct softfilter_thread_data)); filt->threads = 1; filt->in_fmt = in_fmt; + if (!filt->workers) { free(filt); @@ -202,8 +204,8 @@ static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height, int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { - unsigned nextline, finish; - nextline = (last) ? 0 : src_stride; + unsigned finish; + unsigned nextline = (last) ? 0 : src_stride; for (; height; height--) { @@ -232,8 +234,8 @@ static void supertwoxsai_generic_rgb565(unsigned width, unsigned height, int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { - unsigned nextline, finish; - nextline = (last) ? 0 : src_stride; + unsigned finish; + unsigned nextline = (last) ? 0 : src_stride; for (; height; height--) { @@ -287,8 +289,9 @@ static void supertwoxsai_generic_packets(void *data, void *output, size_t output_stride, const void *input, unsigned width, unsigned height, size_t input_stride) { - struct filter_data *filt = (struct filter_data*)data; unsigned i; + struct filter_data *filt = (struct filter_data*)data; + for (i = 0; i < filt->threads; i++) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; diff --git a/gfx/video_filters/supereagle.c b/gfx/video_filters/supereagle.c index 79341e7d3b..8c243d486a 100644 --- a/gfx/video_filters/supereagle.c +++ b/gfx/video_filters/supereagle.c @@ -219,8 +219,8 @@ static void supereagle_generic_xrgb8888(unsigned width, unsigned height, int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { - unsigned finish, nextline; - nextline = (last) ? 0 : src_stride; + unsigned finish; + unsigned nextline = (last) ? 0 : src_stride; for (; height; height--) { @@ -243,8 +243,8 @@ static void supereagle_generic_rgb565(unsigned width, unsigned height, int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { - unsigned nextline, finish; - nextline = (last) ? 0 : src_stride; + unsigned finish; + unsigned nextline = (last) ? 0 : src_stride; for (; height; height--) { @@ -292,8 +292,9 @@ static void supereagle_generic_packets(void *data, void *output, size_t output_stride, const void *input, unsigned width, unsigned height, size_t input_stride) { - struct filter_data *filt = (struct filter_data*)data; unsigned i; + struct filter_data *filt = (struct filter_data*)data; + for (i = 0; i < filt->threads; i++) { struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i];