signed_relts_print(netdissect_options *ndo,
int32_t secs)
{
- if (secs == -2147483648) {
- /*
- * -2^31; you can't fit its absolute value into a 32-bit
- * signed integer.
- *
- * We calculate the right string by hand.
- */
- ND_PRINT((ndo, "-68y5w3h14m8s"));
- return;
- }
if (secs < 0) {
- /*
- * We now know -secs will fit into secs.
- */
ND_PRINT((ndo, "-"));
- secs = -secs;
+ if (secs == -2147483648) {
+ /*
+ * -2^31; you can't fit its absolute value into
+ * a 32-bit signed integer.
+ *
+ * Just directly pass said absolute value to
+ * unsigned_relts_print() directly.
+ *
+ * (XXX - does ISO C guarantee that -(-2^n),
+ * when calculated and cast to an n-bit unsigned
+ * integer type, will have the value 2^n?)
+ */
+ unsigned_relts_print(ndo, 2147483648U);
+ } else {
+ /*
+ * We now know -secs will fit into an int32_t;
+ * negate it and pass that to unsigned_relts_print().
+ */
+ unsigned_relts_print(ndo, -secs);
+ }
+ return;
}
unsigned_relts_print(ndo, secs);
}