diff options
author | ed <ed@FreeBSD.org> | 2013-04-09 16:16:34 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2013-04-09 16:16:34 +0000 |
commit | e6908177eccfacb8285f916beec706f652d4ac1f (patch) | |
tree | 984c9ec0b986d4b7ad1f72e3a3107d82c5a5281c /include | |
parent | d0006df0dfbf0b45236fce9ccbae1815bae56ac4 (diff) | |
download | FreeBSD-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 'include')
-rw-r--r-- | include/protocols/timed.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/protocols/timed.h b/include/protocols/timed.h index 18747be..d26b4a2 100644 --- a/include/protocols/timed.h +++ b/include/protocols/timed.h @@ -90,11 +90,13 @@ struct tsp { #define TSPTYPENUMBER 25 #ifdef TSPTYPES -const char *tsptype[TSPTYPENUMBER] = +static char const * const tsptype[] = { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP", "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT", "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ", "TEST", "SETDATE", "SETDATEREQ", "LOOP" }; +_Static_assert(sizeof(tsptype) / sizeof(const char *) == TSPTYPENUMBER, + "Size of tsptype does not match TSPTYPENUMBER"); #endif #endif /* !_TIMED_H_ */ |