summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-04-29 20:19:38 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2010-05-05 15:46:28 -0700
commit30e388a8284ed100893983178acb6b4e3ff2b815 (patch)
tree68ea9a13627712ca9dea9b1e856df66cdbef10c6
parent110078a137915f486a13e0445ee9ba5e1558c081 (diff)
Deal with lint warnings about implicit narrowing conversions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
-rw-r--r--AA16.c7
-rw-r--r--AA32.c7
-rw-r--r--AA8.c7
-rw-r--r--AofA8.c7
-rw-r--r--RAofA8.c4
-rw-r--r--RaA16.c6
-rw-r--r--RaA32.c7
-rw-r--r--RaA8.c7
-rw-r--r--RaAoA8.c7
9 files changed, 49 insertions, 10 deletions
diff --git a/AA16.c b/AA16.c
index 5de5caf..049a24a 100644
--- a/AA16.c
+++ b/AA16.c
@@ -36,16 +36,21 @@ in this Software without prior written authorization from The Open Group.
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>
+#include <limits.h>
int
XdmcpAllocARRAY16 (ARRAY16Ptr array, int length)
{
CARD16Ptr newData;
+ /* length defined in ARRAY16 struct is a CARD8 */
+ if (length > UINT8_MAX)
+ return FALSE;
+
newData = (CARD16Ptr) Xalloc (length * sizeof (CARD16));
if (!newData)
return FALSE;
- array->length = length;
+ array->length = (CARD8) length;
array->data = newData;
return TRUE;
}
diff --git a/AA32.c b/AA32.c
index fbeded1..5687a9a 100644
--- a/AA32.c
+++ b/AA32.c
@@ -36,16 +36,21 @@ in this Software without prior written authorization from The Open Group.
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>
+#include <limits.h>
int
XdmcpAllocARRAY32 (ARRAY32Ptr array, int length)
{
CARD32Ptr newData;
+ /* length defined in ARRAY32 struct is a CARD8 */
+ if (length > UINT8_MAX)
+ return FALSE;
+
newData = (CARD32Ptr) Xalloc (length * sizeof (CARD32));
if (!newData)
return FALSE;
- array->length = length;
+ array->length = (CARD8) length;
array->data = newData;
return TRUE;
}
diff --git a/AA8.c b/AA8.c
index 391e788..1cb29d4 100644
--- a/AA8.c
+++ b/AA8.c
@@ -36,16 +36,21 @@ in this Software without prior written authorization from The Open Group.
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>
+#include <limits.h>
int
XdmcpAllocARRAY8 (ARRAY8Ptr array, int length)
{
CARD8Ptr newData;
+ /* length defined in ARRAY8 struct is a CARD16 (not CARD8 like the rest) */
+ if (length > UINT16_MAX)
+ return FALSE;
+
newData = (CARD8Ptr) Xalloc (length * sizeof (CARD8));
if (!newData)
return FALSE;
- array->length = length;
+ array->length = (CARD16) length;
array->data = newData;
return TRUE;
}
diff --git a/AofA8.c b/AofA8.c
index fe77330..93cf4e6 100644
--- a/AofA8.c
+++ b/AofA8.c
@@ -36,16 +36,21 @@ in this Software without prior written authorization from The Open Group.
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>
+#include <limits.h>
int
XdmcpAllocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length)
{
ARRAY8Ptr newData;
+ /* length defined in ARRAYofARRAY8 struct is a CARD8 */
+ if (length > UINT8_MAX)
+ return FALSE;
+
newData = (ARRAY8Ptr) Xalloc (length * sizeof (ARRAY8));
if (!newData)
return FALSE;
- array->length = length;
+ array->length = (CARD8) length;
array->data = newData;
return TRUE;
}
diff --git a/RAofA8.c b/RAofA8.c
index 7c8563f..2df3c24 100644
--- a/RAofA8.c
+++ b/RAofA8.c
@@ -38,7 +38,7 @@ in this Software without prior written authorization from The Open Group.
int
XdmcpReadARRAYofARRAY8 (XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array)
{
- int i;
+ CARD8 i;
if (!XdmcpReadCARD8 (buffer, &array->length)) {
@@ -56,7 +56,7 @@ XdmcpReadARRAYofARRAY8 (XdmcpBufferPtr buffer, ARRAYofARRAY8Ptr array)
array->data = (ARRAY8 *) Xalloc (array->length * sizeof (ARRAY8));
if (!array->data)
return FALSE;
- for (i = 0; i < (int)array->length; i++)
+ for (i = 0; i < array->length; i++)
{
if (!XdmcpReadARRAY8 (buffer, &array->data[i]))
{
diff --git a/RaA16.c b/RaA16.c
index b02fa2f..96f87b5 100644
--- a/RaA16.c
+++ b/RaA16.c
@@ -36,16 +36,20 @@ in this Software without prior written authorization from The Open Group.
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>
+#include <limits.h>
int
XdmcpReallocARRAY16 (ARRAY16Ptr array, int length)
{
CARD16Ptr newData;
+ /* length defined in ARRAY16 struct is a CARD8 */
+ if (length > UINT8_MAX)
+ return FALSE;
newData = (CARD16Ptr) Xrealloc (array->data, length * sizeof (CARD16));
if (!newData)
return FALSE;
- array->length = length;
+ array->length = (CARD8) length;
array->data = newData;
return TRUE;
}
diff --git a/RaA32.c b/RaA32.c
index 52167d1..93037e3 100644
--- a/RaA32.c
+++ b/RaA32.c
@@ -36,16 +36,21 @@ in this Software without prior written authorization from The Open Group.
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>
+#include <limits.h>
int
XdmcpReallocARRAY32 (ARRAY32Ptr array, int length)
{
CARD32Ptr newData;
+ /* length defined in ARRAY32 struct is a CARD8 */
+ if (length > UINT8_MAX)
+ return FALSE;
+
newData = (CARD32Ptr) Xrealloc (array->data, length * sizeof (CARD32));
if (!newData)
return FALSE;
- array->length = length;
+ array->length = (CARD8) length;
array->data = newData;
return TRUE;
}
diff --git a/RaA8.c b/RaA8.c
index 3e7bc08..ac85ae7 100644
--- a/RaA8.c
+++ b/RaA8.c
@@ -36,16 +36,21 @@ in this Software without prior written authorization from The Open Group.
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>
+#include <limits.h>
int
XdmcpReallocARRAY8 (ARRAY8Ptr array, int length)
{
CARD8Ptr newData;
+ /* length defined in ARRAY8 struct is a CARD16 (not CARD8 like the rest) */
+ if (length > UINT16_MAX)
+ return FALSE;
+
newData = (CARD8Ptr) Xrealloc (array->data, length * sizeof (CARD8));
if (!newData)
return FALSE;
- array->length = length;
+ array->length = (CARD16) length;
array->data = newData;
return TRUE;
}
diff --git a/RaAoA8.c b/RaAoA8.c
index 8b4806c..6ef5a09 100644
--- a/RaAoA8.c
+++ b/RaAoA8.c
@@ -36,16 +36,21 @@ in this Software without prior written authorization from The Open Group.
#include <X11/X.h>
#include <X11/Xmd.h>
#include <X11/Xdmcp.h>
+#include <limits.h>
int
XdmcpReallocARRAYofARRAY8 (ARRAYofARRAY8Ptr array, int length)
{
ARRAY8Ptr newData;
+ /* length defined in ARRAYofARRAY8 struct is a CARD8 */
+ if (length > UINT8_MAX)
+ return FALSE;
+
newData = (ARRAY8Ptr) Xrealloc (array->data, length * sizeof (ARRAY8));
if (!newData)
return FALSE;
- array->length = length;
+ array->length = (CARD8) length;
array->data = newData;
return TRUE;
}