# HG changeset patch # User Matti Hamalainen # Date 1422988032 -7200 # Node ID fc272f5f2d15aabc7d50ffa7bf58c7b58e807756 # Parent 2711f99b40e524461373536b205ac1298cbf6f37 Make value type of dmGetIntVal() unsigned. diff -r 2711f99b40e5 -r fc272f5f2d15 src/dmlib.c --- a/src/dmlib.c Tue Feb 03 20:07:38 2015 +0200 +++ b/src/dmlib.c Tue Feb 03 20:27:12 2015 +0200 @@ -123,7 +123,7 @@ } -BOOL dmGetIntVal(const char *s, int *i) +BOOL dmGetIntVal(const char *s, unsigned int *i) { if (s[0] == '$') { diff -r 2711f99b40e5 -r fc272f5f2d15 src/dmlib.h --- a/src/dmlib.h Tue Feb 03 20:07:38 2015 +0200 +++ b/src/dmlib.h Tue Feb 03 20:27:12 2015 +0200 @@ -392,7 +392,7 @@ void * dmCalloc(size_t, size_t); void dmFree(void *); -BOOL dmGetIntVal(const char *s, int *i); +BOOL dmGetIntVal(const char *s, unsigned int *i); int dmGetErrno(); const char *dmErrorStr(int error); diff -r 2711f99b40e5 -r fc272f5f2d15 tools/gfxconv.c --- a/tools/gfxconv.c Tue Feb 03 20:07:38 2015 +0200 +++ b/tools/gfxconv.c Tue Feb 03 20:27:12 2015 +0200 @@ -111,7 +111,7 @@ { BOOL triplet, alpha; DMColor color; - int from, to; + unsigned int from, to; } DMMapValue; @@ -125,8 +125,8 @@ optOutSubFormat = IMGFMT_PNG, optItemCount = -1, optPlanedWidth = 1, - optForcedFormat = -1, - optInSkip = 0; + optForcedFormat = -1; +unsigned int optInSkip = 0; int optCropMode = CROP_NONE, optCropX0, optCropY0, @@ -310,7 +310,7 @@ } -static BOOL dmParseMapOptionMapItem(const char *popt, DMMapValue *value, const int nmax, const char *msg) +static BOOL dmParseMapOptionMapItem(const char *popt, DMMapValue *value, const unsigned int nmax, const char *msg) { char *end, *split, *opt = dm_strdup(popt); @@ -373,13 +373,13 @@ goto error; } - if (!value->triplet && (value->from < 0 || value->from > 255)) + if (!value->triplet && value->from > 255) { dmError("Invalid %s map source color index value %d, must be [0..255].\n", msg, value->from); goto error; } - if (value->to < 0 || value->to > nmax) + if (value->to > nmax) { dmError("Invalid %s map destination color index value %d, must be [0..%d].\n", msg, value->to, nmax); goto error; @@ -414,7 +414,7 @@ } else { - int *value = (int *) pvalue; + unsigned int *value = (unsigned int *) pvalue; char *split = strchr(opt, ':'); if (split != NULL) { diff -r 2711f99b40e5 -r fc272f5f2d15 tools/objlink.c --- a/tools/objlink.c Tue Feb 03 20:07:38 2015 +0200 +++ b/tools/objlink.c Tue Feb 03 20:27:12 2015 +0200 @@ -134,7 +134,7 @@ Uint32 optInitValue = 0; int optInitValueType = 1; -int optCropStart, optCropEnd; +unsigned int optCropStart, optCropEnd; BOOL optCropOutput = FALSE; int optLoadAddress = LA_AUTO; @@ -236,10 +236,10 @@ } -BOOL dmParseSection(const char *arg, int *sectStart, int *sectEnd, char **sectName, BOOL canHasName) +BOOL dmParseSection(const char *arg, unsigned int *sectStart, unsigned int *sectEnd, char **sectName, BOOL canHasName) { char sectMode, *sep, *str, *namesep; - int tmpi; + unsigned int tmpi; // Define reserved section // Create a copy of the argument @@ -323,7 +323,7 @@ BOOL dmParseInputFile(char *arg, const int type1, const int type2, const char *desc, BOOL requireAddr) { - int tmpi = 0; + unsigned int tmpi = 0; BOOL hasAddr = FALSE; char *sep; @@ -356,7 +356,7 @@ BOOL argHandleOpt(const int optN, char *optArg, char *currArg) { char *p; - int tmpi; + unsigned int tmpi; switch (optN) { case 0: @@ -456,7 +456,7 @@ case 12: { char *sectName = "Clear"; - int sectStart, sectEnd, sectLen; + unsigned int sectStart, sectEnd, sectLen; if (!dmParseSection(optArg, §Start, §End, §Name, TRUE)) return FALSE; @@ -494,7 +494,7 @@ dmError("Invalid loading address '%s'.\n", optArg); return FALSE; } - if (tmpi < 0 || tmpi >= 64*1024) + if (tmpi >= 64*1024) { dmError("Invalid or insane loading address %d/$%x!\n", tmpi); diff -r 2711f99b40e5 -r fc272f5f2d15 tools/packed.c --- a/tools/packed.c Tue Feb 03 20:07:38 2015 +0200 +++ b/tools/packed.c Tue Feb 03 20:27:12 2015 +0200 @@ -105,7 +105,7 @@ case 8: { - int i; + unsigned int i; if (!dmGetIntVal(optArg, &i)) { dmError("Invalid flags value '%s'.\n", optArg);