Merge "Fix google-runtime-int warnings."
am: a1f4a1e
* commit 'a1f4a1ec3319ee1ab869a46805bff63550b56ca7':
Fix google-runtime-int warnings.
Change-Id: If924b2e1b1e7e7bb4317fdca0c583b7de45db397
This commit is contained in:
@@ -596,7 +596,7 @@ size_t FreeSpaceForFile(const char* filename) {
|
|||||||
|
|
||||||
int CacheSizeCheck(size_t bytes) {
|
int CacheSizeCheck(size_t bytes) {
|
||||||
if (MakeFreeSpaceOnCache(bytes) < 0) {
|
if (MakeFreeSpaceOnCache(bytes) < 0) {
|
||||||
printf("unable to make %ld bytes available on /cache\n", (long)bytes);
|
printf("unable to make %zu bytes available on /cache\n", bytes);
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -229,8 +229,8 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||||||
ssize_t have = temp_data.size() - strm.avail_out;
|
ssize_t have = temp_data.size() - strm.avail_out;
|
||||||
|
|
||||||
if (sink(temp_data.data(), have, token) != have) {
|
if (sink(temp_data.data(), have, token) != have) {
|
||||||
printf("failed to write %ld compressed bytes to output\n",
|
printf("failed to write %zd compressed bytes to output\n",
|
||||||
(long)have);
|
have);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ctx) SHA1_Update(ctx, temp_data.data(), have);
|
if (ctx) SHA1_Update(ctx, temp_data.data(), have);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ void Write4(int value, FILE* f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Write an 8-byte value to f in little-endian order. */
|
/** Write an 8-byte value to f in little-endian order. */
|
||||||
void Write8(long long value, FILE* f) {
|
void Write8(int64_t value, FILE* f) {
|
||||||
fputc(value & 0xff, f);
|
fputc(value & 0xff, f);
|
||||||
fputc((value >> 8) & 0xff, f);
|
fputc((value >> 8) & 0xff, f);
|
||||||
fputc((value >> 16) & 0xff, f);
|
fputc((value >> 16) & 0xff, f);
|
||||||
@@ -52,14 +52,14 @@ int Read4(void* pv) {
|
|||||||
(unsigned int)p[0]);
|
(unsigned int)p[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
long long Read8(void* pv) {
|
int64_t Read8(void* pv) {
|
||||||
unsigned char* p = reinterpret_cast<unsigned char*>(pv);
|
unsigned char* p = reinterpret_cast<unsigned char*>(pv);
|
||||||
return (long long)(((unsigned long long)p[7] << 56) |
|
return (int64_t)(((uint64_t)p[7] << 56) |
|
||||||
((unsigned long long)p[6] << 48) |
|
((uint64_t)p[6] << 48) |
|
||||||
((unsigned long long)p[5] << 40) |
|
((uint64_t)p[5] << 40) |
|
||||||
((unsigned long long)p[4] << 32) |
|
((uint64_t)p[4] << 32) |
|
||||||
((unsigned long long)p[3] << 24) |
|
((uint64_t)p[3] << 24) |
|
||||||
((unsigned long long)p[2] << 16) |
|
((uint64_t)p[2] << 16) |
|
||||||
((unsigned long long)p[1] << 8) |
|
((uint64_t)p[1] << 8) |
|
||||||
(unsigned long long)p[0]);
|
(uint64_t)p[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,14 +17,15 @@
|
|||||||
#ifndef _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
#ifndef _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
||||||
#define _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
#define _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
// Read and write little-endian values of various sizes.
|
// Read and write little-endian values of various sizes.
|
||||||
|
|
||||||
void Write4(int value, FILE* f);
|
void Write4(int value, FILE* f);
|
||||||
void Write8(long long value, FILE* f);
|
void Write8(int64_t value, FILE* f);
|
||||||
int Read2(void* p);
|
int Read2(void* p);
|
||||||
int Read4(void* p);
|
int Read4(void* p);
|
||||||
long long Read8(void* p);
|
int64_t Read8(void* p);
|
||||||
|
|
||||||
#endif // _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
#endif // _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
||||||
|
|||||||
@@ -286,13 +286,14 @@ Value* LessThanIntFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
char* end;
|
char* end;
|
||||||
|
|
||||||
long l_int = strtol(left, &end, 10);
|
// Parse up to at least long long or 64-bit integers.
|
||||||
|
int64_t l_int = static_cast<int64_t>(strtoll(left, &end, 10));
|
||||||
if (left[0] == '\0' || *end != '\0') {
|
if (left[0] == '\0' || *end != '\0') {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
long r_int;
|
int64_t r_int;
|
||||||
r_int = strtol(right, &end, 10);
|
r_int = static_cast<int64_t>(strtoll(right, &end, 10));
|
||||||
if (right[0] == '\0' || *end != '\0') {
|
if (right[0] == '\0' || *end != '\0') {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ static unsigned ev_count = 0;
|
|||||||
static unsigned ev_dev_count = 0;
|
static unsigned ev_dev_count = 0;
|
||||||
static unsigned ev_misc_count = 0;
|
static unsigned ev_misc_count = 0;
|
||||||
|
|
||||||
static bool test_bit(size_t bit, unsigned long* array) {
|
static bool test_bit(size_t bit, unsigned long* array) { // NOLINT
|
||||||
return (array[bit/BITS_PER_LONG] & (1UL << (bit % BITS_PER_LONG))) != 0;
|
return (array[bit/BITS_PER_LONG] & (1UL << (bit % BITS_PER_LONG))) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,8 @@ int ev_init(ev_callback input_cb, void* data) {
|
|||||||
if (dir != NULL) {
|
if (dir != NULL) {
|
||||||
dirent* de;
|
dirent* de;
|
||||||
while ((de = readdir(dir))) {
|
while ((de = readdir(dir))) {
|
||||||
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
|
// Use unsigned long to match ioctl's parameter type.
|
||||||
|
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
|
||||||
|
|
||||||
// fprintf(stderr,"/dev/input/%s\n", de->d_name);
|
// fprintf(stderr,"/dev/input/%s\n", de->d_name);
|
||||||
if (strncmp(de->d_name, "event", 5)) continue;
|
if (strncmp(de->d_name, "event", 5)) continue;
|
||||||
@@ -175,8 +176,9 @@ int ev_get_input(int fd, uint32_t epevents, input_event* ev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data) {
|
int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data) {
|
||||||
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
|
// Use unsigned long to match ioctl's parameter type.
|
||||||
unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)];
|
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
|
||||||
|
unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; // NOLINT
|
||||||
|
|
||||||
for (size_t i = 0; i < ev_dev_count; ++i) {
|
for (size_t i = 0; i < ev_dev_count; ++i) {
|
||||||
memset(ev_bits, 0, sizeof(ev_bits));
|
memset(ev_bits, 0, sizeof(ev_bits));
|
||||||
@@ -203,8 +205,9 @@ int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ev_iterate_available_keys(std::function<void(int)> f) {
|
void ev_iterate_available_keys(std::function<void(int)> f) {
|
||||||
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
|
// Use unsigned long to match ioctl's parameter type.
|
||||||
unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)];
|
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
|
||||||
|
unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; // NOLINT
|
||||||
|
|
||||||
for (size_t i = 0; i < ev_dev_count; ++i) {
|
for (size_t i = 0; i < ev_dev_count; ++i) {
|
||||||
memset(ev_bits, 0, sizeof(ev_bits));
|
memset(ev_bits, 0, sizeof(ev_bits));
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ static ssize_t logrotate(
|
|||||||
if (!isdigit(number.data()[0])) {
|
if (!isdigit(number.data()[0])) {
|
||||||
name += ".1";
|
name += ".1";
|
||||||
} else {
|
} else {
|
||||||
unsigned long long i = std::stoull(number);
|
auto i = std::stoull(number);
|
||||||
name = sub + "." + std::to_string(i + 1);
|
name = sub + "." + std::to_string(i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -391,7 +391,7 @@ static void copy_log_file_to_pmsg(const char* source, const char* destination) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// How much of the temp log we have copied to the copy in cache.
|
// How much of the temp log we have copied to the copy in cache.
|
||||||
static long tmplog_offset = 0;
|
static off_t tmplog_offset = 0;
|
||||||
|
|
||||||
static void copy_log_file(const char* source, const char* destination, bool append) {
|
static void copy_log_file(const char* source, const char* destination, bool append) {
|
||||||
FILE* dest_fp = fopen_path(destination, append ? "a" : "w");
|
FILE* dest_fp = fopen_path(destination, append ? "a" : "w");
|
||||||
@@ -401,7 +401,7 @@ static void copy_log_file(const char* source, const char* destination, bool appe
|
|||||||
FILE* source_fp = fopen(source, "r");
|
FILE* source_fp = fopen(source, "r");
|
||||||
if (source_fp != nullptr) {
|
if (source_fp != nullptr) {
|
||||||
if (append) {
|
if (append) {
|
||||||
fseek(source_fp, tmplog_offset, SEEK_SET); // Since last write
|
fseeko(source_fp, tmplog_offset, SEEK_SET); // Since last write
|
||||||
}
|
}
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
size_t bytes;
|
size_t bytes;
|
||||||
@@ -409,7 +409,7 @@ static void copy_log_file(const char* source, const char* destination, bool appe
|
|||||||
fwrite(buf, 1, bytes, dest_fp);
|
fwrite(buf, 1, bytes, dest_fp);
|
||||||
}
|
}
|
||||||
if (append) {
|
if (append) {
|
||||||
tmplog_offset = ftell(source_fp);
|
tmplog_offset = ftello(source_fp);
|
||||||
}
|
}
|
||||||
check_and_fclose(source_fp, source);
|
check_and_fclose(source_fp, source);
|
||||||
}
|
}
|
||||||
@@ -1213,7 +1213,7 @@ static ssize_t logrotate(
|
|||||||
if (!isdigit(number.data()[0])) {
|
if (!isdigit(number.data()[0])) {
|
||||||
name += ".1";
|
name += ".1";
|
||||||
} else {
|
} else {
|
||||||
unsigned long long i = std::stoull(number);
|
auto i = std::stoull(number);
|
||||||
name = sub + "." + std::to_string(i + 1);
|
name = sub + "." + std::to_string(i + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ void ScreenRecoveryUI::ProgressThreadLoop() {
|
|||||||
// minimum of 20ms delay between frames
|
// minimum of 20ms delay between frames
|
||||||
double delay = interval - (end-start);
|
double delay = interval - (end-start);
|
||||||
if (delay < 0.02) delay = 0.02;
|
if (delay < 0.02) delay = 0.02;
|
||||||
usleep((long)(delay * 1000000));
|
usleep(static_cast<useconds_t>(delay * 1000000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,8 +572,8 @@ void ScreenRecoveryUI::ClearText() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScreenRecoveryUI::ShowFile(FILE* fp) {
|
void ScreenRecoveryUI::ShowFile(FILE* fp) {
|
||||||
std::vector<long> offsets;
|
std::vector<off_t> offsets;
|
||||||
offsets.push_back(ftell(fp));
|
offsets.push_back(ftello(fp));
|
||||||
ClearText();
|
ClearText();
|
||||||
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
@@ -583,7 +583,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (show_prompt) {
|
if (show_prompt) {
|
||||||
PrintOnScreenOnly("--(%d%% of %d bytes)--",
|
PrintOnScreenOnly("--(%d%% of %d bytes)--",
|
||||||
static_cast<int>(100 * (double(ftell(fp)) / double(sb.st_size))),
|
static_cast<int>(100 * (double(ftello(fp)) / double(sb.st_size))),
|
||||||
static_cast<int>(sb.st_size));
|
static_cast<int>(sb.st_size));
|
||||||
Redraw();
|
Redraw();
|
||||||
while (show_prompt) {
|
while (show_prompt) {
|
||||||
@@ -602,7 +602,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
|
|||||||
if (feof(fp)) {
|
if (feof(fp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
offsets.push_back(ftell(fp));
|
offsets.push_back(ftello(fp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClearText();
|
ClearText();
|
||||||
|
|||||||
@@ -200,8 +200,9 @@ static int produce_block_map(const char* path, const char* map_file, const char*
|
|||||||
|
|
||||||
std::vector<int> ranges;
|
std::vector<int> ranges;
|
||||||
|
|
||||||
std::string s = android::base::StringPrintf("%s\n%" PRId64 " %ld\n",
|
std::string s = android::base::StringPrintf("%s\n%" PRId64 " %" PRId64 "\n",
|
||||||
blk_dev, sb.st_size, static_cast<long>(sb.st_blksize));
|
blk_dev, static_cast<int64_t>(sb.st_size),
|
||||||
|
static_cast<int64_t>(sb.st_blksize));
|
||||||
if (!android::base::WriteStringToFd(s, mapfd)) {
|
if (!android::base::WriteStringToFd(s, mapfd)) {
|
||||||
ALOGE("failed to write %s: %s", tmp_map_file.c_str(), strerror(errno));
|
ALOGE("failed to write %s: %s", tmp_map_file.c_str(), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -602,8 +602,8 @@ Value* PackageExtractFileFn(const char* name, State* state,
|
|||||||
v->size = mzGetZipEntryUncompLen(entry);
|
v->size = mzGetZipEntryUncompLen(entry);
|
||||||
v->data = reinterpret_cast<char*>(malloc(v->size));
|
v->data = reinterpret_cast<char*>(malloc(v->size));
|
||||||
if (v->data == NULL) {
|
if (v->data == NULL) {
|
||||||
printf("%s: failed to allocate %ld bytes for %s\n",
|
printf("%s: failed to allocate %zd bytes for %s\n",
|
||||||
name, (long)v->size, zip_path);
|
name, v->size, zip_path);
|
||||||
goto done1;
|
goto done1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -992,7 +992,8 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||||||
|
|
||||||
buffer = reinterpret_cast<char*>(malloc(st.st_size+1));
|
buffer = reinterpret_cast<char*>(malloc(st.st_size+1));
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
ErrorAbort(state, "%s: failed to alloc %lld bytes", name, (long long)st.st_size+1);
|
ErrorAbort(state, "%s: failed to alloc %zu bytes", name,
|
||||||
|
static_cast<size_t>(st.st_size+1));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1004,8 +1005,8 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ota_fread(buffer, 1, st.st_size, f) != static_cast<size_t>(st.st_size)) {
|
if (ota_fread(buffer, 1, st.st_size, f) != static_cast<size_t>(st.st_size)) {
|
||||||
ErrorAbort(state, "%s: failed to read %lld bytes from %s",
|
ErrorAbort(state, "%s: failed to read %zu bytes from %s",
|
||||||
name, (long long)st.st_size+1, filename);
|
name, static_cast<size_t>(st.st_size), filename);
|
||||||
ota_fclose(f);
|
ota_fclose(f);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
10
wear_ui.cpp
10
wear_ui.cpp
@@ -320,7 +320,7 @@ void WearRecoveryUI::progress_loop() {
|
|||||||
// minimum of 20ms delay between frames
|
// minimum of 20ms delay between frames
|
||||||
double delay = interval - (end-start);
|
double delay = interval - (end-start);
|
||||||
if (delay < 0.02) delay = 0.02;
|
if (delay < 0.02) delay = 0.02;
|
||||||
usleep((long)(delay * 1000000));
|
usleep(static_cast<useconds_t>(delay * 1000000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -573,8 +573,8 @@ void WearRecoveryUI::Redraw()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WearRecoveryUI::ShowFile(FILE* fp) {
|
void WearRecoveryUI::ShowFile(FILE* fp) {
|
||||||
std::vector<long> offsets;
|
std::vector<off_t> offsets;
|
||||||
offsets.push_back(ftell(fp));
|
offsets.push_back(ftello(fp));
|
||||||
ClearText();
|
ClearText();
|
||||||
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
@@ -584,7 +584,7 @@ void WearRecoveryUI::ShowFile(FILE* fp) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
if (show_prompt) {
|
if (show_prompt) {
|
||||||
Print("--(%d%% of %d bytes)--",
|
Print("--(%d%% of %d bytes)--",
|
||||||
static_cast<int>(100 * (double(ftell(fp)) / double(sb.st_size))),
|
static_cast<int>(100 * (double(ftello(fp)) / double(sb.st_size))),
|
||||||
static_cast<int>(sb.st_size));
|
static_cast<int>(sb.st_size));
|
||||||
Redraw();
|
Redraw();
|
||||||
while (show_prompt) {
|
while (show_prompt) {
|
||||||
@@ -603,7 +603,7 @@ void WearRecoveryUI::ShowFile(FILE* fp) {
|
|||||||
if (feof(fp)) {
|
if (feof(fp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
offsets.push_back(ftell(fp));
|
offsets.push_back(ftello(fp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClearText();
|
ClearText();
|
||||||
|
|||||||
Reference in New Issue
Block a user