summaryrefslogtreecommitdiffstats
path: root/sys/sys/ttydefaults.h
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2013-04-09 16:16:34 +0000
committered <ed@FreeBSD.org>2013-04-09 16:16:34 +0000
commite6908177eccfacb8285f916beec706f652d4ac1f (patch)
tree984c9ec0b986d4b7ad1f72e3a3107d82c5a5281c /sys/sys/ttydefaults.h
parentd0006df0dfbf0b45236fce9ccbae1815bae56ac4 (diff)
downloadFreeBSD-src-e6908177eccfacb8285f916beec706f652d4ac1f.zip
FreeBSD-src-e6908177eccfacb8285f916beec706f652d4ac1f.tar.gz
Add static/const keywords to the arrays.
This theoretically allows a compiler to optimize (parts of) the array away if unused. While there, make the array size implicit and use a _Static_assert() to ensure that the definition matches up with the number of elements in the list.
Diffstat (limited to 'sys/sys/ttydefaults.h')
-rw-r--r--sys/sys/ttydefaults.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/sys/ttydefaults.h b/sys/sys/ttydefaults.h
index 409ebc7..82929f9 100644
--- a/sys/sys/ttydefaults.h
+++ b/sys/sys/ttydefaults.h
@@ -95,10 +95,17 @@
* #define TTYDEFCHARS to include an array of default control characters.
*/
#ifdef TTYDEFCHARS
-static cc_t ttydefchars[NCCS] = {
- CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT,
- CERASE2, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT,
- CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE
+
+#include <sys/cdefs.h>
+#include <sys/_termios.h>
+
+static const cc_t ttydefchars[] = {
+ CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT, CERASE2, CINTR,
+ CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT, CDISCARD, CMIN, CTIME,
+ CSTATUS, _POSIX_VDISABLE
};
+_Static_assert(sizeof(ttydefchars) / sizeof(cc_t) == NCCS,
+ "Size of ttydefchars does not match NCCS");
+
#undef TTYDEFCHARS
-#endif
+#endif /* TTYDEFCHARS */
OpenPOWER on IntegriCloud