diff --git a/mtdutils/mtdutils.c b/mtdutils/mtdutils.c
index cc30334..cd4f52c 100644
--- a/mtdutils/mtdutils.c
+++ b/mtdutils/mtdutils.c
@@ -300,20 +300,20 @@
         if (TEMP_FAILURE_RETRY(lseek64(fd, pos, SEEK_SET)) != pos ||
                     TEMP_FAILURE_RETRY(read(fd, data, size)) != size) {
             printf("mtd: read error at 0x%08llx (%s)\n",
-                    pos, strerror(errno));
+                   (long long)pos, strerror(errno));
         } else if (ioctl(fd, ECCGETSTATS, &after)) {
             printf("mtd: ECCGETSTATS error (%s)\n", strerror(errno));
             return -1;
         } else if (after.failed != before.failed) {
             printf("mtd: ECC errors (%d soft, %d hard) at 0x%08llx\n",
-                    after.corrected - before.corrected,
-                    after.failed - before.failed, pos);
+                   after.corrected - before.corrected,
+                   after.failed - before.failed, (long long)pos);
             // copy the comparison baseline for the next read.
             memcpy(&before, &after, sizeof(struct mtd_ecc_stats));
         } else if ((mgbb = ioctl(fd, MEMGETBADBLOCK, &pos))) {
             fprintf(stderr,
                     "mtd: MEMGETBADBLOCK returned %d at 0x%08llx: %s\n",
-                    mgbb, pos, strerror(errno));
+                    mgbb, (long long)pos, strerror(errno));
         } else {
             return 0;  // Success!
         }
diff --git a/updater/blockimg.cpp b/updater/blockimg.cpp
index 6111d0d..ddb474f 100644
--- a/updater/blockimg.cpp
+++ b/updater/blockimg.cpp
@@ -36,6 +36,7 @@
 #include <string>
 #include <vector>
 
+#include <base/parseint.h>
 #include <base/strings.h>
 
 #include "applypatch/applypatch.h"
@@ -77,40 +78,31 @@
         goto err;
     }
 
-    errno = 0;
-    val = strtol(pieces[0].c_str(), nullptr, 0);
-
-    if (errno != 0 || val < 2 || val > INT_MAX) {
-        goto err;
-    } else if (val % 2) {
-        goto err; // must be even
-    } else if (val != static_cast<long int>(pieces.size() - 1)) {
+    size_t num;
+    if (!android::base::ParseUint(pieces[0].c_str(), &num, static_cast<size_t>(INT_MAX))) {
         goto err;
     }
 
-    size_t num;
-    num = static_cast<size_t>(val);
+    if (num == 0 || num % 2) {
+        goto err; // must be even
+    } else if (num != pieces.size() - 1) {
+        goto err;
+    }
 
     rs.pos.resize(num);
     rs.count = num / 2;
     rs.size = 0;
 
     for (size_t i = 0; i < num; i += 2) {
-        const char* token = pieces[i+1].c_str();
-        errno = 0;
-        val = strtol(token, nullptr, 0);
-        if (errno != 0 || val < 0 || val > INT_MAX) {
+        if (!android::base::ParseUint(pieces[i+1].c_str(), &rs.pos[i],
+                                      static_cast<size_t>(INT_MAX))) {
             goto err;
         }
-        rs.pos[i] = static_cast<size_t>(val);
 
-        token = pieces[i+2].c_str();
-        errno = 0;
-        val = strtol(token, nullptr, 0);
-        if (errno != 0 || val < 0 || val > INT_MAX) {
+        if (!android::base::ParseUint(pieces[i+2].c_str(), &rs.pos[i+1],
+                                      static_cast<size_t>(INT_MAX))) {
             goto err;
         }
-        rs.pos[i+1] = static_cast<size_t>(val);
 
         if (rs.pos[i] >= rs.pos[i+1]) {
             goto err; // empty or negative range
@@ -800,7 +792,7 @@
 
     // <src_block_count>
     word = strtok_r(nullptr, " ", wordsave);
-    src_blocks = strtol(word, nullptr, 0);
+    android::base::ParseUint(word, &src_blocks);
 
     allocate(src_blocks * BLOCKSIZE, buffer);
 
@@ -1381,24 +1373,21 @@
     std::vector<std::string> lines = android::base::Split(transfer_list, "\n");
 
     // First line in transfer list is the version number
-    long int val;
-    errno = 0;
-    val = strtol(lines[0].c_str(), nullptr, 0);
-    if (errno != 0 || val < 1 || val > 3) {
+    if (!android::base::ParseInt(lines[0].c_str(), &params.version, 1, 3)) {
         fprintf(stderr, "unexpected transfer list version [%s]\n", lines[0].c_str());
         return StringValue(strdup(""));
     }
-    params.version = static_cast<int>(val);
 
     fprintf(stderr, "blockimg version is %d\n", params.version);
 
     // Second line in transfer list is the total number of blocks we expect to write
-    int total_blocks = strtol(lines[1].c_str(), nullptr, 0);
-
-    if (total_blocks < 0) {
+    int total_blocks;
+    if (!android::base::ParseInt(lines[1].c_str(), &total_blocks, 0)) {
         ErrorAbort(state, "unexpected block count [%s]\n", lines[1].c_str());
         return StringValue(strdup(""));
-    } else if (total_blocks == 0) {
+    }
+
+    if (total_blocks == 0) {
         return StringValue(strdup("t"));
     }
 
@@ -1408,24 +1397,20 @@
         fprintf(stderr, "maximum stash entries %s\n", lines[2].c_str());
 
         // Fourth line is the maximum number of blocks that will be stashed simultaneously
-        int stash_max_blocks = strtol(lines[3].c_str(), nullptr, 0);
-
-        if (stash_max_blocks < 0) {
+        int stash_max_blocks;
+        if (!android::base::ParseInt(lines[3].c_str(), &stash_max_blocks, 0)) {
             ErrorAbort(state, "unexpected maximum stash blocks [%s]\n", lines[3].c_str());
             return StringValue(strdup(""));
         }
 
-        if (stash_max_blocks >= 0) {
-            int res = CreateStash(state, stash_max_blocks, blockdev_filename->data,
-                    params.stashbase);
+        int res = CreateStash(state, stash_max_blocks, blockdev_filename->data, params.stashbase);
 
-            if (res == -1) {
-                return StringValue(strdup(""));
-            }
-
-            params.createdstash = res;
+        if (res == -1) {
+            return StringValue(strdup(""));
         }
 
+        params.createdstash = res;
+
         start += 2;
     }
 
diff --git a/updater/install.cpp b/updater/install.cpp
index a6ed078..97e3905 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -34,6 +34,7 @@
 #include <linux/xattr.h>
 #include <inttypes.h>
 
+#include <base/parseint.h>
 #include <base/strings.h>
 #include <base/stringprintf.h>
 
@@ -474,7 +475,8 @@
     }
 
     double frac = strtod(frac_str, NULL);
-    int sec = strtol(sec_str, NULL, 10);
+    int sec;
+    android::base::ParseInt(sec_str, &sec);
 
     UpdaterInfo* ui = (UpdaterInfo*)(state->cookie);
     fprintf(ui->cmd_pipe, "progress %f %d\n", frac, sec);
@@ -990,7 +992,7 @@
         goto done;
     }
 
-    if (fread(buffer, 1, st.st_size, f) != st.st_size) {
+    if (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);
         fclose(f);
@@ -1145,12 +1147,11 @@
         return NULL;
     }
 
-    char* endptr;
-    size_t bytes = strtol(bytes_str, &endptr, 10);
-    if (bytes == 0 && endptr == bytes_str) {
+    size_t bytes;
+    if (!android::base::ParseUint(bytes_str, &bytes)) {
         ErrorAbort(state, "%s(): can't parse \"%s\" as byte count\n\n", name, bytes_str);
         free(bytes_str);
-        return NULL;
+        return nullptr;
     }
 
     return StringValue(strdup(CacheSizeCheck(bytes) ? "" : "t"));
@@ -1174,16 +1175,14 @@
         return NULL;
     }
 
-    char* endptr;
-    size_t target_size = strtol(target_size_str, &endptr, 10);
-    if (target_size == 0 && endptr == target_size_str) {
-        ErrorAbort(state, "%s(): can't parse \"%s\" as byte count",
-                   name, target_size_str);
+    size_t target_size;
+    if (!android::base::ParseUint(target_size_str, &target_size)) {
+        ErrorAbort(state, "%s(): can't parse \"%s\" as byte count", name, target_size_str);
         free(source_filename);
         free(target_filename);
         free(target_sha1);
         free(target_size_str);
-        return NULL;
+        return nullptr;
     }
 
     int patchcount = (argc-4) / 2;
@@ -1523,7 +1522,8 @@
     char* len_str;
     if (ReadArgs(state, argv, 2, &filename, &len_str) < 0) return NULL;
 
-    size_t len = strtoull(len_str, NULL, 0);
+    size_t len;
+    android::base::ParseUint(len_str, &len);
     int fd = open(filename, O_WRONLY, 0644);
     int success = wipe_block_device(fd, len);
 
