123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- From 8b8af383ffa335600a44981a3ea9dd071cf8679e Mon Sep 17 00:00:00 2001
- From: Mats Erik Andersson <gnu@gisladisker.se>
- Date: Fri, 21 Feb 2020 17:47:49 +0100
- Subject: [PATCH 32/60] Various compiler warnings.
- ---
- ChangeLog | 19 +++++++++++++++++++
- libls/print.c | 2 +-
- ping/ping.c | 2 +-
- src/hostname.c | 6 +++---
- src/logger.c | 4 ++--
- src/rcp.c | 4 ++--
- src/syslogd.c | 8 ++++----
- src/traceroute.c | 2 +-
- 8 files changed, 33 insertions(+), 14 deletions(-)
- diff --git a/ChangeLog b/ChangeLog
- index 77e6a615..39a545ff 100644
- --- a/ChangeLog
- +++ b/ChangeLog
- @@ -1,3 +1,22 @@
- +2020-02-21 Mats Erik Andersson <gnu@gisladisker.se>
- +
- + Various compiler warnings, getting closer to `-Werror'.
- +
- + * libls/print.c (printlong): The functions major() and minor() have
- + no portable value type, so cast as `int'.
- +
- + * ping/ping.c (decode_type): Initialize HOSTNAME to NULL.
- +
- + * src/hostname.c (parse_opt, main) <SET_NAME_ACTION>: The prototype
- + of sethostname() is not portable, so cast as `void *'. Do this
- + also on both members in a conditional clause.
- + * src/logger.c (parse_level): Cast PRIORITYNAMES and FACILITYNAMES
- + as `CODE *', since BSD-systems assign these a constant type.
- + * src/syslogd.c (textpri, cfline): Likewise.
- + * src/rcp.c (source, rsource): Type length of `stat.st_mode' is not
- + portable, so cast as `int'.
- + * src/traceroute.c (trace_write): Make loop variable I unsigned.
- +
- 2020-01-29 Mats Erik Andersson <gnu@gisladisker.se>
-
- More work on CVE-2019-0053.
- diff --git a/libls/print.c b/libls/print.c
- index 3ca1ba58..98f60204 100644
- --- a/libls/print.c
- +++ b/libls/print.c
- @@ -138,7 +138,7 @@ printlong (DISPLAY *dp)
- if (f_flags)
- printf ("%-*s ", dp->s_flags, np->flags);
- if (S_ISCHR (sp->st_mode) || S_ISBLK (sp->st_mode))
- - printf ("%3d, %3d ", major (sp->st_rdev), minor (sp->st_rdev));
- + printf ("%3d, %3d ", (int) major (sp->st_rdev), (int) minor (sp->st_rdev));
- else if (dp->bcfile)
- printf ("%*s%*llu ",
- 8 - dp->s_size, "", dp->s_size, (long long) sp->st_size);
- diff --git a/ping/ping.c b/ping/ping.c
- index 091e0708..b6db5894 100644
- --- a/ping/ping.c
- +++ b/ping/ping.c
- @@ -335,7 +335,7 @@ main (int argc, char **argv)
-
- int (*decode_type (const char *arg)) (char *hostname)
- {
- - int (*ping_type) (char *hostname);
- + int (*ping_type) (char *hostname) = NULL;
-
- if (strcasecmp (arg, "echo") == 0)
- ping_type = ping_echo;
- diff --git a/src/hostname.c b/src/hostname.c
- index e340f8fd..67144b67 100644
- --- a/src/hostname.c
- +++ b/src/hostname.c
- @@ -91,7 +91,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
- break;
-
- case 'F':
- - set_name_action = sethostname;
- + set_name_action = (void *) sethostname;
- args->hostname_file = arg;
- break;
-
- @@ -116,7 +116,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
- break;
-
- case ARGP_KEY_ARG:
- - set_name_action = sethostname;
- + set_name_action = (void *) sethostname;
- args->hostname_new = strdup (arg);
- if (args->hostname_new == NULL)
- error (EXIT_FAILURE, errno, "strdup");
- @@ -160,7 +160,7 @@ main (int argc, char *argv[])
-
- if (get_name_action == xgetdomainname || get_name_action == xgethostname)
- get_name (&args);
- - else if (set_name_action == sethostname)
- + else if ((void *) set_name_action == (void *) sethostname)
- set_name (&args);
-
- return 0;
- diff --git a/src/logger.c b/src/logger.c
- index 113e2f52..52c9064c 100644
- --- a/src/logger.c
- +++ b/src/logger.c
- @@ -115,9 +115,9 @@ parse_level (char *str)
- if (p)
- *p++ = 0;
-
- - fac = decode (str, facilitynames, "facility");
- + fac = decode (str, (CODE *) facilitynames, "facility");
- if (p)
- - prio = decode (p, prioritynames, "priority");
- + prio = decode (p, (CODE *) prioritynames, "priority");
-
- return MAKE_PRI (fac, prio);
- }
- diff --git a/src/rcp.c b/src/rcp.c
- index 21f55b64..0eab5fa1 100644
- --- a/src/rcp.c
- +++ b/src/rcp.c
- @@ -746,7 +746,7 @@ source (int argc, char *argv[])
- }
- #define RCP_MODEMASK (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)
- snprintf (buf, sizeof buf, "C%04o %jd %s\n",
- - stb.st_mode & RCP_MODEMASK, (intmax_t) stb.st_size, last);
- + (int) stb.st_mode & RCP_MODEMASK, (intmax_t) stb.st_size, last);
- write (rem, buf, strlen (buf));
- if (response () < 0)
- goto next;
- @@ -831,7 +831,7 @@ rsource (char *name, struct stat *statp)
- return;
- }
-
- - sprintf (buf, "D%04o %d %s\n", statp->st_mode & RCP_MODEMASK, 0, last);
- + sprintf (buf, "D%04o %d %s\n", (int) statp->st_mode & RCP_MODEMASK, 0, last);
- write (rem, buf, strlen (buf));
- free (buf);
-
- diff --git a/src/syslogd.c b/src/syslogd.c
- index 352a5bd0..2f4ee416 100644
- --- a/src/syslogd.c
- +++ b/src/syslogd.c
- @@ -1157,9 +1157,9 @@ textpri (int pri)
- static char res[20];
- CODE *c_pri, *c_fac;
-
- - for (c_fac = facilitynames; c_fac->c_name
- + for (c_fac = (CODE *) facilitynames; c_fac->c_name
- && !(c_fac->c_val == LOG_FAC (pri) << 3); c_fac++);
- - for (c_pri = prioritynames; c_pri->c_name
- + for (c_pri = (CODE *) prioritynames; c_pri->c_name
- && !(c_pri->c_val == LOG_PRI (pri)); c_pri++);
-
- snprintf (res, sizeof (res), "%s.%s", c_fac->c_name, c_pri->c_name);
- @@ -2260,7 +2260,7 @@ cfline (const char *line, struct filed *f)
- }
- else
- {
- - pri = decode (bp, prioritynames);
- + pri = decode (bp, (CODE *) prioritynames);
- if (pri < 0 || (pri > LOG_PRIMASK && pri != INTERNAL_NOPRI))
- {
- snprintf (ebuf, sizeof (ebuf),
- @@ -2306,7 +2306,7 @@ cfline (const char *line, struct filed *f)
- }
- else
- {
- - i = decode (buf, facilitynames);
- + i = decode (buf, (CODE *) facilitynames);
-
- if (i < 0 || i > (LOG_NFACILITIES << 3))
- {
- diff --git a/src/traceroute.c b/src/traceroute.c
- index 2a56a53d..54fc8b89 100644
- --- a/src/traceroute.c
- +++ b/src/traceroute.c
- @@ -702,7 +702,7 @@ trace_write (trace_t * t)
- case TRACE_ICMP:
- {
- icmphdr_t hdr;
- - int i;
- + unsigned int i;
-
- /* Deposit deterministic values throughout the header! */
- for (i = 0; i < sizeof (hdr); ++i)
- --
- 2.26.0.292.g33ef6b2f38
|