diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2010-04-29 20:19:38 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2010-05-05 15:46:28 -0700 |
commit | 30e388a8284ed100893983178acb6b4e3ff2b815 (patch) | |
tree | 68ea9a13627712ca9dea9b1e856df66cdbef10c6 | |
parent | 110078a137915f486a13e0445ee9ba5e1558c081 (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.c | 7 | ||||
-rw-r--r-- | AA32.c | 7 | ||||
-rw-r--r-- | AA8.c | 7 | ||||
-rw-r--r-- | AofA8.c | 7 | ||||
-rw-r--r-- | RAofA8.c | 4 | ||||
-rw-r--r-- | RaA16.c | 6 | ||||
-rw-r--r-- | RaA32.c | 7 | ||||
-rw-r--r-- | RaA8.c | 7 | ||||
-rw-r--r-- | RaAoA8.c | 7 |
9 files changed, 49 insertions, 10 deletions
@@ -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; } @@ -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; } @@ -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; } @@ -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; } @@ -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])) { @@ -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; } @@ -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; } @@ -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; } @@ -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; } |