From 6630fbb8ad762dfef2d48b385f3a3e192e83496d Mon Sep 17 00:00:00 2001 From: rofl0r Date: Sat, 5 Oct 2013 06:15:19 +0200 Subject: [PATCH] hexStr... use size_t where size_t is needed --- hexedit.h | 2 +- mark.c | 2 +- misc.c | 4 ++-- search.c | 12 +++++++----- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/hexedit.h b/hexedit.h index a1684ff..abfa40c 100644 --- a/hexedit.h +++ b/hexedit.h @@ -188,6 +188,6 @@ int not(int b); char *mymemmem(char *a, int sizea, char *b, int sizeb); char *mymemrmem(char *a, int sizea, char *b, int sizeb); int is_file(char *name); -int hexStringToBinString(char *p, int *l); +int hexStringToBinString(char *p, size_t *l); #endif /* HEXEDIT_H */ diff --git a/mark.c b/mark.c index ae25f55..ea6d798 100644 --- a/mark.c +++ b/mark.c @@ -94,7 +94,7 @@ void fill_with_string(void) char **last = hexOrAscii ? &lastFillWithStringHexa : &lastFillWithStringAscii; char tmp2[BLOCK_SEARCH_SIZE]; unsigned char *tmp1; - int i, l1, l2; + size_t i, l1, l2; if (!mark_set) return; if (isReadOnly) { displayMessageAndWaitForKey("File is read-only!"); return; } diff --git a/misc.c b/misc.c index fcd37fd..2920a62 100644 --- a/misc.c +++ b/misc.c @@ -117,9 +117,9 @@ char *mymemrmem(char *a, int sizea, char *b, int sizeb) } -int hexStringToBinString(char *p, int *l) +int hexStringToBinString(char *p, size_t *l) { - int i; + size_t i; for (i = 0; i < *l; i++) { if (!isxdigit(p[i])) { diff --git a/search.c b/search.c index be46938..8117e69 100644 --- a/search.c +++ b/search.c @@ -16,13 +16,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.*/ #include "hexedit.h" -static int searchA(char **string, int *sizea, char *tmp, int tmp_size); +static int searchA(char **string, size_t *sizea, char *tmp, int tmp_size); static void searchB(off_t loc, char *string); /*******************************************************************************/ /* Search functions */ /*******************************************************************************/ -static int searchA(char **string, int *sizea, char *tmp, int tmp_size) +static int searchA(char **string, size_t *sizea, char *tmp, int tmp_size) { char *msg = hexOrAscii ? "Hexa string to search: " : "Ascii string to search: "; char **last = hexOrAscii ? &lastAskHexString : &lastAskAsciiString; @@ -55,7 +55,8 @@ static void searchB(off_t loc, char *string) void search_forward(void) { char *p, *string, tmp[BLOCK_SEARCH_SIZE], tmpstr[BLOCK_SEARCH_SIZE]; - int quit, sizea, sizeb; + int quit; + size_t sizea, sizeb; off_t blockstart; if (!searchA(&string, &sizea, tmp, sizeof(tmp))) return; @@ -80,7 +81,8 @@ void search_forward(void) void search_backward(void) { char *p, *string, tmp[BLOCK_SEARCH_SIZE], tmpstr[BLOCK_SEARCH_SIZE]; - int quit, sizea, sizeb; + int quit; + size_t sizea, sizeb; off_t blockstart; if (!searchA(&string, &sizea, tmp, sizeof(tmp))) return; @@ -94,7 +96,7 @@ void search_backward(void) if (sizeb < sizea) quit = -3; else { if (LSEEK_(fd, blockstart) == -1) { quit = -3; break; } - if (sizeb != read(fd, tmp, sizeb)) quit = -3; + if ((ssize_t) sizeb != read(fd, tmp, sizeb)) quit = -3; else if (getch() != ERR) quit = -2; else if ((p = mymemrmem(tmp, sizeb, string, sizea))) quit = p - tmp; } -- 2.11.4.GIT