aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-08-24 18:41:24 -0700
committerGuy Harris <gharris@sonic.net>2022-08-25 01:42:31 +0000
commitbb8d23192e8c4261487fd365ded3ed4800470e20 (patch)
tree95f5c7a5a9d8850ce841f837d0fa12aa16f6ef82 /wiretap
parentd8e877f6104111cec878908065c6b04c4f1e49a5 (diff)
Add a comment explaining WTAP_NSTIME_32BIT_SECS_MAX.
Diffstat (limited to 'wiretap')
-rw-r--r--wiretap/wtap.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 739367f777..8e55bb6ad5 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1338,6 +1338,28 @@ typedef struct {
#define BBLOG_TYPE_EVENT_BLOCK 1
#define BBLOG_TYPE_SKIPPED_BLOCK 2
+/*
+ * The largest nstime.secs value that can be put into an unsigned
+ * 32-bit quantity.
+ *
+ * We assume that time_t is signed; it is signed on Windows/MSVC and
+ * on many UN*Xes.
+ *
+ * So, if time_t is 32-bit, we define this as G_MAXINT32, as that's
+ * the largest value a time_t can have, and it fits in an unsigned
+ * 32-bit quantity. If it's 64-bit or larger, we define this as
+ * G_MAXUINT32, as, even if it's signed, it can be as large as
+ * G_MAXUINT32, and that's the largest value that can fit in
+ * a 32-bit unsigned quantity.
+ *
+ * Comparing against this, rather than against G_MAXINT2, when checking
+ * whether a time stamp will fit in a 32-bit unsigned integer seconds
+ * field in a capture file being written avoids signed vs. unsigned
+ * warnings if time_t is a signed 32-bit type.
+ *
+ * XXX - what if time_t is unsigned? Are there any platforms where
+ * it is?
+ */
#define WTAP_NSTIME_32BIT_SECS_MAX ((time_t)(sizeof(time_t) > sizeof(gint32) ? G_MAXUINT32 : G_MAXINT32))
typedef struct {