Fix Windows build after f09d0cde00a1

While building crashpad_database_util.cc:

…\crashpad\tools\crashpad_database_util.cc(150) : error C3861: 'gettimeofday': identifier not found

util/win/time.h has its own GetTimeOfDay() to provide this missing
function on Windows. I don’t know why it’s not in compat. Even so, it
doesn’t return a value, so it’d be unsuitable for use in the PCHECK().
Go back to time() with an errno test.

While building string_number_conversion_test.cc:

…\crashpad\util\stdlib\string_number_conversion_test.cc(242) : error C2220: warning treated as error - no 'object' file generated
…\crashpad\util\stdlib\string_number_conversion_test.cc(242) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
…\crashpad\util\stdlib\string_number_conversion_test.cc(243) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
…\crashpad\util\stdlib\string_number_conversion_test.cc(244) : warning C4146: unary minus operator applied to unsigned type, result still unsigned

Use INT64_C(), and remove a duplicate test case.

Change-Id: I308db9856e492604c7462238cb8b7b66731f0cfe
Reviewed-on: https://chromium-review.googlesource.com/411331
Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
Mark Mentovai 2016-11-15 14:12:23 -05:00
parent f09d0cde00
commit 5a21fc1573
2 changed files with 5 additions and 7 deletions

View File

@ -12,12 +12,12 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <sys/time.h>
#include <sys/types.h>
#include <time.h>
@ -146,9 +146,8 @@ bool StringToTime(const char* string, time_t* out_time, bool utc) {
}
if (strcasecmp(string, "now") == 0) {
timeval tv;
PCHECK(gettimeofday(&tv, nullptr) == 0);
*out_time = tv.tv_sec;
errno = 0;
PCHECK(time(out_time) != -1 || errno == 0);
return true;
}

View File

@ -239,9 +239,8 @@ TEST(StringNumberConversion, StringToInt64) {
{"18446744073709551615", false, 0},
{"18446744073709551616", false, 0},
{"-1", true, -1},
{"-2147483648", true, -2147483648},
{"-2147483649", true, -2147483649},
{"-2147483648", true, -2147483648},
{"-2147483648", true, INT64_C(-2147483648)},
{"-2147483649", true, INT64_C(-2147483649)},
{"-9223372036854775808", true, std::numeric_limits<int64_t>::min()},
{"-9223372036854775809", false, 0},
{"0x7fffffffffffffff", true, std::numeric_limits<int64_t>::max()},