Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: src/common/dwarf/bytereader-inl.h

Issue 1605153004: unittests: fix -Wnarrowing build errors (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: convert to uint8_t Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/common/dwarf/bytereader-inl.h
diff --git a/src/common/dwarf/bytereader-inl.h b/src/common/dwarf/bytereader-inl.h
index 3c167089f7218fac04b7894c6f8c9db79230c916..f6a95751432411cc27f5eedf750626cde446cc49 100644
--- a/src/common/dwarf/bytereader-inl.h
+++ b/src/common/dwarf/bytereader-inl.h
@@ -35,13 +35,11 @@
namespace dwarf2reader {
-inline uint8 ByteReader::ReadOneByte(const char* buffer) const {
+inline uint8 ByteReader::ReadOneByte(const uint8_t *buffer) const {
return buffer[0];
}
-inline uint16 ByteReader::ReadTwoBytes(const char* signed_buffer) const {
- const unsigned char *buffer
- = reinterpret_cast<const unsigned char *>(signed_buffer);
+inline uint16 ByteReader::ReadTwoBytes(const uint8_t *buffer) const {
const uint16 buffer0 = buffer[0];
const uint16 buffer1 = buffer[1];
if (endian_ == ENDIANNESS_LITTLE) {
@@ -51,9 +49,7 @@ inline uint16 ByteReader::ReadTwoBytes(const char* signed_buffer) const {
}
}
-inline uint64 ByteReader::ReadFourBytes(const char* signed_buffer) const {
- const unsigned char *buffer
- = reinterpret_cast<const unsigned char *>(signed_buffer);
+inline uint64 ByteReader::ReadFourBytes(const uint8_t *buffer) const {
const uint32 buffer0 = buffer[0];
const uint32 buffer1 = buffer[1];
const uint32 buffer2 = buffer[2];
@@ -65,9 +61,7 @@ inline uint64 ByteReader::ReadFourBytes(const char* signed_buffer) const {
}
}
-inline uint64 ByteReader::ReadEightBytes(const char* signed_buffer) const {
- const unsigned char *buffer
- = reinterpret_cast<const unsigned char *>(signed_buffer);
+inline uint64 ByteReader::ReadEightBytes(const uint8_t *buffer) const {
const uint64 buffer0 = buffer[0];
const uint64 buffer1 = buffer[1];
const uint64 buffer2 = buffer[2];
@@ -89,12 +83,12 @@ inline uint64 ByteReader::ReadEightBytes(const char* signed_buffer) const {
// information, plus one bit saying whether the number continues or
// not.
-inline uint64 ByteReader::ReadUnsignedLEB128(const char* buffer,
+inline uint64 ByteReader::ReadUnsignedLEB128(const uint8_t *buffer,
size_t* len) const {
uint64 result = 0;
size_t num_read = 0;
unsigned int shift = 0;
- unsigned char byte;
+ uint8_t byte;
do {
byte = *buffer++;
@@ -114,12 +108,12 @@ inline uint64 ByteReader::ReadUnsignedLEB128(const char* buffer,
// Read a signed LEB128 number. These are like regular LEB128
// numbers, except the last byte may have a sign bit set.
-inline int64 ByteReader::ReadSignedLEB128(const char* buffer,
+inline int64 ByteReader::ReadSignedLEB128(const uint8_t *buffer,
size_t* len) const {
int64 result = 0;
unsigned int shift = 0;
size_t num_read = 0;
- unsigned char byte;
+ uint8_t byte;
do {
byte = *buffer++;
@@ -134,18 +128,18 @@ inline int64 ByteReader::ReadSignedLEB128(const char* buffer,
return result;
}
-inline uint64 ByteReader::ReadOffset(const char* buffer) const {
+inline uint64 ByteReader::ReadOffset(const uint8_t *buffer) const {
assert(this->offset_reader_);
return (this->*offset_reader_)(buffer);
}
-inline uint64 ByteReader::ReadAddress(const char* buffer) const {
+inline uint64 ByteReader::ReadAddress(const uint8_t *buffer) const {
assert(this->address_reader_);
return (this->*address_reader_)(buffer);
}
inline void ByteReader::SetCFIDataBase(uint64 section_base,
- const char *buffer_base) {
+ const uint8_t *buffer_base) {
section_base_ = section_base;
buffer_base_ = buffer_base;
have_section_base_ = true;

Powered by Google App Engine
This is Rietveld 408576698