diff options
author | Karl Ramm <kcr@1ts.org> | 2011-02-02 05:26:20 +0000 |
---|---|---|
committer | Karl Ramm <kcr@1ts.org> | 2011-02-02 05:26:20 +0000 |
commit | fc8b21401978bf891fbd13855ac6c8b1f07bae3c (patch) | |
tree | 86a6724b9fde96edb413572f340411cc6e1a2968 | |
parent | 819ad52b9f100d870fa0e0b8274a6c1b6d3e1881 (diff) |
Explicitly define ZNotice_Kind constants + actually define the promised strings
Since these are constants used in the protocol be explicit about what values
the C compiler is assigning them, and that they can't be arbitrarily
rearranged.
Also, since we were promising strings for describing them in zephyr.h
actually define the array.
-rw-r--r-- | h/zephyr/zephyr.h | 5 | ||||
-rw-r--r-- | lib/Zinternal.c | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/h/zephyr/zephyr.h b/h/zephyr/zephyr.h index ac42bb0..f23bb19 100644 --- a/h/zephyr/zephyr.h +++ b/h/zephyr/zephyr.h @@ -59,9 +59,10 @@ typedef char ZPacket_t[Z_MAXPKTLEN]; /* Packet type */ typedef enum { - UNSAFE, UNACKED, ACKED, HMACK, HMCTL, SERVACK, SERVNAK, CLIENTACK, STAT + UNSAFE = 0, UNACKED = 1, ACKED = 2, HMACK = 3, HMCTL = 4, SERVACK = 5, + SERVNAK = 6, CLIENTACK = 7, STAT = 8 } ZNotice_Kind_t; -extern const char *ZNoticeKinds[9]; +extern const char * const ZNoticeKinds[9]; struct _ZTimeval { int tv_sec; diff --git a/lib/Zinternal.c b/lib/Zinternal.c index f7fc940..119f731 100644 --- a/lib/Zinternal.c +++ b/lib/Zinternal.c @@ -1273,13 +1273,11 @@ Code_t Z_XmitFragment(ZNotice_t *notice, return(ZSendPacket(buf, len, wait)); } -#ifdef Z_DEBUG /* For debugging printing */ const char *const ZNoticeKinds[] = { "UNSAFE", "UNACKED", "ACKED", "HMACK", "HMCTL", "SERVACK", "SERVNAK", "CLIENTACK", "STAT" }; -#endif #ifdef Z_DEBUG |