[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Clean whitespace in last patch.
commit f1782d9c4c6d0b299d2fb9bb37a58f515aed4abe
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Mon Oct 13 13:20:07 2014 -0400
Clean whitespace in last patch.
---
src/common/util.c | 2 +-
src/test/test_util.c | 99 +++++++++++++++++++++++++-------------------------
2 files changed, 50 insertions(+), 51 deletions(-)
diff --git a/src/common/util.c b/src/common/util.c
index 0ea7095..1d9d99d 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1670,7 +1670,7 @@ format_time_interval(char *out, size_t out_len, long interval)
{
/* We only report seconds if there's no hours. */
long sec = 0, min = 0, hour = 0, day = 0;
-
+
/* -LONG_MIN is LONG_MAX + 1, which causes signed overflow */
if (interval < -LONG_MAX)
interval = LONG_MAX;
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 3fed1f7..8855caf 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -2080,7 +2080,7 @@ test_util_format_time_interval(void *arg)
char dbuf[DBUF_SIZE];
#define T_ "%ld"
long sec, min, hour, day;
-
+
/* we don't care about the exact spelling of the
* second(s), minute(s), hour(s), day(s) labels */
#define LABEL_SIZE 21
@@ -2091,16 +2091,16 @@ test_util_format_time_interval(void *arg)
char label_d[LABEL_SIZE];
#define TL_ T_ " " L_
-
+
int r;
-
+
(void)arg;
-
+
/* In these tests, we're not picky about
* spelling or abbreviations */
-
+
/* seconds: 0, 1, 9, 10, 59 */
-
+
/* ignore exact spelling of "second(s)"*/
format_time_interval(dbuf, sizeof(dbuf), 0);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2108,30 +2108,30 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2);
tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 0);
-
+
format_time_interval(dbuf, sizeof(dbuf), 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s);
tt_int_op(r,==, 2);
tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 1);
-
+
format_time_interval(dbuf, sizeof(dbuf), 10);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s);
tt_int_op(r,==, 2);
tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 10);
-
+
format_time_interval(dbuf, sizeof(dbuf), 59);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s);
tt_int_op(r,==, 2);
tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 59);
-
+
/* negative seconds are reported as their absolute value */
-
+
format_time_interval(dbuf, sizeof(dbuf), -4);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s);
@@ -2139,7 +2139,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 4);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
-
+
format_time_interval(dbuf, sizeof(dbuf), -32);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &sec, label_s);
@@ -2147,9 +2147,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_s[0],==, 's');
tt_int_op(sec,==, 32);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
-
+
/* minutes: 1:00, 1:01, 1:59, 2:00, 2:01, 59:59 */
-
+
/* ignore trailing "0 second(s)", if present */
format_time_interval(dbuf, sizeof(dbuf), 60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2170,7 +2170,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(sec,==, 1);
tt_ci_char_op(label_s[0],==, 's');
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
-
+
format_time_interval(dbuf, sizeof(dbuf), 60*2 - 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_,
@@ -2180,7 +2180,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 59);
tt_ci_char_op(label_s[0],==, 's');
-
+
/* ignore trailing "0 second(s)", if present */
format_time_interval(dbuf, sizeof(dbuf), 60*2);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2188,7 +2188,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2);
tt_int_op(min,==, 2);
tt_ci_char_op(label_m[0],==, 'm');
-
+
/* ignore exact spelling of "minute(s)," and "second(s)" */
format_time_interval(dbuf, sizeof(dbuf), 60*2 + 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2199,7 +2199,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 1);
tt_ci_char_op(label_s[0],==, 's');
-
+
format_time_interval(dbuf, sizeof(dbuf), 60*60 - 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_,
@@ -2209,9 +2209,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 59);
tt_ci_char_op(label_s[0],==, 's');
-
+
/* negative minutes are reported as their absolute value */
-
+
/* ignore trailing "0 second(s)", if present */
format_time_interval(dbuf, sizeof(dbuf), -3*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2219,7 +2219,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2);
tt_int_op(min,==, 3);
tt_ci_char_op(label_m[0],==, 'm');
-
+
/* ignore exact spelling of "minute(s)," and "second(s)" */
format_time_interval(dbuf, sizeof(dbuf), -96);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2230,7 +2230,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 36);
tt_ci_char_op(label_s[0],==, 's');
-
+
format_time_interval(dbuf, sizeof(dbuf), -2815);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_,
@@ -2240,10 +2240,10 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_m[0],==, 'm');
tt_int_op(sec,==, 55);
tt_ci_char_op(label_s[0],==, 's');
-
+
/* hours: 1:00, 1:00:01, 1:01, 23:59, 23:59:59 */
/* always ignore trailing seconds, if present */
-
+
/* ignore trailing "0 minute(s)" etc., if present */
format_time_interval(dbuf, sizeof(dbuf), 60*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2251,14 +2251,14 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2);
tt_int_op(hour,==, 1);
tt_ci_char_op(label_h[0],==, 'h');
-
+
format_time_interval(dbuf, sizeof(dbuf), 60*60 + 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &hour, label_h);
tt_int_op(r,==, 2);
tt_int_op(hour,==, 1);
tt_ci_char_op(label_h[0],==, 'h');
-
+
/* ignore exact spelling of "hour(s)," etc. */
format_time_interval(dbuf, sizeof(dbuf), 60*60 + 60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2269,7 +2269,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 1);
tt_ci_char_op(label_m[0],==, 'm');
-
+
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_,
@@ -2279,7 +2279,7 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 59);
tt_ci_char_op(label_m[0],==, 'm');
-
+
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_,
@@ -2289,9 +2289,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 59);
tt_ci_char_op(label_m[0],==, 'm');
-
+
/* negative hours are reported as their absolute value */
-
+
/* ignore exact spelling of "hour(s)," etc., if present */
format_time_interval(dbuf, sizeof(dbuf), -2*60*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2299,7 +2299,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2);
tt_int_op(hour,==, 2);
tt_ci_char_op(label_h[0],==, 'h');
-
+
format_time_interval(dbuf, sizeof(dbuf), -75804);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_,
@@ -2309,10 +2309,10 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 3);
tt_ci_char_op(label_m[0],==, 'm');
-
+
/* days: 1:00, 1:00:00:01, 1:00:01, 1:01 */
/* always ignore trailing seconds, if present */
-
+
/* ignore trailing "0 hours(s)" etc., if present */
format_time_interval(dbuf, sizeof(dbuf), 24*60*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2320,14 +2320,14 @@ test_util_format_time_interval(void *arg)
tt_int_op(r,==, 2);
tt_int_op(day,==, 1);
tt_ci_char_op(label_d[0],==, 'd');
-
+
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 1);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_, &day, label_d);
tt_int_op(r,==, 2);
tt_int_op(day,==, 1);
tt_ci_char_op(label_d[0],==, 'd');
-
+
/* ignore exact spelling of "days(s)," etc. */
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2347,7 +2347,7 @@ test_util_format_time_interval(void *arg)
}
tt_int_op(min,==, 1);
tt_ci_char_op(label_m[0],==, 'm');
-
+
/* ignore trailing "0 minutes(s)" etc., if present */
format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60*60);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2358,9 +2358,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_d[0],==, 'd');
tt_int_op(hour,==, 1);
tt_ci_char_op(label_h[0],==, 'h');
-
+
/* negative days are reported as their absolute value */
-
+
format_time_interval(dbuf, sizeof(dbuf), -21936184);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
@@ -2372,9 +2372,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 23);
tt_ci_char_op(label_m[0],==, 'm');
-
+
/* periods > 1 year are reported in days (warn?) */
-
+
/* ignore exact spelling of "days(s)," etc., if present */
format_time_interval(dbuf, sizeof(dbuf), 758635154);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2387,9 +2387,9 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 59);
tt_ci_char_op(label_m[0],==, 'm');
-
+
/* negative periods > 1 year are reported in days (warn?) */
-
+
format_time_interval(dbuf, sizeof(dbuf), -1427014922);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
@@ -2401,12 +2401,12 @@ test_util_format_time_interval(void *arg)
tt_ci_char_op(label_h[0],==, 'h');
tt_int_op(min,==, 2);
tt_ci_char_op(label_m[0],==, 'm');
-
+
#if SIZEOF_LONG == 4 || SIZEOF_LONG == 8
/* We can try INT32_MIN/MAX */
/* Always ignore second(s) */
-
+
/* INT32_MAX */
format_time_interval(dbuf, sizeof(dbuf), 2147483647);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2420,7 +2420,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(min,==, 14);
tt_ci_char_op(label_m[0],==, 'm');
/* and 7 seconds - ignored */
-
+
/* INT32_MIN: check that we get the absolute value of interval,
* which doesn't actually fit in int32_t.
* We expect INT32_MAX or INT32_MAX + 1 with 64 bit longs */
@@ -2443,7 +2443,7 @@ test_util_format_time_interval(void *arg)
/* We can try INT64_MIN/MAX */
/* Always ignore second(s) */
-
+
/* INT64_MAX */
format_time_interval(dbuf, sizeof(dbuf), 9223372036854775807L);
tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
@@ -2457,7 +2457,7 @@ test_util_format_time_interval(void *arg)
tt_int_op(min,==, 30);
tt_ci_char_op(label_m[0],==, 'm');
/* and 7 seconds - ignored */
-
+
/* INT64_MIN: check that we get the absolute value of interval,
* which doesn't actually fit in int64_t.
* We expect INT64_MAX */
@@ -2474,11 +2474,10 @@ test_util_format_time_interval(void *arg)
tt_int_op(min,==, 30);
tt_ci_char_op(label_m[0],==, 'm');
/* and 7 or 8 seconds - ignored */
-
+
#endif
-
-done:
+ done:
;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits