From 08fb993f8e729f14951908dddb2cdae0ddb0a1e6 Mon Sep 17 00:00:00 2001 From: redrossa Date: Wed, 8 Sep 2021 18:22:52 -0500 Subject: [PATCH 1/3] Fix compilation error on UWP --- examples/example.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/example.c b/examples/example.c index fe82a8a7..4136d0c3 100644 --- a/examples/example.c +++ b/examples/example.c @@ -5,7 +5,7 @@ int main(int argc, char **argv) { - int r = 0; + int r = 0, err; FILE *png; spng_ctx *ctx = NULL; unsigned char *out = NULL; @@ -16,8 +16,14 @@ int main(int argc, char **argv) goto error; } +#if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) + err = fopen_s(&png, argv[1], "rb"); +#else png = fopen(argv[1], "rb"); if(png == NULL) + err = 1; +#endif + if (err) { printf("error opening input file %s\n", argv[1]); goto error; From 8c4fa954f4897f1d2191304ce6df40b38c05140d Mon Sep 17 00:00:00 2001 From: redrossa Date: Wed, 8 Sep 2021 18:26:47 -0500 Subject: [PATCH 2/3] Fix uninitialized variable err --- examples/example.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/example.c b/examples/example.c index 4136d0c3..93a85ada 100644 --- a/examples/example.c +++ b/examples/example.c @@ -20,8 +20,7 @@ int main(int argc, char **argv) err = fopen_s(&png, argv[1], "rb"); #else png = fopen(argv[1], "rb"); - if(png == NULL) - err = 1; + err = png == NULL; #endif if (err) { From b28b6e3cc8cf87466a5d54ed4367a3609fd706fb Mon Sep 17 00:00:00 2001 From: Randy Date: Thu, 9 Sep 2021 21:35:15 +0200 Subject: [PATCH 3/3] cleanup, limit fix to msvc --- examples/example.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/example.c b/examples/example.c index 93a85ada..d747e10d 100644 --- a/examples/example.c +++ b/examples/example.c @@ -5,7 +5,7 @@ int main(int argc, char **argv) { - int r = 0, err; + int r = 0; FILE *png; spng_ctx *ctx = NULL; unsigned char *out = NULL; @@ -16,13 +16,13 @@ int main(int argc, char **argv) goto error; } -#if defined(_MSC_VER) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) - err = fopen_s(&png, argv[1], "rb"); +#if defined(_MSC_VER) + r = fopen_s(&png, argv[1], "rb"); #else png = fopen(argv[1], "rb"); - err = png == NULL; + if(!png) r = 1; #endif - if (err) + if(r) { printf("error opening input file %s\n", argv[1]); goto error;