Resolved warning suppression issue in timerDurationString(). It turns out BOTH this AND the solution were both in timer.c, and I somehow did not notice :V

This commit is contained in:
Pietro Gagliardi 2019-06-01 12:05:29 -04:00
parent a8ad49fead
commit efe118a81d
2 changed files with 17 additions and 20 deletions

View File

@ -154,7 +154,7 @@ static bool testingprivTRun(testingT *t, testingprivOutbuf *parentbuf)
return !t->failed;
}
// TODO rename all options to opts and all format to fmt
// TODO rename all options to opts
static void testingprivSetRun(testingSet *set, const testingOptions *opts, testingprivOutbuf *outbuf, bool *anyFailed)
{
size_t i;
@ -188,7 +188,7 @@ void testingprivTLogfFull(testingT *t, const char *file, long line, const char *
{
va_list ap;
va_start(ap, fmt);
va_start(ap, format);
testingprivTLogvfFull(t, file, line, format, ap);
va_end(ap);
}

View File

@ -81,20 +81,20 @@ void timerDurationString(timerDuration d, char buf[timerDurationStringLen])
buf[1] = 's';
return;
}
unsec = (uint64_t) d;
neg = false;
if (d < 0) {
#ifdef _MSC_VER
// TODO figure out a more explicit way to do this; until then, just go with what the standard says should happen, because it's what we want (TODO verify this)
#pragma warning(push)
#pragma warning(disable: 4146)
#endif
unsec = -unsec;
#ifdef _MSC_VER
#pragma warning(pop)
#endif
neg = true;
neg = d < 0;
if (neg) {
// C99 §6.2.6.2 resticts the possible signed integer representations in C to either sign-magnitude, 1's complement, or 2's complement.
// Therefore, INT64_MIN will always be either -INT64_MAX or -INT64_MAX - 1, so we can safely do this to see if we need to special-case INT64_MIN as -INT64_MIN cannot be safely represented, or if we can just say -d as that can be safely represented.
// See also https://stackoverflow.com/questions/29808397/how-to-portably-find-out-minint-max-absint-min
if (d < -INT64_MAX) {
// INT64_MIN is -INT64_MAX - 1.
// This value comes directly from forcing such a value into Go's code; let's just use it.
memmove(buf, "-2562047h47m16.854775808s", (25 + 1) * sizeof (char));
return;
}
unsec = (uint64_t) (-d);
} else
unsec = (uint64_t) d;
for (p = parts; p->suffix != 0; p++) {
if (p->mode == modeMaxAndStop && unsec < p->maxOrMod) {
@ -149,11 +149,8 @@ static void int128FromInt64(int64_t n, timerprivInt128 *out)
}
out->neg = true;
out->high = 0;
// C99 §6.2.6.2 resticts the possible signed integer representations in C to either sign-magnitude, 1's complement, or 2's complement.
// Therefore, INT64_MIN will always be either -INT64_MAX or -INT64_MAX - 1, so we can safely do this to see if we need to special-case INT64_MIN as -INT64_MIN cannot be safely represented, or if we can just say -n as that can be safely represented.
// See also https://stackoverflow.com/questions/29808397/how-to-portably-find-out-minint-max-absint-min
// And now we do the same INT64_MIN/INT64_MAX juggling as above.
if (n < -INT64_MAX) {
// INT64_MIN is -INT64_MAX - 1
out->low = ((uint64_t) INT64_MAX) + 1;
return;
}