Fix a number of WARNS, including printf, constness and unsigned comparison
warnings.
This commit is contained in:
parent
21e1f59618
commit
fd8c668afc
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=170513
@ -234,13 +234,13 @@ parse(char *string)
|
|||||||
if (strcmp(fmt, "IK") == 0) {
|
if (strcmp(fmt, "IK") == 0) {
|
||||||
if (!set_IK(newval, &intval))
|
if (!set_IK(newval, &intval))
|
||||||
errx(1, "invalid value '%s'",
|
errx(1, "invalid value '%s'",
|
||||||
newval);
|
(char *)newval);
|
||||||
} else {
|
} else {
|
||||||
intval = (int)strtol(newval, &endptr,
|
intval = (int)strtol(newval, &endptr,
|
||||||
0);
|
0);
|
||||||
if (endptr == newval || *endptr != '\0')
|
if (endptr == newval || *endptr != '\0')
|
||||||
errx(1, "invalid integer '%s'",
|
errx(1, "invalid integer '%s'",
|
||||||
newval);
|
(char *)newval);
|
||||||
}
|
}
|
||||||
newval = &intval;
|
newval = &intval;
|
||||||
newsize = sizeof(intval);
|
newsize = sizeof(intval);
|
||||||
@ -249,7 +249,7 @@ parse(char *string)
|
|||||||
uintval = (int) strtoul(newval, &endptr, 0);
|
uintval = (int) strtoul(newval, &endptr, 0);
|
||||||
if (endptr == newval || *endptr != '\0')
|
if (endptr == newval || *endptr != '\0')
|
||||||
errx(1, "invalid unsigned integer '%s'",
|
errx(1, "invalid unsigned integer '%s'",
|
||||||
newval);
|
(char *)newval);
|
||||||
newval = &uintval;
|
newval = &uintval;
|
||||||
newsize = sizeof(uintval);
|
newsize = sizeof(uintval);
|
||||||
break;
|
break;
|
||||||
@ -257,7 +257,7 @@ parse(char *string)
|
|||||||
longval = strtol(newval, &endptr, 0);
|
longval = strtol(newval, &endptr, 0);
|
||||||
if (endptr == newval || *endptr != '\0')
|
if (endptr == newval || *endptr != '\0')
|
||||||
errx(1, "invalid long integer '%s'",
|
errx(1, "invalid long integer '%s'",
|
||||||
newval);
|
(char *)newval);
|
||||||
newval = &longval;
|
newval = &longval;
|
||||||
newsize = sizeof(longval);
|
newsize = sizeof(longval);
|
||||||
break;
|
break;
|
||||||
@ -265,7 +265,7 @@ parse(char *string)
|
|||||||
ulongval = strtoul(newval, &endptr, 0);
|
ulongval = strtoul(newval, &endptr, 0);
|
||||||
if (endptr == newval || *endptr != '\0')
|
if (endptr == newval || *endptr != '\0')
|
||||||
errx(1, "invalid unsigned long integer"
|
errx(1, "invalid unsigned long integer"
|
||||||
" '%s'", newval);
|
" '%s'", (char *)newval);
|
||||||
newval = &ulongval;
|
newval = &ulongval;
|
||||||
newsize = sizeof(ulongval);
|
newsize = sizeof(ulongval);
|
||||||
break;
|
break;
|
||||||
@ -539,7 +539,8 @@ static int
|
|||||||
show_var(int *oid, int nlen)
|
show_var(int *oid, int nlen)
|
||||||
{
|
{
|
||||||
u_char buf[BUFSIZ], *val, *oval, *p;
|
u_char buf[BUFSIZ], *val, *oval, *p;
|
||||||
char name[BUFSIZ], *fmt, *sep;
|
char name[BUFSIZ], *fmt;
|
||||||
|
const char *sep, *sep1;
|
||||||
int qoid[CTL_MAXNAME+2];
|
int qoid[CTL_MAXNAME+2];
|
||||||
uintmax_t umv;
|
uintmax_t umv;
|
||||||
intmax_t mv;
|
intmax_t mv;
|
||||||
@ -628,7 +629,7 @@ show_var(int *oid, int nlen)
|
|||||||
case 'L': intlen = sizeof(long); flen = 18; break;
|
case 'L': intlen = sizeof(long); flen = 18; break;
|
||||||
case 'Q': intlen = sizeof(quad_t); flen = 18; break;
|
case 'Q': intlen = sizeof(quad_t); flen = 18; break;
|
||||||
}
|
}
|
||||||
val = "";
|
sep1 = "";
|
||||||
while (len >= intlen) {
|
while (len >= intlen) {
|
||||||
switch (*fmt) {
|
switch (*fmt) {
|
||||||
case 'I':
|
case 'I':
|
||||||
@ -644,19 +645,19 @@ show_var(int *oid, int nlen)
|
|||||||
memcpy(&qv, p, intlen); mv = qv;
|
memcpy(&qv, p, intlen); mv = qv;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fputs(val, stdout);
|
fputs(sep1, stdout);
|
||||||
if (fmt[1] == 'U')
|
if (fmt[1] == 'U')
|
||||||
printf(hflag ? "%'ju" : "%ju", umv);
|
printf(hflag ? "%'ju" : "%ju", umv);
|
||||||
else if (fmt[1] == 'X')
|
else if (fmt[1] == 'X')
|
||||||
printf(hflag ? "%'#0*jx" : "%#0*jx", flen, umv);
|
printf("%#0*jx", flen, umv);
|
||||||
else if (fmt[1] == 'K') {
|
else if (fmt[1] == 'K') {
|
||||||
if (*(int *)p < 0)
|
if (*(int *)p < 0)
|
||||||
printf("%jd", mv);
|
printf("%jd", mv);
|
||||||
else
|
else
|
||||||
printf("%.1fC", (mv - 2732.0) / 10);
|
printf("%.1fC", (mv - 2732.0) / 10);
|
||||||
} else
|
} else
|
||||||
printf(hflag ? "%'d" : "%d", mv);
|
printf(hflag ? "%'jd" : "%jd", mv);
|
||||||
val = " ";
|
sep1 = " ";
|
||||||
len -= intlen;
|
len -= intlen;
|
||||||
p += intlen;
|
p += intlen;
|
||||||
}
|
}
|
||||||
@ -741,7 +742,7 @@ sysctl_all(int *oid, int len)
|
|||||||
|
|
||||||
l2 /= sizeof(int);
|
l2 /= sizeof(int);
|
||||||
|
|
||||||
if (l2 < len)
|
if (len < 0 || l2 < (unsigned int)len)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user