*
* Do we also support it?
*/
- if (header.ver < RPCAP_MIN_VERSION ||
- header.ver > RPCAP_MAX_VERSION)
+ if (RPCAP_VERSION_IS_SUPPORTED(header.ver))
{
/*
* No, so there's no version we both support.
#define RPCAP_MIN_VERSION 0
#define RPCAP_MAX_VERSION 0
+/*
+ * Version numbers are unsigned, so if RPCAP_MIN_VERSION is 0, they
+ * are >= the minimum version, by definition; don't check against
+ * RPCAP_MIN_VERSION, as you may get compiler warnings that the
+ * comparison will always succeed.
+ */
+#if RPCAP_MIN_VERSION == 0
+#define RPCAP_VERSION_IS_SUPPORTED(v) ((v) <= RPCAP_MAX_VERSION)
+#else
+#define RPCAP_VERSION_IS_SUPPORTED(v) \
+ ((v) >= RPCAP_MIN_VERSION && (v) <= RPCAP_MAX_VERSION)
+#endif
+
/*
* Separators used for the host list.
*
//
// Did the client specify a version we can handle?
//
- if (header.ver < RPCAP_MIN_VERSION ||
- header.ver > RPCAP_MAX_VERSION)
+ if (RPCAP_VERSION_IS_SUPPORTED(header.ver))
{
//
// Tell them it's not a valid protocol version.
//
uint8 reply_version;
+ //
+ // If RPCAP_MIN_VERSION is 0, no version is too
+ // old, as the oldest supported version is 0,
+ // and there are no negative versions.
+ //
+#if RPCAP_MIN_VERSION != 0
if (header.ver < RPCAP_MIN_VERSION)
{
//
reply_version = header.ver;
}
else
+#endif
{
//
// Their maximum version is too new,