Various compiler warnings.

This commit is contained in:
Mats Erik Andersson
2020-02-21 17:47:49 +01:00
parent c1f18548f7
commit a9d1edfd47
8 changed files with 33 additions and 14 deletions

View File

@@ -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-02-20 Mats Erik Andersson <gnu@gisladisker.se>
rexecd, rshd: Avoid false failure message.

View File

@@ -137,7 +137,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);

View File

@@ -333,7 +333,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;

View File

@@ -90,7 +90,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;
@@ -115,7 +115,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");
@@ -159,7 +159,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;

View File

@@ -114,9 +114,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);
}

View File

@@ -744,7 +744,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;
@@ -829,7 +829,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);

View File

@@ -1155,9 +1155,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);
@@ -2258,7 +2258,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),
@@ -2304,7 +2304,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))
{

View File

@@ -701,7 +701,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)