0032-Various-compiler-warnings.patch 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. From 8b8af383ffa335600a44981a3ea9dd071cf8679e Mon Sep 17 00:00:00 2001
  2. From: Mats Erik Andersson <gnu@gisladisker.se>
  3. Date: Fri, 21 Feb 2020 17:47:49 +0100
  4. Subject: [PATCH 32/60] Various compiler warnings.
  5. ---
  6. ChangeLog | 19 +++++++++++++++++++
  7. libls/print.c | 2 +-
  8. ping/ping.c | 2 +-
  9. src/hostname.c | 6 +++---
  10. src/logger.c | 4 ++--
  11. src/rcp.c | 4 ++--
  12. src/syslogd.c | 8 ++++----
  13. src/traceroute.c | 2 +-
  14. 8 files changed, 33 insertions(+), 14 deletions(-)
  15. diff --git a/ChangeLog b/ChangeLog
  16. index 77e6a615..39a545ff 100644
  17. --- a/ChangeLog
  18. +++ b/ChangeLog
  19. @@ -1,3 +1,22 @@
  20. +2020-02-21 Mats Erik Andersson <gnu@gisladisker.se>
  21. +
  22. + Various compiler warnings, getting closer to `-Werror'.
  23. +
  24. + * libls/print.c (printlong): The functions major() and minor() have
  25. + no portable value type, so cast as `int'.
  26. +
  27. + * ping/ping.c (decode_type): Initialize HOSTNAME to NULL.
  28. +
  29. + * src/hostname.c (parse_opt, main) <SET_NAME_ACTION>: The prototype
  30. + of sethostname() is not portable, so cast as `void *'. Do this
  31. + also on both members in a conditional clause.
  32. + * src/logger.c (parse_level): Cast PRIORITYNAMES and FACILITYNAMES
  33. + as `CODE *', since BSD-systems assign these a constant type.
  34. + * src/syslogd.c (textpri, cfline): Likewise.
  35. + * src/rcp.c (source, rsource): Type length of `stat.st_mode' is not
  36. + portable, so cast as `int'.
  37. + * src/traceroute.c (trace_write): Make loop variable I unsigned.
  38. +
  39. 2020-01-29 Mats Erik Andersson <gnu@gisladisker.se>
  40. More work on CVE-2019-0053.
  41. diff --git a/libls/print.c b/libls/print.c
  42. index 3ca1ba58..98f60204 100644
  43. --- a/libls/print.c
  44. +++ b/libls/print.c
  45. @@ -138,7 +138,7 @@ printlong (DISPLAY *dp)
  46. if (f_flags)
  47. printf ("%-*s ", dp->s_flags, np->flags);
  48. if (S_ISCHR (sp->st_mode) || S_ISBLK (sp->st_mode))
  49. - printf ("%3d, %3d ", major (sp->st_rdev), minor (sp->st_rdev));
  50. + printf ("%3d, %3d ", (int) major (sp->st_rdev), (int) minor (sp->st_rdev));
  51. else if (dp->bcfile)
  52. printf ("%*s%*llu ",
  53. 8 - dp->s_size, "", dp->s_size, (long long) sp->st_size);
  54. diff --git a/ping/ping.c b/ping/ping.c
  55. index 091e0708..b6db5894 100644
  56. --- a/ping/ping.c
  57. +++ b/ping/ping.c
  58. @@ -335,7 +335,7 @@ main (int argc, char **argv)
  59. int (*decode_type (const char *arg)) (char *hostname)
  60. {
  61. - int (*ping_type) (char *hostname);
  62. + int (*ping_type) (char *hostname) = NULL;
  63. if (strcasecmp (arg, "echo") == 0)
  64. ping_type = ping_echo;
  65. diff --git a/src/hostname.c b/src/hostname.c
  66. index e340f8fd..67144b67 100644
  67. --- a/src/hostname.c
  68. +++ b/src/hostname.c
  69. @@ -91,7 +91,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
  70. break;
  71. case 'F':
  72. - set_name_action = sethostname;
  73. + set_name_action = (void *) sethostname;
  74. args->hostname_file = arg;
  75. break;
  76. @@ -116,7 +116,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
  77. break;
  78. case ARGP_KEY_ARG:
  79. - set_name_action = sethostname;
  80. + set_name_action = (void *) sethostname;
  81. args->hostname_new = strdup (arg);
  82. if (args->hostname_new == NULL)
  83. error (EXIT_FAILURE, errno, "strdup");
  84. @@ -160,7 +160,7 @@ main (int argc, char *argv[])
  85. if (get_name_action == xgetdomainname || get_name_action == xgethostname)
  86. get_name (&args);
  87. - else if (set_name_action == sethostname)
  88. + else if ((void *) set_name_action == (void *) sethostname)
  89. set_name (&args);
  90. return 0;
  91. diff --git a/src/logger.c b/src/logger.c
  92. index 113e2f52..52c9064c 100644
  93. --- a/src/logger.c
  94. +++ b/src/logger.c
  95. @@ -115,9 +115,9 @@ parse_level (char *str)
  96. if (p)
  97. *p++ = 0;
  98. - fac = decode (str, facilitynames, "facility");
  99. + fac = decode (str, (CODE *) facilitynames, "facility");
  100. if (p)
  101. - prio = decode (p, prioritynames, "priority");
  102. + prio = decode (p, (CODE *) prioritynames, "priority");
  103. return MAKE_PRI (fac, prio);
  104. }
  105. diff --git a/src/rcp.c b/src/rcp.c
  106. index 21f55b64..0eab5fa1 100644
  107. --- a/src/rcp.c
  108. +++ b/src/rcp.c
  109. @@ -746,7 +746,7 @@ source (int argc, char *argv[])
  110. }
  111. #define RCP_MODEMASK (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
  112. snprintf (buf, sizeof buf, "C%04o %jd %s\n",
  113. - stb.st_mode & RCP_MODEMASK, (intmax_t) stb.st_size, last);
  114. + (int) stb.st_mode & RCP_MODEMASK, (intmax_t) stb.st_size, last);
  115. write (rem, buf, strlen (buf));
  116. if (response () < 0)
  117. goto next;
  118. @@ -831,7 +831,7 @@ rsource (char *name, struct stat *statp)
  119. return;
  120. }
  121. - sprintf (buf, "D%04o %d %s\n", statp->st_mode & RCP_MODEMASK, 0, last);
  122. + sprintf (buf, "D%04o %d %s\n", (int) statp->st_mode & RCP_MODEMASK, 0, last);
  123. write (rem, buf, strlen (buf));
  124. free (buf);
  125. diff --git a/src/syslogd.c b/src/syslogd.c
  126. index 352a5bd0..2f4ee416 100644
  127. --- a/src/syslogd.c
  128. +++ b/src/syslogd.c
  129. @@ -1157,9 +1157,9 @@ textpri (int pri)
  130. static char res[20];
  131. CODE *c_pri, *c_fac;
  132. - for (c_fac = facilitynames; c_fac->c_name
  133. + for (c_fac = (CODE *) facilitynames; c_fac->c_name
  134. && !(c_fac->c_val == LOG_FAC (pri) << 3); c_fac++);
  135. - for (c_pri = prioritynames; c_pri->c_name
  136. + for (c_pri = (CODE *) prioritynames; c_pri->c_name
  137. && !(c_pri->c_val == LOG_PRI (pri)); c_pri++);
  138. snprintf (res, sizeof (res), "%s.%s", c_fac->c_name, c_pri->c_name);
  139. @@ -2260,7 +2260,7 @@ cfline (const char *line, struct filed *f)
  140. }
  141. else
  142. {
  143. - pri = decode (bp, prioritynames);
  144. + pri = decode (bp, (CODE *) prioritynames);
  145. if (pri < 0 || (pri > LOG_PRIMASK && pri != INTERNAL_NOPRI))
  146. {
  147. snprintf (ebuf, sizeof (ebuf),
  148. @@ -2306,7 +2306,7 @@ cfline (const char *line, struct filed *f)
  149. }
  150. else
  151. {
  152. - i = decode (buf, facilitynames);
  153. + i = decode (buf, (CODE *) facilitynames);
  154. if (i < 0 || i > (LOG_NFACILITIES << 3))
  155. {
  156. diff --git a/src/traceroute.c b/src/traceroute.c
  157. index 2a56a53d..54fc8b89 100644
  158. --- a/src/traceroute.c
  159. +++ b/src/traceroute.c
  160. @@ -702,7 +702,7 @@ trace_write (trace_t * t)
  161. case TRACE_ICMP:
  162. {
  163. icmphdr_t hdr;
  164. - int i;
  165. + unsigned int i;
  166. /* Deposit deterministic values throughout the header! */
  167. for (i = 0; i < sizeof (hdr); ++i)
  168. --
  169. 2.26.0.292.g33ef6b2f38