Fix google-runtime-int warnings.
Bug: 28220065 Change-Id: Ida199c66692a1638be6990d583d2ed42583fb592
This commit is contained in:
parent
51dcd0da37
commit
54a2747ef3
12 changed files with 53 additions and 46 deletions
|
@ -596,7 +596,7 @@ size_t FreeSpaceForFile(const char* filename) {
|
|||
|
||||
int CacheSizeCheck(size_t bytes) {
|
||||
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;
|
||||
} else {
|
||||
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;
|
||||
|
||||
if (sink(temp_data.data(), have, token) != have) {
|
||||
printf("failed to write %ld compressed bytes to output\n",
|
||||
(long)have);
|
||||
printf("failed to write %zd compressed bytes to output\n",
|
||||
have);
|
||||
return -1;
|
||||
}
|
||||
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. */
|
||||
void Write8(long long value, FILE* f) {
|
||||
void Write8(int64_t value, FILE* f) {
|
||||
fputc(value & 0xff, f);
|
||||
fputc((value >> 8) & 0xff, f);
|
||||
fputc((value >> 16) & 0xff, f);
|
||||
|
@ -52,14 +52,14 @@ int Read4(void* pv) {
|
|||
(unsigned int)p[0]);
|
||||
}
|
||||
|
||||
long long Read8(void* pv) {
|
||||
int64_t Read8(void* pv) {
|
||||
unsigned char* p = reinterpret_cast<unsigned char*>(pv);
|
||||
return (long long)(((unsigned long long)p[7] << 56) |
|
||||
((unsigned long long)p[6] << 48) |
|
||||
((unsigned long long)p[5] << 40) |
|
||||
((unsigned long long)p[4] << 32) |
|
||||
((unsigned long long)p[3] << 24) |
|
||||
((unsigned long long)p[2] << 16) |
|
||||
((unsigned long long)p[1] << 8) |
|
||||
(unsigned long long)p[0]);
|
||||
return (int64_t)(((uint64_t)p[7] << 56) |
|
||||
((uint64_t)p[6] << 48) |
|
||||
((uint64_t)p[5] << 40) |
|
||||
((uint64_t)p[4] << 32) |
|
||||
((uint64_t)p[3] << 24) |
|
||||
((uint64_t)p[2] << 16) |
|
||||
((uint64_t)p[1] << 8) |
|
||||
(uint64_t)p[0]);
|
||||
}
|
||||
|
|
|
@ -17,14 +17,15 @@
|
|||
#ifndef _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
||||
#define _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Read and write little-endian values of various sizes.
|
||||
|
||||
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 Read4(void* p);
|
||||
long long Read8(void* p);
|
||||
int64_t Read8(void* p);
|
||||
|
||||
#endif // _BUILD_TOOLS_APPLYPATCH_UTILS_H
|
||||
|
|
|
@ -286,13 +286,14 @@ Value* LessThanIntFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||
bool result = false;
|
||||
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') {
|
||||
goto done;
|
||||
}
|
||||
|
||||
long r_int;
|
||||
r_int = strtol(right, &end, 10);
|
||||
int64_t r_int;
|
||||
r_int = static_cast<int64_t>(strtoll(right, &end, 10));
|
||||
if (right[0] == '\0' || *end != '\0') {
|
||||
goto done;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ static unsigned ev_count = 0;
|
|||
static unsigned ev_dev_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;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,8 @@ int ev_init(ev_callback input_cb, void* data) {
|
|||
if (dir != NULL) {
|
||||
dirent* de;
|
||||
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);
|
||||
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) {
|
||||
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
|
||||
unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)];
|
||||
// Use unsigned long to match ioctl's parameter type.
|
||||
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) {
|
||||
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) {
|
||||
unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)];
|
||||
unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)];
|
||||
// Use unsigned long to match ioctl's parameter type.
|
||||
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) {
|
||||
memset(ev_bits, 0, sizeof(ev_bits));
|
||||
|
|
|
@ -92,7 +92,7 @@ static ssize_t logrotate(
|
|||
if (!isdigit(number.data()[0])) {
|
||||
name += ".1";
|
||||
} else {
|
||||
unsigned long long i = std::stoull(number);
|
||||
auto i = std::stoull(number);
|
||||
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.
|
||||
static long tmplog_offset = 0;
|
||||
static off_t tmplog_offset = 0;
|
||||
|
||||
static void copy_log_file(const char* source, const char* destination, bool append) {
|
||||
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");
|
||||
if (source_fp != nullptr) {
|
||||
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];
|
||||
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);
|
||||
}
|
||||
if (append) {
|
||||
tmplog_offset = ftell(source_fp);
|
||||
tmplog_offset = ftello(source_fp);
|
||||
}
|
||||
check_and_fclose(source_fp, source);
|
||||
}
|
||||
|
@ -1213,7 +1213,7 @@ static ssize_t logrotate(
|
|||
if (!isdigit(number.data()[0])) {
|
||||
name += ".1";
|
||||
} else {
|
||||
unsigned long long i = std::stoull(number);
|
||||
auto i = std::stoull(number);
|
||||
name = sub + "." + std::to_string(i + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -356,7 +356,7 @@ void ScreenRecoveryUI::ProgressThreadLoop() {
|
|||
// minimum of 20ms delay between frames
|
||||
double delay = interval - (end-start);
|
||||
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) {
|
||||
std::vector<long> offsets;
|
||||
offsets.push_back(ftell(fp));
|
||||
std::vector<off_t> offsets;
|
||||
offsets.push_back(ftello(fp));
|
||||
ClearText();
|
||||
|
||||
struct stat sb;
|
||||
|
@ -583,7 +583,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
|
|||
while (true) {
|
||||
if (show_prompt) {
|
||||
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));
|
||||
Redraw();
|
||||
while (show_prompt) {
|
||||
|
@ -602,7 +602,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
|
|||
if (feof(fp)) {
|
||||
return;
|
||||
}
|
||||
offsets.push_back(ftell(fp));
|
||||
offsets.push_back(ftello(fp));
|
||||
}
|
||||
}
|
||||
ClearText();
|
||||
|
|
|
@ -200,8 +200,9 @@ static int produce_block_map(const char* path, const char* map_file, const char*
|
|||
|
||||
std::vector<int> ranges;
|
||||
|
||||
std::string s = android::base::StringPrintf("%s\n%" PRId64 " %ld\n",
|
||||
blk_dev, sb.st_size, static_cast<long>(sb.st_blksize));
|
||||
std::string s = android::base::StringPrintf("%s\n%" PRId64 " %" PRId64 "\n",
|
||||
blk_dev, static_cast<int64_t>(sb.st_size),
|
||||
static_cast<int64_t>(sb.st_blksize));
|
||||
if (!android::base::WriteStringToFd(s, mapfd)) {
|
||||
ALOGE("failed to write %s: %s", tmp_map_file.c_str(), strerror(errno));
|
||||
return -1;
|
||||
|
|
|
@ -602,8 +602,8 @@ Value* PackageExtractFileFn(const char* name, State* state,
|
|||
v->size = mzGetZipEntryUncompLen(entry);
|
||||
v->data = reinterpret_cast<char*>(malloc(v->size));
|
||||
if (v->data == NULL) {
|
||||
printf("%s: failed to allocate %ld bytes for %s\n",
|
||||
name, (long)v->size, zip_path);
|
||||
printf("%s: failed to allocate %zd bytes for %s\n",
|
||||
name, v->size, zip_path);
|
||||
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));
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
ErrorAbort(state, "%s: failed to read %lld bytes from %s",
|
||||
name, (long long)st.st_size+1, filename);
|
||||
ErrorAbort(state, "%s: failed to read %zu bytes from %s",
|
||||
name, static_cast<size_t>(st.st_size), filename);
|
||||
ota_fclose(f);
|
||||
goto done;
|
||||
}
|
||||
|
|
10
wear_ui.cpp
10
wear_ui.cpp
|
@ -320,7 +320,7 @@ void WearRecoveryUI::progress_loop() {
|
|||
// minimum of 20ms delay between frames
|
||||
double delay = interval - (end-start);
|
||||
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) {
|
||||
std::vector<long> offsets;
|
||||
offsets.push_back(ftell(fp));
|
||||
std::vector<off_t> offsets;
|
||||
offsets.push_back(ftello(fp));
|
||||
ClearText();
|
||||
|
||||
struct stat sb;
|
||||
|
@ -584,7 +584,7 @@ void WearRecoveryUI::ShowFile(FILE* fp) {
|
|||
while (true) {
|
||||
if (show_prompt) {
|
||||
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));
|
||||
Redraw();
|
||||
while (show_prompt) {
|
||||
|
@ -603,7 +603,7 @@ void WearRecoveryUI::ShowFile(FILE* fp) {
|
|||
if (feof(fp)) {
|
||||
return;
|
||||
}
|
||||
offsets.push_back(ftell(fp));
|
||||
offsets.push_back(ftello(fp));
|
||||
}
|
||||
}
|
||||
ClearText();
|
||||
|
|
Loading…
Reference in a new issue