svn commit: r308303 - stable/10/tools/tools/cxgbetool

John Baldwin jhb at FreeBSD.org
Fri Nov 4 18:16:01 UTC 2016


Author: jhb
Date: Fri Nov  4 18:16:00 2016
New Revision: 308303
URL: https://svnweb.freebsd.org/changeset/base/308303

Log:
  MFC 287297,296236: Cleanups to cxgbetool.
  
  287297:
  - Replace N(a)/N(i)/N(T)/LEN(a)/ARRAY_SIZE(a) with nitems()
  - Add missing <err.h> for err() and <sys/sysctl.h> for sysctlbyname()
  - NULL -> 0 for 5th parameter of sysctlbyname()
  
  Note, the original commit touched several files under tools/tools, but
  this commit only includes changes to cxgbetool.
  
  296236:
  Fix some whitespace nits in cxgbetool.c.  No functional change.
  
  Sponsored by:	Chelsio Communications

Modified:
  stable/10/tools/tools/cxgbetool/cxgbetool.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/tools/tools/cxgbetool/cxgbetool.c
==============================================================================
--- stable/10/tools/tools/cxgbetool/cxgbetool.c	Fri Nov  4 17:55:50 2016	(r308302)
+++ stable/10/tools/tools/cxgbetool/cxgbetool.c	Fri Nov  4 18:16:00 2016	(r308303)
@@ -28,29 +28,30 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <stdint.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <errno.h>
-#include <err.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdio.h>
+#include <sys/param.h>
 #include <sys/ioctl.h>
-#include <limits.h>
 #include <sys/mman.h>
-#include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
-#include <net/ethernet.h>
-#include <netinet/in.h>
+
 #include <arpa/inet.h>
+#include <net/ethernet.h>
 #include <net/sff8472.h>
+#include <netinet/in.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 #include "t4_ioctl.h"
 
-#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 #define in_range(val, lo, hi) ( val < 0 || (val <= hi && val >= lo))
 #define	max(x, y) ((x) > (y) ? (x) : (y))
 
@@ -345,7 +346,7 @@ dump_regs_t4(int argc, const char *argv[
 		T4_MODREGS(xgmac)
 	};
 
-	return dump_regs_table(argc, argv, regs, t4_mod, ARRAY_SIZE(t4_mod));
+	return dump_regs_table(argc, argv, regs, t4_mod, nitems(t4_mod));
 }
 #undef T4_MODREGS
 
@@ -360,8 +361,7 @@ dump_regs_t4vf(int argc, const char *arg
 		{ "cim", t4vf_cim_regs },
 	};
 
-	return dump_regs_table(argc, argv, regs, t4vf_mod,
-	    ARRAY_SIZE(t4vf_mod));
+	return dump_regs_table(argc, argv, regs, t4vf_mod, nitems(t4vf_mod));
 }
 
 #define T5_MODREGS(name) { #name, t5_##name##_regs }
@@ -398,7 +398,7 @@ dump_regs_t5(int argc, const char *argv[
 		{ "hma", t5_hma_t5_regs }
 	};
 
-	return dump_regs_table(argc, argv, regs, t5_mod, ARRAY_SIZE(t5_mod));
+	return dump_regs_table(argc, argv, regs, t5_mod, nitems(t5_mod));
 }
 #undef T5_MODREGS
 
@@ -446,47 +446,47 @@ do_show_info_header(uint32_t mode)
 {
 	uint32_t i;
 
-	printf ("%4s %8s", "Idx", "Hits");
+	printf("%4s %8s", "Idx", "Hits");
 	for (i = T4_FILTER_FCoE; i <= T4_FILTER_IP_FRAGMENT; i <<= 1) {
 		switch (mode & i) {
 		case T4_FILTER_FCoE:
-			printf (" FCoE");
+			printf(" FCoE");
 			break;
 
 		case T4_FILTER_PORT:
-			printf (" Port");
+			printf(" Port");
 			break;
 
 		case T4_FILTER_VNIC:
-			printf ("      vld:VNIC");
+			printf("      vld:VNIC");
 			break;
 
 		case T4_FILTER_VLAN:
-			printf ("      vld:VLAN");
+			printf("      vld:VLAN");
 			break;
 
 		case T4_FILTER_IP_TOS:
-			printf ("   TOS");
+			printf("   TOS");
 			break;
 
 		case T4_FILTER_IP_PROTO:
-			printf ("  Prot");
+			printf("  Prot");
 			break;
 
 		case T4_FILTER_ETH_TYPE:
-			printf ("   EthType");
+			printf("   EthType");
 			break;
 
 		case T4_FILTER_MAC_IDX:
-			printf ("  MACIdx");
+			printf("  MACIdx");
 			break;
 
 		case T4_FILTER_MPS_HIT_TYPE:
-			printf (" MPS");
+			printf(" MPS");
 			break;
 
 		case T4_FILTER_IP_FRAGMENT:
-			printf (" Frag");
+			printf(" Frag");
 			break;
 
 		default:
@@ -866,7 +866,7 @@ get_filter_mode(void)
 
 	if (mode & T4_FILTER_IP_SADDR)
 		printf("sip ");
-	
+
 	if (mode & T4_FILTER_IP_DADDR)
 		printf("dip ");
 


More information about the svn-src-all mailing list