From 97c5a387c7b50f50254d5e97fdc39d2cf84c9e7a Mon Sep 17 00:00:00 2001 From: zeniko Date: Sat, 1 Jun 2013 21:49:26 +0200 Subject: fix MSVC compilation warnings in apps * pdfapp_save in pdfapp.c contains unreachable code (and could be simplified by inverting most of the checked conditions) * RegSetValueExA expects a const BYTE pointer instead of a char pointer (warns about signedness mismatch) * same for SendMessageA where -1 is signed even though WPARAM isn't Also, there's no need to include mupdf.h, muxps.h, etc. at the top of applications which only use the fz_* API (fitz.h comes included with pdfapp.h). --- apps/pdfapp.c | 66 +++++++++++++++++++++++---------------------------------- apps/win_main.c | 10 +++------ 2 files changed, 29 insertions(+), 47 deletions(-) (limited to 'apps') diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 1f82218f..33f222fc 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -1,7 +1,4 @@ #include "pdfapp.h" -#include "mupdf.h" -#include "muxps.h" -#include "mucbz.h" #include /* for tolower() */ @@ -322,51 +319,40 @@ static int pdfapp_save(pdfapp_t *app) opts.do_garbage = 1; opts.do_linear = 0; - if (strcmp(buf, app->docpath) == 0) + if (strcmp(buf, app->docpath) != 0) { - if (gen_tmp_file(buf, PATH_MAX)) - { - int written; - - fz_var(written); - fz_try(app->ctx) - { - fz_write_document(app->doc, buf, &opts); - written = 1; - } - fz_catch(app->ctx) - { - written = 0; - } + fz_write_document(app->doc, buf, &opts); + return 1; + } - if (written) - { - char buf2[PATH_MAX]; - fz_strlcpy(buf2, app->docpath, PATH_MAX); - pdfapp_close(app); - winreplacefile(buf, buf2); - pdfapp_open(app, buf2, 1); - } + if (gen_tmp_file(buf, PATH_MAX)) + { + int written; - return written; + fz_try(app->ctx) + { + fz_write_document(app->doc, buf, &opts); + written = 1; } - else + fz_catch(app->ctx) { - return 0; + written = 0; } - } - else - { - fz_write_document(app->doc, buf, &opts); - return 1; - } - return 1; - } - else - { - return 0; + if (written) + { + char buf2[PATH_MAX]; + fz_strlcpy(buf2, app->docpath, PATH_MAX); + pdfapp_close(app); + winreplacefile(buf, buf2); + pdfapp_open(app, buf2, 1); + + return written; + } + } } + + return 0; } int pdfapp_preclose(pdfapp_t *app) diff --git a/apps/win_main.c b/apps/win_main.c index 6de5033b..d19f29ba 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -1,7 +1,3 @@ -#include "fitz.h" -#include "mupdf.h" -#include "muxps.h" -#include "mucbz.h" #include "pdfapp.h" #ifndef UNICODE @@ -52,7 +48,7 @@ static char filename[PATH_MAX]; RegCreateKeyExA(parent, name, 0, 0, 0, KEY_WRITE, 0, &ptr, 0) #define SET_KEY(parent, name, value) \ - RegSetValueExA(parent, name, 0, REG_SZ, value, strlen(value) + 1) + RegSetValueExA(parent, name, 0, REG_SZ, (const BYTE *)(value), strlen(value) + 1) void install_app(char *argv0) { @@ -344,7 +340,7 @@ dlogchoiceproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* FIXME: handle multiple select */ if (*cd_nvals > 0) { - item = SendMessageA(listbox, LB_FINDSTRINGEXACT, -1, (LPARAM)cd_vals[0]); + item = SendMessageA(listbox, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)cd_vals[0]); if (item != LB_ERR) SendMessageA(listbox, LB_SETCURSEL, item, 0); } @@ -357,7 +353,7 @@ dlogchoiceproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) *cd_nvals = 0; for (i = 0; i < cd_nopts; i++) { - item = SendMessageA(listbox, LB_FINDSTRINGEXACT, -1, (LPARAM)cd_opts[i]); + item = SendMessageA(listbox, LB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)cd_opts[i]); sel = SendMessageA(listbox, LB_GETSEL, item, 0); if (sel && sel != LB_ERR) cd_vals[(*cd_nvals)++] = cd_opts[i]; -- cgit v1.2.3