changeset 871:fc272f5f2d15

Make value type of dmGetIntVal() unsigned.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 03 Feb 2015 20:27:12 +0200
parents 2711f99b40e5
children b01d04e44b6f
files src/dmlib.c src/dmlib.h tools/gfxconv.c tools/objlink.c tools/packed.c
diffstat 5 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- 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] == '$')
     {
--- 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);
--- 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)
         {
--- 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, &sectStart, &sectEnd, &sectName, 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);
--- 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);