Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Aug 2016 20:32:02 +0000 (UTC)
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r303678 - head/sbin/pfctl
Message-ID:  <201608022032.u72KW2fO010691@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kp
Date: Tue Aug  2 20:32:02 2016
New Revision: 303678
URL: https://svnweb.freebsd.org/changeset/base/303678

Log:
  pfctl: Use const where possible.
  
  This adds const qualifiers where it is possible.
  
  Submitted by:	Christian Mauderer <christian.mauderer@embedded-brains.de>

Modified:
  head/sbin/pfctl/pfctl.c
  head/sbin/pfctl/pfctl_parser.c
  head/sbin/pfctl/pfctl_radix.c

Modified: head/sbin/pfctl/pfctl.c
==============================================================================
--- head/sbin/pfctl/pfctl.c	Tue Aug  2 20:26:04 2016	(r303677)
+++ head/sbin/pfctl/pfctl.c	Tue Aug  2 20:32:02 2016	(r303678)
@@ -100,7 +100,7 @@ int	 pfctl_ruleset_trans(struct pfctl *,
 int	 pfctl_load_ruleset(struct pfctl *, char *,
 		struct pf_ruleset *, int, int);
 int	 pfctl_load_rule(struct pfctl *, char *, struct pf_rule *, int);
-const char	*pfctl_lookup_option(char *, const char **);
+const char	*pfctl_lookup_option(char *, const char * const *);
 
 struct pf_anchor_global	 pf_anchors;
 struct pf_anchor	 pf_main_anchor;
@@ -111,7 +111,7 @@ const char	*showopt;
 const char	*debugopt;
 char		*anchoropt;
 const char	*optiopt = NULL;
-char		*pf_device = "/dev/pf";
+const char	*pf_device = "/dev/pf";
 char		*ifaceopt;
 char		*tableopt;
 const char	*tblcmdopt;
@@ -203,27 +203,27 @@ static const struct {
 	{ NULL,			NULL }
 };
 
-static const char *clearopt_list[] = {
+static const char * const clearopt_list[] = {
 	"nat", "queue", "rules", "Sources",
 	"states", "info", "Tables", "osfp", "all", NULL
 };
 
-static const char *showopt_list[] = {
+static const char * const showopt_list[] = {
 	"nat", "queue", "rules", "Anchors", "Sources", "states", "info",
 	"Interfaces", "labels", "timeouts", "memory", "Tables", "osfp",
 	"all", NULL
 };
 
-static const char *tblcmdopt_list[] = {
+static const char * const tblcmdopt_list[] = {
 	"kill", "flush", "add", "delete", "load", "replace", "show",
 	"test", "zero", "expire", NULL
 };
 
-static const char *debugopt_list[] = {
+static const char * const debugopt_list[] = {
 	"none", "urgent", "misc", "loud", NULL
 };
 
-static const char *optiopt_list[] = {
+static const char * const optiopt_list[] = {
 	"none", "basic", "profile", NULL
 };
 
@@ -1975,7 +1975,7 @@ pfctl_show_anchors(int dev, int opts, ch
 }
 
 const char *
-pfctl_lookup_option(char *cmd, const char **list)
+pfctl_lookup_option(char *cmd, const char * const *list)
 {
 	if (cmd != NULL && *cmd)
 		for (; *list; list++)

Modified: head/sbin/pfctl/pfctl_parser.c
==============================================================================
--- head/sbin/pfctl/pfctl_parser.c	Tue Aug  2 20:26:04 2016	(r303677)
+++ head/sbin/pfctl/pfctl_parser.c	Tue Aug  2 20:32:02 2016	(r303678)
@@ -76,7 +76,7 @@ struct node_host	*host_v4(const char *, 
 struct node_host	*host_v6(const char *, int);
 struct node_host	*host_dns(const char *, int, int);
 
-const char *tcpflags = "FSRPAUEW";
+const char * const tcpflags = "FSRPAUEW";
 
 static const struct icmptypeent icmp_type[] = {
 	{ "echoreq",	ICMP_ECHO },
@@ -473,10 +473,10 @@ print_pool(struct pf_pool *pool, u_int16
 		printf(" static-port");
 }
 
-const char	*pf_reasons[PFRES_MAX+1] = PFRES_NAMES;
-const char	*pf_lcounters[LCNT_MAX+1] = LCNT_NAMES;
-const char	*pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
-const char	*pf_scounters[FCNT_MAX+1] = FCNT_NAMES;
+const char	* const pf_reasons[PFRES_MAX+1] = PFRES_NAMES;
+const char	* const pf_lcounters[LCNT_MAX+1] = LCNT_NAMES;
+const char	* const pf_fcounters[FCNT_MAX+1] = FCNT_NAMES;
+const char	* const pf_scounters[FCNT_MAX+1] = FCNT_NAMES;
 
 void
 print_status(struct pf_status *s, int opts)

Modified: head/sbin/pfctl/pfctl_radix.c
==============================================================================
--- head/sbin/pfctl/pfctl_radix.c	Tue Aug  2 20:26:04 2016	(r303677)
+++ head/sbin/pfctl/pfctl_radix.c	Tue Aug  2 20:32:02 2016	(r303678)
@@ -401,7 +401,7 @@ pfi_get_ifaces(const char *filter, struc
 
 /* buffer management code */
 
-size_t buf_esize[PFRB_MAX] = { 0,
+const size_t buf_esize[PFRB_MAX] = { 0,
 	sizeof(struct pfr_table), sizeof(struct pfr_tstats),
 	sizeof(struct pfr_addr), sizeof(struct pfr_astats),
 	sizeof(struct pfi_kif), sizeof(struct pfioc_trans_e)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608022032.u72KW2fO010691>