cast--1-size_t.diff 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From: Wayne Davison <wayned@samba.org>
  2. Date: Tue, 22 Jul 2008 06:21:09 +0000 (-0700)
  3. Subject: Explicitly cast a -1 that is being assigned to a size_t.
  4. X-Git-Url: http://git.samba.org/?p=rsync.git;a=commitdiff_plain;h=bb640d32213c5dce2ad26515b5fc26e023ec9b98;hp=0566dc54b18fcaa6d666711ec3356bf6096af87e
  5. Explicitly cast a -1 that is being assigned to a size_t.
  6. ---
  7. diff --git a/flist.c b/flist.c
  8. index 7c21f73..2d17bf7 100644
  9. --- a/flist.c
  10. +++ b/flist.c
  11. @@ -689,7 +689,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
  12. xbuf outbuf, inbuf;
  13. INIT_CONST_XBUF(outbuf, thisname);
  14. - INIT_XBUF(inbuf, lastname, basename_len, -1);
  15. + INIT_XBUF(inbuf, lastname, basename_len, (size_t)-1);
  16. if (iconvbufs(ic_recv, &inbuf, &outbuf, 0) < 0) {
  17. io_error |= IOERR_GENERAL;
  18. diff --git a/io.c b/io.c
  19. index d884846..6068575 100644
  20. --- a/io.c
  21. +++ b/io.c
  22. @@ -511,7 +511,7 @@ static void mplex_write(int fd, enum msgcode code, const char *buf, size_t len,
  23. xbuf outbuf, inbuf;
  24. INIT_XBUF(outbuf, buffer + 4, 0, sizeof buffer - 4);
  25. - INIT_XBUF(inbuf, (char*)buf, len, -1);
  26. + INIT_XBUF(inbuf, (char*)buf, len, (size_t)-1);
  27. iconvbufs(ic_send, &inbuf, &outbuf,
  28. ICB_INCLUDE_BAD | ICB_INCLUDE_INCOMPLETE);
  29. @@ -1093,7 +1093,7 @@ static int readfd_unbuffered(int fd, char *buf, size_t len)
  30. int add_null = 0;
  31. INIT_CONST_XBUF(outbuf, line);
  32. - INIT_XBUF(inbuf, ibuf, 0, -1);
  33. + INIT_XBUF(inbuf, ibuf, 0, (size_t)-1);
  34. while (msg_bytes) {
  35. inbuf.len = msg_bytes > sizeof ibuf
  36. diff --git a/log.c b/log.c
  37. index d50523b..13c9311 100644
  38. --- a/log.c
  39. +++ b/log.c
  40. @@ -351,7 +351,7 @@ output_msg:
  41. int ierrno;
  42. INIT_CONST_XBUF(outbuf, convbuf);
  43. - INIT_XBUF(inbuf, (char*)buf, len, -1);
  44. + INIT_XBUF(inbuf, (char*)buf, len, (size_t)-1);
  45. while (inbuf.len) {
  46. iconvbufs(ic, &inbuf, &outbuf, 0);
  47. diff --git a/rsync.h b/rsync.h
  48. index 6540257..3a709d3 100644
  49. --- a/rsync.h
  50. +++ b/rsync.h
  51. @@ -851,7 +851,7 @@ typedef struct {
  52. } xbuf;
  53. #define INIT_XBUF(xb, str, ln, sz) (xb).buf = (str), (xb).len = (ln), (xb).size = (sz), (xb).pos = 0
  54. -#define INIT_XBUF_STRLEN(xb, str) (xb).buf = (str), (xb).len = strlen((xb).buf), (xb).size = (-1), (xb).pos = 0
  55. +#define INIT_XBUF_STRLEN(xb, str) (xb).buf = (str), (xb).len = strlen((xb).buf), (xb).size = (size_t)-1, (xb).pos = 0
  56. /* This one is used to make an output xbuf based on a char[] buffer: */
  57. #define INIT_CONST_XBUF(xb, bf) (xb).buf = (bf), (xb).size = sizeof (bf), (xb).len = (xb).pos = 0