diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-07-20 14:35:11 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-07-20 14:35:11 -0700 |
commit | 0d276835222eeb57de56f56cd9e12611b1d30466 (patch) | |
tree | 45c77a6944028cd1923fadd1f571975be21198eb | |
parent | bb3d8a7767cf260b97c7e019e4fec0ee7d7b65a8 (diff) |
Fix some clang warnings about integer sign/size conversions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/ICElibint.h | 4 | ||||
-rw-r--r-- | src/authutil.c | 26 | ||||
-rw-r--r-- | src/connect.c | 6 |
3 files changed, 20 insertions, 16 deletions
diff --git a/src/ICElibint.h b/src/ICElibint.h index 240e295..e034194 100644 --- a/src/ICElibint.h +++ b/src/ICElibint.h @@ -58,7 +58,7 @@ Author: Ralph Mor, X Consortium #define PAD64(_bytes) ((8 - ((unsigned int) (_bytes) % 8)) % 8) -#define PADDED_BYTES64(_bytes) (_bytes + PAD64 (_bytes)) +#define PADDED_BYTES64(_bytes) ((unsigned int) _bytes + PAD64 (_bytes)) /* @@ -67,7 +67,7 @@ Author: Ralph Mor, X Consortium #define PAD32(_bytes) ((4 - ((unsigned int) (_bytes) % 4)) % 4) -#define PADDED_BYTES32(_bytes) (_bytes + PAD32 (_bytes)) +#define PADDED_BYTES32(_bytes) ((unsigned int) _bytes + PAD32 (_bytes)) /* diff --git a/src/authutil.c b/src/authutil.c index 96ce3a0..dbd8b92 100644 --- a/src/authutil.c +++ b/src/authutil.c @@ -35,6 +35,7 @@ Author: Ralph Mor, X Consortium #include <X11/Xos.h> #include <sys/stat.h> #include <errno.h> +#include <limits.h> #include <time.h> #define Time_t time_t @@ -69,8 +70,8 @@ IceAuthFileName (void) static char slashDotICEauthority[] = "/.ICEauthority"; char *name; static char *buf; - static int bsize; - int size; + static size_t bsize; + size_t size; #ifdef WIN32 #ifndef PATH_MAX #define PATH_MAX 512 @@ -112,7 +113,7 @@ IceAuthFileName (void) { if (buf) free (buf); - buf = malloc ((unsigned) size); + buf = malloc (size); if (!buf) return (NULL); bsize = size; @@ -378,7 +379,7 @@ read_short (FILE *file, unsigned short *shortp) { unsigned char file_short[2]; - if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) + if (fread (file_short, sizeof (file_short), 1, file) != 1) return (0); *shortp = file_short[0] * 256 + file_short[1]; @@ -403,7 +404,7 @@ read_string (FILE *file, char **stringp) if (len != 0) { - if (fread (data, (int) sizeof (char), (int) len, file) != len) + if (fread (data, sizeof (char), len, file) != len) { free (data); return (0); @@ -438,7 +439,7 @@ read_counted_string (FILE *file, unsigned short *countp, char **stringp) if (!data) return (0); - if (fread (data, (int) sizeof (char), (int) len, file) != len) + if (fread (data, sizeof (char), len, file) != len) { free (data); return (0); @@ -460,7 +461,7 @@ write_short (FILE *file, unsigned short s) file_short[0] = (s & (unsigned) 0xff00) >> 8; file_short[1] = s & 0xff; - if (fwrite ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) + if (fwrite (file_short, sizeof (file_short), 1, file) != 1) return (0); return (1); @@ -470,12 +471,15 @@ write_short (FILE *file, unsigned short s) static Status write_string (FILE *file, char *string) { - unsigned short count = strlen (string); + size_t count = strlen (string); - if (!write_short (file, count)) + if (count > USHRT_MAX) + return (0); + + if (!write_short (file, (unsigned short) count)) return (0); - if (fwrite (string, (int) sizeof (char), (int) count, file) != count) + if (fwrite (string, sizeof (char), count, file) != count) return (0); return (1); @@ -488,7 +492,7 @@ write_counted_string (FILE *file, unsigned short count, char *string) if (!write_short (file, count)) return (0); - if (fwrite (string, (int) sizeof (char), (int) count, file) != count) + if (fwrite (string, sizeof (char), count, file) != count) return (0); return (1); diff --git a/src/connect.c b/src/connect.c index b59e94c..193a746 100644 --- a/src/connect.c +++ b/src/connect.c @@ -451,9 +451,9 @@ ConnectToPeer (char *networkIdsList, char **actualConnectionRet) char* address; char *ptr, *endptr, *delim; int madeConnection = 0; - int len, retry; - int connect_stat; - int address_size; + size_t len; + int retry, connect_stat; + size_t address_size; XtransConnInfo trans_conn = NULL; *actualConnectionRet = NULL; |