aboutsummaryrefslogtreecommitdiff
path: root/sbin/ipfw/ipv6.c
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2020-07-13 17:51:04 +0000
committerMark Johnston <markj@FreeBSD.org>2020-07-13 17:51:04 +0000
commit56707bee4b34c53ade245709397addac02c53726 (patch)
tree1404480bc153c770487682df2bae67600fdda8a4 /sbin/ipfw/ipv6.c
parent329d975c0c8b521bd1500b409f780312335f6f2e (diff)
downloadsrc-56707bee4b34c53ade245709397addac02c53726.tar.gz
src-56707bee4b34c53ade245709397addac02c53726.zip
ipfw(8): Fix most warnings with the default WARNS level.
- Add missing const and static qualifiers. - Avoid shadowing the global "co" by renaming it to "g_co". - Avoid mixing signedness in loop bound checks. - Leave -Wcast-align warnings disabled for now. Reviewed by: ae, melifaro MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D25456
Notes
Notes: svn path=/head/; revision=363164
Diffstat (limited to 'sbin/ipfw/ipv6.c')
-rw-r--r--sbin/ipfw/ipv6.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/sbin/ipfw/ipv6.c b/sbin/ipfw/ipv6.c
index a9259b65a6fa..eea313572f34 100644
--- a/sbin/ipfw/ipv6.c
+++ b/sbin/ipfw/ipv6.c
@@ -85,14 +85,14 @@ print_unreach6_code(struct buf_pr *bp, uint16_t code)
* Print the ip address contained in a command.
*/
void
-print_ip6(struct buf_pr *bp, ipfw_insn_ip6 *cmd)
+print_ip6(struct buf_pr *bp, const ipfw_insn_ip6 *cmd)
{
char trad[255];
struct hostent *he = NULL;
- struct in6_addr *a = &(cmd->addr6);
+ const struct in6_addr *a = &(cmd->addr6);
int len, mb;
- len = F_LEN((ipfw_insn *) cmd) - 1;
+ len = F_LEN((const ipfw_insn *)cmd) - 1;
if (cmd->o.opcode == O_IP6_SRC_ME || cmd->o.opcode == O_IP6_DST_ME) {
bprintf(bp, " me6");
return;
@@ -112,10 +112,11 @@ print_ip6(struct buf_pr *bp, ipfw_insn_ip6 *cmd)
/* mask length */
mb = (cmd->o.opcode == O_IP6_SRC ||
cmd->o.opcode == O_IP6_DST) ? 128:
- contigmask((uint8_t *)&(a[1]), 128);
+ contigmask((const uint8_t *)&(a[1]), 128);
- if (mb == 128 && co.do_resolv)
- he = gethostbyaddr((char *)a, sizeof(*a), AF_INET6);
+ if (mb == 128 && g_co.do_resolv)
+ he = gethostbyaddr((const char *)a, sizeof(*a),
+ AF_INET6);
if (he != NULL) /* resolved to name */
bprintf(bp, "%s", he->h_name);
@@ -142,7 +143,7 @@ fill_icmp6types(ipfw_insn_icmp6 *cmd, char *av, int cblen)
{
uint8_t type;
- CHECK_LENGTH(cblen, F_INSN_SIZE(ipfw_insn_icmp6));
+ CHECK_LENGTH(cblen, (int)F_INSN_SIZE(ipfw_insn_icmp6));
memset(cmd, 0, sizeof(*cmd));
while (*av) {
if (*av == ',')
@@ -165,7 +166,7 @@ fill_icmp6types(ipfw_insn_icmp6 *cmd, char *av, int cblen)
}
void
-print_icmp6types(struct buf_pr *bp, ipfw_insn_u32 *cmd)
+print_icmp6types(struct buf_pr *bp, const ipfw_insn_u32 *cmd)
{
int i, j;
char sep= ' ';
@@ -181,7 +182,7 @@ print_icmp6types(struct buf_pr *bp, ipfw_insn_u32 *cmd)
}
void
-print_flow6id(struct buf_pr *bp, ipfw_insn_u32 *cmd)
+print_flow6id(struct buf_pr *bp, const ipfw_insn_u32 *cmd)
{
uint16_t i, limit = cmd->o.arg1;
char sep = ',';
@@ -257,7 +258,7 @@ fill_ext6hdr( ipfw_insn *cmd, char *av)
}
void
-print_ext6hdr(struct buf_pr *bp, ipfw_insn *cmd )
+print_ext6hdr(struct buf_pr *bp, const ipfw_insn *cmd )
{
char sep = ' ';
@@ -364,7 +365,8 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av, int cblen, struct tidx *tstate)
int masklen;
char md = '\0';
- CHECK_LENGTH(cblen, 1 + len + 2 * F_INSN_SIZE(struct in6_addr));
+ CHECK_LENGTH(cblen,
+ 1 + len + 2 * (int)F_INSN_SIZE(struct in6_addr));
if ((q = strchr(av, ',')) ) {
*q = '\0';
@@ -453,7 +455,8 @@ fill_flow6( ipfw_insn_u32 *cmd, char *av, int cblen)
cmd->d[0] = 0; /* Initializing the base number*/
while (s) {
- CHECK_LENGTH(cblen, F_INSN_SIZE(ipfw_insn_u32) + nflow + 1);
+ CHECK_LENGTH(cblen,
+ (int)F_INSN_SIZE(ipfw_insn_u32) + nflow + 1);
av = strsep( &s, ",") ;
type = strtoul(av, &av, 0);