aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 c8594c28..270fde5c 100644
--- a/applypatch/applypatch.cpp
+++ b/applypatch/applypatch.cpp
@@ -596,7 +596,7 @@ size_t FreeSpaceForFile(const char* filename) {
596 596
597int CacheSizeCheck(size_t bytes) { 597int CacheSizeCheck(size_t bytes) {
598 if (MakeFreeSpaceOnCache(bytes) < 0) { 598 if (MakeFreeSpaceOnCache(bytes) < 0) {
599 printf("unable to make %ld bytes available on /cache\n", (long)bytes); 599 printf("unable to make %zu bytes available on /cache\n", bytes);
600 return 1; 600 return 1;
601 } else { 601 } else {
602 return 0; 602 return 0;
diff --git a/applypatch/imgpatch.cpp b/applypatch/imgpatch.cpp
index 4251c012..f5aed763 100644
--- a/applypatch/imgpatch.cpp
+++ b/applypatch/imgpatch.cpp
@@ -229,8 +229,8 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
229 ssize_t have = temp_data.size() - strm.avail_out; 229 ssize_t have = temp_data.size() - strm.avail_out;
230 230
231 if (sink(temp_data.data(), have, token) != have) { 231 if (sink(temp_data.data(), have, token) != have) {
232 printf("failed to write %ld compressed bytes to output\n", 232 printf("failed to write %zd compressed bytes to output\n",
233 (long)have); 233 have);
234 return -1; 234 return -1;
235 } 235 }
236 if (ctx) SHA1_Update(ctx, temp_data.data(), have); 236 if (ctx) SHA1_Update(ctx, temp_data.data(), have);
diff --git a/applypatch/utils.cpp b/applypatch/utils.cpp
index 4a80be75..fef250f0 100644
--- a/applypatch/utils.cpp
+++ b/applypatch/utils.cpp
@@ -27,7 +27,7 @@ void Write4(int value, FILE* f) {
27} 27}
28 28
29/** Write an 8-byte value to f in little-endian order. */ 29/** Write an 8-byte value to f in little-endian order. */
30void Write8(long long value, FILE* f) { 30void Write8(int64_t value, FILE* f) {
31 fputc(value & 0xff, f); 31 fputc(value & 0xff, f);
32 fputc((value >> 8) & 0xff, f); 32 fputc((value >> 8) & 0xff, f);
33 fputc((value >> 16) & 0xff, f); 33 fputc((value >> 16) & 0xff, f);
@@ -52,14 +52,14 @@ int Read4(void* pv) {
52 (unsigned int)p[0]); 52 (unsigned int)p[0]);
53} 53}
54 54
55long long Read8(void* pv) { 55int64_t Read8(void* pv) {
56 unsigned char* p = reinterpret_cast<unsigned char*>(pv); 56 unsigned char* p = reinterpret_cast<unsigned char*>(pv);
57 return (long long)(((unsigned long long)p[7] << 56) | 57 return (int64_t)(((uint64_t)p[7] << 56) |
58 ((unsigned long long)p[6] << 48) | 58 ((uint64_t)p[6] << 48) |
59 ((unsigned long long)p[5] << 40) | 59 ((uint64_t)p[5] << 40) |
60 ((unsigned long long)p[4] << 32) | 60 ((uint64_t)p[4] << 32) |
61 ((unsigned long long)p[3] << 24) | 61 ((uint64_t)p[3] << 24) |
62 ((unsigned long long)p[2] << 16) | 62 ((uint64_t)p[2] << 16) |
63 ((unsigned long long)p[1] << 8) | 63 ((uint64_t)p[1] << 8) |
64 (unsigned long long)p[0]); 64 (uint64_t)p[0]);
65} 65}
diff --git a/applypatch/utils.h b/applypatch/utils.h
index bc97f172..1c34edd9 100644
--- a/applypatch/utils.h
+++ b/applypatch/utils.h
@@ -17,14 +17,15 @@
17#ifndef _BUILD_TOOLS_APPLYPATCH_UTILS_H 17#ifndef _BUILD_TOOLS_APPLYPATCH_UTILS_H
18#define _BUILD_TOOLS_APPLYPATCH_UTILS_H 18#define _BUILD_TOOLS_APPLYPATCH_UTILS_H
19 19
20#include <inttypes.h>
20#include <stdio.h> 21#include <stdio.h>
21 22
22// Read and write little-endian values of various sizes. 23// Read and write little-endian values of various sizes.
23 24
24void Write4(int value, FILE* f); 25void Write4(int value, FILE* f);
25void Write8(long long value, FILE* f); 26void Write8(int64_t value, FILE* f);
26int Read2(void* p); 27int Read2(void* p);
27int Read4(void* p); 28int Read4(void* p);
28long long Read8(void* p); 29int64_t Read8(void* p);
29 30
30#endif // _BUILD_TOOLS_APPLYPATCH_UTILS_H 31#endif // _BUILD_TOOLS_APPLYPATCH_UTILS_H
diff --git a/edify/expr.cpp b/edify/expr.cpp
index cd1e0872..c34342f7 100644
--- a/edify/expr.cpp
+++ b/edify/expr.cpp
@@ -286,13 +286,14 @@ Value* LessThanIntFn(const char* name, State* state, int argc, Expr* argv[]) {
286 bool result = false; 286 bool result = false;
287 char* end; 287 char* end;
288 288
289 long l_int = strtol(left, &end, 10); 289 // Parse up to at least long long or 64-bit integers.
290 int64_t l_int = static_cast<int64_t>(strtoll(left, &end, 10));
290 if (left[0] == '\0' || *end != '\0') { 291 if (left[0] == '\0' || *end != '\0') {
291 goto done; 292 goto done;
292 } 293 }
293 294
294 long r_int; 295 int64_t r_int;
295 r_int = strtol(right, &end, 10); 296 r_int = static_cast<int64_t>(strtoll(right, &end, 10));
296 if (right[0] == '\0' || *end != '\0') { 297 if (right[0] == '\0' || *end != '\0') {
297 goto done; 298 goto done;
298 } 299 }
diff --git a/minui/events.cpp b/minui/events.cpp
index 3b2262a4..a6b9671e 100644
--- a/minui/events.cpp
+++ b/minui/events.cpp
@@ -49,7 +49,7 @@ static unsigned ev_count = 0;
49static unsigned ev_dev_count = 0; 49static unsigned ev_dev_count = 0;
50static unsigned ev_misc_count = 0; 50static unsigned ev_misc_count = 0;
51 51
52static bool test_bit(size_t bit, unsigned long* array) { 52static bool test_bit(size_t bit, unsigned long* array) { // NOLINT
53 return (array[bit/BITS_PER_LONG] & (1UL << (bit % BITS_PER_LONG))) != 0; 53 return (array[bit/BITS_PER_LONG] & (1UL << (bit % BITS_PER_LONG))) != 0;
54} 54}
55 55
@@ -65,7 +65,8 @@ int ev_init(ev_callback input_cb, void* data) {
65 if (dir != NULL) { 65 if (dir != NULL) {
66 dirent* de; 66 dirent* de;
67 while ((de = readdir(dir))) { 67 while ((de = readdir(dir))) {
68 unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; 68 // Use unsigned long to match ioctl's parameter type.
69 unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
69 70
70// fprintf(stderr,"/dev/input/%s\n", de->d_name); 71// fprintf(stderr,"/dev/input/%s\n", de->d_name);
71 if (strncmp(de->d_name, "event", 5)) continue; 72 if (strncmp(de->d_name, "event", 5)) continue;
@@ -175,8 +176,9 @@ int ev_get_input(int fd, uint32_t epevents, input_event* ev) {
175} 176}
176 177
177int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data) { 178int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data) {
178 unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; 179 // Use unsigned long to match ioctl's parameter type.
179 unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; 180 unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
181 unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; // NOLINT
180 182
181 for (size_t i = 0; i < ev_dev_count; ++i) { 183 for (size_t i = 0; i < ev_dev_count; ++i) {
182 memset(ev_bits, 0, sizeof(ev_bits)); 184 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) {
203} 205}
204 206
205void ev_iterate_available_keys(std::function<void(int)> f) { 207void ev_iterate_available_keys(std::function<void(int)> f) {
206 unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; 208 // Use unsigned long to match ioctl's parameter type.
207 unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; 209 unsigned long ev_bits[BITS_TO_LONGS(EV_MAX)]; // NOLINT
210 unsigned long key_bits[BITS_TO_LONGS(KEY_MAX)]; // NOLINT
208 211
209 for (size_t i = 0; i < ev_dev_count; ++i) { 212 for (size_t i = 0; i < ev_dev_count; ++i) {
210 memset(ev_bits, 0, sizeof(ev_bits)); 213 memset(ev_bits, 0, sizeof(ev_bits));
diff --git a/recovery-refresh.cpp b/recovery-refresh.cpp
index 70adc70e..333367eb 100644
--- a/recovery-refresh.cpp
+++ b/recovery-refresh.cpp
@@ -92,7 +92,7 @@ static ssize_t logrotate(
92 if (!isdigit(number.data()[0])) { 92 if (!isdigit(number.data()[0])) {
93 name += ".1"; 93 name += ".1";
94 } else { 94 } else {
95 unsigned long long i = std::stoull(number); 95 auto i = std::stoull(number);
96 name = sub + "." + std::to_string(i + 1); 96 name = sub + "." + std::to_string(i + 1);
97 } 97 }
98 } 98 }
diff --git a/recovery.cpp b/recovery.cpp
index 169413ad..20c6ca11 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -391,7 +391,7 @@ static void copy_log_file_to_pmsg(const char* source, const char* destination) {
391} 391}
392 392
393// How much of the temp log we have copied to the copy in cache. 393// How much of the temp log we have copied to the copy in cache.
394static long tmplog_offset = 0; 394static off_t tmplog_offset = 0;
395 395
396static void copy_log_file(const char* source, const char* destination, bool append) { 396static void copy_log_file(const char* source, const char* destination, bool append) {
397 FILE* dest_fp = fopen_path(destination, append ? "a" : "w"); 397 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
401 FILE* source_fp = fopen(source, "r"); 401 FILE* source_fp = fopen(source, "r");
402 if (source_fp != nullptr) { 402 if (source_fp != nullptr) {
403 if (append) { 403 if (append) {
404 fseek(source_fp, tmplog_offset, SEEK_SET); // Since last write 404 fseeko(source_fp, tmplog_offset, SEEK_SET); // Since last write
405 } 405 }
406 char buf[4096]; 406 char buf[4096];
407 size_t bytes; 407 size_t bytes;
@@ -409,7 +409,7 @@ static void copy_log_file(const char* source, const char* destination, bool appe
409 fwrite(buf, 1, bytes, dest_fp); 409 fwrite(buf, 1, bytes, dest_fp);
410 } 410 }
411 if (append) { 411 if (append) {
412 tmplog_offset = ftell(source_fp); 412 tmplog_offset = ftello(source_fp);
413 } 413 }
414 check_and_fclose(source_fp, source); 414 check_and_fclose(source_fp, source);
415 } 415 }
@@ -1213,7 +1213,7 @@ static ssize_t logrotate(
1213 if (!isdigit(number.data()[0])) { 1213 if (!isdigit(number.data()[0])) {
1214 name += ".1"; 1214 name += ".1";
1215 } else { 1215 } else {
1216 unsigned long long i = std::stoull(number); 1216 auto i = std::stoull(number);
1217 name = sub + "." + std::to_string(i + 1); 1217 name = sub + "." + std::to_string(i + 1);
1218 } 1218 }
1219 } 1219 }
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 522aa6b2..1d33269d 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -356,7 +356,7 @@ void ScreenRecoveryUI::ProgressThreadLoop() {
356 // minimum of 20ms delay between frames 356 // minimum of 20ms delay between frames
357 double delay = interval - (end-start); 357 double delay = interval - (end-start);
358 if (delay < 0.02) delay = 0.02; 358 if (delay < 0.02) delay = 0.02;
359 usleep((long)(delay * 1000000)); 359 usleep(static_cast<useconds_t>(delay * 1000000));
360 } 360 }
361} 361}
362 362
@@ -572,8 +572,8 @@ void ScreenRecoveryUI::ClearText() {
572} 572}
573 573
574void ScreenRecoveryUI::ShowFile(FILE* fp) { 574void ScreenRecoveryUI::ShowFile(FILE* fp) {
575 std::vector<long> offsets; 575 std::vector<off_t> offsets;
576 offsets.push_back(ftell(fp)); 576 offsets.push_back(ftello(fp));
577 ClearText(); 577 ClearText();
578 578
579 struct stat sb; 579 struct stat sb;
@@ -583,7 +583,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
583 while (true) { 583 while (true) {
584 if (show_prompt) { 584 if (show_prompt) {
585 PrintOnScreenOnly("--(%d%% of %d bytes)--", 585 PrintOnScreenOnly("--(%d%% of %d bytes)--",
586 static_cast<int>(100 * (double(ftell(fp)) / double(sb.st_size))), 586 static_cast<int>(100 * (double(ftello(fp)) / double(sb.st_size))),
587 static_cast<int>(sb.st_size)); 587 static_cast<int>(sb.st_size));
588 Redraw(); 588 Redraw();
589 while (show_prompt) { 589 while (show_prompt) {
@@ -602,7 +602,7 @@ void ScreenRecoveryUI::ShowFile(FILE* fp) {
602 if (feof(fp)) { 602 if (feof(fp)) {
603 return; 603 return;
604 } 604 }
605 offsets.push_back(ftell(fp)); 605 offsets.push_back(ftello(fp));
606 } 606 }
607 } 607 }
608 ClearText(); 608 ClearText();
diff --git a/uncrypt/uncrypt.cpp b/uncrypt/uncrypt.cpp
index 43a2c2ab..a1de6a18 100644
--- a/uncrypt/uncrypt.cpp
+++ b/uncrypt/uncrypt.cpp
@@ -200,8 +200,9 @@ static int produce_block_map(const char* path, const char* map_file, const char*
200 200
201 std::vector<int> ranges; 201 std::vector<int> ranges;
202 202
203 std::string s = android::base::StringPrintf("%s\n%" PRId64 " %ld\n", 203 std::string s = android::base::StringPrintf("%s\n%" PRId64 " %" PRId64 "\n",
204 blk_dev, sb.st_size, static_cast<long>(sb.st_blksize)); 204 blk_dev, static_cast<int64_t>(sb.st_size),
205 static_cast<int64_t>(sb.st_blksize));
205 if (!android::base::WriteStringToFd(s, mapfd)) { 206 if (!android::base::WriteStringToFd(s, mapfd)) {
206 ALOGE("failed to write %s: %s", tmp_map_file.c_str(), strerror(errno)); 207 ALOGE("failed to write %s: %s", tmp_map_file.c_str(), strerror(errno));
207 return -1; 208 return -1;
diff --git a/updater/install.cpp b/updater/install.cpp
index 925604f3..4f526840 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -602,8 +602,8 @@ Value* PackageExtractFileFn(const char* name, State* state,
602 v->size = mzGetZipEntryUncompLen(entry); 602 v->size = mzGetZipEntryUncompLen(entry);
603 v->data = reinterpret_cast<char*>(malloc(v->size)); 603 v->data = reinterpret_cast<char*>(malloc(v->size));
604 if (v->data == NULL) { 604 if (v->data == NULL) {
605 printf("%s: failed to allocate %ld bytes for %s\n", 605 printf("%s: failed to allocate %zd bytes for %s\n",
606 name, (long)v->size, zip_path); 606 name, v->size, zip_path);
607 goto done1; 607 goto done1;
608 } 608 }
609 609
@@ -992,7 +992,8 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
992 992
993 buffer = reinterpret_cast<char*>(malloc(st.st_size+1)); 993 buffer = reinterpret_cast<char*>(malloc(st.st_size+1));
994 if (buffer == NULL) { 994 if (buffer == NULL) {
995 ErrorAbort(state, "%s: failed to alloc %lld bytes", name, (long long)st.st_size+1); 995 ErrorAbort(state, "%s: failed to alloc %zu bytes", name,
996 static_cast<size_t>(st.st_size+1));
996 goto done; 997 goto done;
997 } 998 }
998 999
@@ -1004,8 +1005,8 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
1004 } 1005 }
1005 1006
1006 if (ota_fread(buffer, 1, st.st_size, f) != static_cast<size_t>(st.st_size)) { 1007 if (ota_fread(buffer, 1, st.st_size, f) != static_cast<size_t>(st.st_size)) {
1007 ErrorAbort(state, "%s: failed to read %lld bytes from %s", 1008 ErrorAbort(state, "%s: failed to read %zu bytes from %s",
1008 name, (long long)st.st_size+1, filename); 1009 name, static_cast<size_t>(st.st_size), filename);
1009 ota_fclose(f); 1010 ota_fclose(f);
1010 goto done; 1011 goto done;
1011 } 1012 }
diff --git a/wear_ui.cpp b/wear_ui.cpp
index 50aeb384..48278ff2 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -320,7 +320,7 @@ void WearRecoveryUI::progress_loop() {
320 // minimum of 20ms delay between frames 320 // minimum of 20ms delay between frames
321 double delay = interval - (end-start); 321 double delay = interval - (end-start);
322 if (delay < 0.02) delay = 0.02; 322 if (delay < 0.02) delay = 0.02;
323 usleep((long)(delay * 1000000)); 323 usleep(static_cast<useconds_t>(delay * 1000000));
324 } 324 }
325} 325}
326 326
@@ -573,8 +573,8 @@ void WearRecoveryUI::Redraw()
573} 573}
574 574
575void WearRecoveryUI::ShowFile(FILE* fp) { 575void WearRecoveryUI::ShowFile(FILE* fp) {
576 std::vector<long> offsets; 576 std::vector<off_t> offsets;
577 offsets.push_back(ftell(fp)); 577 offsets.push_back(ftello(fp));
578 ClearText(); 578 ClearText();
579 579
580 struct stat sb; 580 struct stat sb;
@@ -584,7 +584,7 @@ void WearRecoveryUI::ShowFile(FILE* fp) {
584 while (true) { 584 while (true) {
585 if (show_prompt) { 585 if (show_prompt) {
586 Print("--(%d%% of %d bytes)--", 586 Print("--(%d%% of %d bytes)--",
587 static_cast<int>(100 * (double(ftell(fp)) / double(sb.st_size))), 587 static_cast<int>(100 * (double(ftello(fp)) / double(sb.st_size))),
588 static_cast<int>(sb.st_size)); 588 static_cast<int>(sb.st_size));
589 Redraw(); 589 Redraw();
590 while (show_prompt) { 590 while (show_prompt) {
@@ -603,7 +603,7 @@ void WearRecoveryUI::ShowFile(FILE* fp) {
603 if (feof(fp)) { 603 if (feof(fp)) {
604 return; 604 return;
605 } 605 }
606 offsets.push_back(ftell(fp)); 606 offsets.push_back(ftello(fp));
607 } 607 }
608 } 608 }
609 ClearText(); 609 ClearText();