summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-hung Hsieh <chh@google.com>2016-04-19 00:34:41 +0200
committerandroid-build-merger <android-build-merger@google.com>2016-04-19 00:34:41 +0200
commit0231e7016dfe56625d6d01a1de468cd23d9cf01a (patch)
tree543fc407741ac3df540e3bfe4c36688e3bda6d80
parentMerge "Fix IWYU errors." am: 51dcd0d (diff)
parentMerge "Fix google-runtime-int warnings." (diff)
downloadandroid_bootable_recovery-0231e7016dfe56625d6d01a1de468cd23d9cf01a.tar
android_bootable_recovery-0231e7016dfe56625d6d01a1de468cd23d9cf01a.tar.gz
android_bootable_recovery-0231e7016dfe56625d6d01a1de468cd23d9cf01a.tar.bz2
android_bootable_recovery-0231e7016dfe56625d6d01a1de468cd23d9cf01a.tar.lz
android_bootable_recovery-0231e7016dfe56625d6d01a1de468cd23d9cf01a.tar.xz
android_bootable_recovery-0231e7016dfe56625d6d01a1de468cd23d9cf01a.tar.zst
android_bootable_recovery-0231e7016dfe56625d6d01a1de468cd23d9cf01a.zip
Diffstat (limited to '')
-rw-r--r--applypatch/applypatch.cpp2
-rw-r--r--applypatch/imgpatch.cpp4
-rw-r--r--applypatch/utils.cpp20
-rw-r--r--applypatch/utils.h5
-rw-r--r--edify/expr.cpp7
-rw-r--r--minui/events.cpp15
-rw-r--r--recovery-refresh.cpp2
-rw-r--r--recovery.cpp8
-rw-r--r--screen_ui.cpp10
-rw-r--r--uncrypt/uncrypt.cpp5
-rw-r--r--updater/install.cpp11
-rw-r--r--wear_ui.cpp10
12 files changed, 53 insertions, 46 deletions
diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp
index c8594c283..270fde5c4 100644
--- a/applypatch/applypatch.cpp
+++ b/applypatch/applypatch.cpp
@@ -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;
diff --git a/applypatch/imgpatch.cpp b/applypatch/imgpatch.cpp
index 4251c0120..f5aed763d 100644
--- a/applypatch/imgpatch.cpp
+++ b/applypatch/imgpatch.cpp
@@ -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);
diff --git a/applypatch/utils.cpp b/applypatch/utils.cpp
index 4a80be75f..fef250f01 100644
--- a/applypatch/utils.cpp
+++ b/applypatch/utils.cpp
@@ -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]);
}
diff --git a/applypatch/utils.h b/applypatch/utils.h
index bc97f1720..1c34edd97 100644
--- a/applypatch/utils.h
+++ b/applypatch/utils.h
@@ -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
diff --git a/edify/expr.cpp b/edify/expr.cpp
index cd1e08726..c34342f76 100644
--- a/edify/expr.cpp
+++ b/edify/expr.cpp
@@ -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;
}
diff --git a/minui/events.cpp b/minui/events.cpp
index 3b2262a4b..a6b9671ed 100644
--- a/minui/events.cpp
+++ b/minui/events.cpp
@@ -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));
diff --git a/recovery-refresh.cpp b/recovery-refresh.cpp
index 70adc70ee..333367eba 100644
--- a/recovery-refresh.cpp
+++ b/recovery-refresh.cpp
@@ -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);
}
}
diff --git a/recovery.cpp b/recovery.cpp
index 756e1c544..f913dc5b4 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -394,7 +394,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");
@@ -404,7 +404,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;
@@ -412,7 +412,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);
}
@@ -1273,7 +1273,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);
}
}
diff --git a/screen_ui.cpp b/screen_ui.cpp
index b32df3649..cfe36e186 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -379,7 +379,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));
}
}
@@ -613,8 +613,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;
@@ -624,7 +624,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) {
@@ -643,7 +643,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
if (feof(fp)) {
return;
}
- offsets.push_back(ftell(fp));
+ offsets.push_back(ftello(fp));
}
}
ClearText();
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index 0e14da13f..5697712aa 100644
--- a/uncrypt/uncrypt.cpp
+++ b/uncrypt/uncrypt.cpp
@@ -262,8 +262,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;
diff --git a/updater/install.cpp b/updater/install.cpp
index 925604f31..4f5268401 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -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;
}
diff --git a/wear_ui.cpp b/wear_ui.cpp
index 2502313ff..5451ed1aa 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -277,7 +277,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));
}
}
@@ -500,8 +500,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;
@@ -511,7 +511,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) {
@@ -530,7 +530,7 @@ void WearRecoveryUI::ShowFile(FILE* fp) {
if (feof(fp)) {
return;
}
- offsets.push_back(ftell(fp));
+ offsets.push_back(ftello(fp));
}
}
ClearText();