summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-03-23 23:00:50 +0100
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-23 23:00:50 +0100
commit30ad0461924096e948f4eef6f0e7cc64c28dac1a (patch)
treead1df5da827f51d31d05ce5d80d44e7488e25dc4
parentam e944944f: Merge "Add "Apply update from sdcard" to default recovery image." (diff)
parentMerge "Always use strerror to report errno in recovery." (diff)
downloadandroid_bootable_recovery-30ad0461924096e948f4eef6f0e7cc64c28dac1a.tar
android_bootable_recovery-30ad0461924096e948f4eef6f0e7cc64c28dac1a.tar.gz
android_bootable_recovery-30ad0461924096e948f4eef6f0e7cc64c28dac1a.tar.bz2
android_bootable_recovery-30ad0461924096e948f4eef6f0e7cc64c28dac1a.tar.lz
android_bootable_recovery-30ad0461924096e948f4eef6f0e7cc64c28dac1a.tar.xz
android_bootable_recovery-30ad0461924096e948f4eef6f0e7cc64c28dac1a.tar.zst
android_bootable_recovery-30ad0461924096e948f4eef6f0e7cc64c28dac1a.zip
-rw-r--r--fuse_sideload.c6
-rw-r--r--mtdutils/mtdutils.c8
-rw-r--r--updater/blockimg.c39
3 files changed, 27 insertions, 26 deletions
diff --git a/fuse_sideload.c b/fuse_sideload.c
index 4e11e01e4..1dd84e97a 100644
--- a/fuse_sideload.c
+++ b/fuse_sideload.c
@@ -106,12 +106,12 @@ static void fuse_reply(struct fuse_data* fd, __u64 unique, const void *data, siz
vec[0].iov_base = &hdr;
vec[0].iov_len = sizeof(hdr);
- vec[1].iov_base = data;
+ vec[1].iov_base = /* const_cast */(void*)(data);
vec[1].iov_len = len;
res = writev(fd->ffd, vec, 2);
if (res < 0) {
- printf("*** REPLY FAILED *** %d\n", errno);
+ printf("*** REPLY FAILED *** %s\n", strerror(errno));
}
}
@@ -430,7 +430,7 @@ int run_fuse_sideload(struct provider_vtab* vtab, void* cookie,
char opts[256];
snprintf(opts, sizeof(opts),
- ("fd=%d,user_id=%d,group_id=%d,max_read=%zu,"
+ ("fd=%d,user_id=%d,group_id=%d,max_read=%u,"
"allow_other,rootmode=040000"),
fd.ffd, fd.uid, fd.gid, block_size);
diff --git a/mtdutils/mtdutils.c b/mtdutils/mtdutils.c
index d04b26efa..9a17e38d8 100644
--- a/mtdutils/mtdutils.c
+++ b/mtdutils/mtdutils.c
@@ -313,8 +313,8 @@ static int read_block(const MtdPartition *partition, int fd, char *data)
memcpy(&before, &after, sizeof(struct mtd_ecc_stats));
} else if ((mgbb = ioctl(fd, MEMGETBADBLOCK, &pos))) {
fprintf(stderr,
- "mtd: MEMGETBADBLOCK returned %d at 0x%08llx (errno=%d)\n",
- mgbb, pos, errno);
+ "mtd: MEMGETBADBLOCK returned %d at 0x%08llx: %s\n",
+ mgbb, pos, strerror(errno));
} else {
return 0; // Success!
}
@@ -419,8 +419,8 @@ static int write_block(MtdWriteContext *ctx, const char *data)
if (ret != 0 && !(ret == -1 && errno == EOPNOTSUPP)) {
add_bad_block_offset(ctx, pos);
fprintf(stderr,
- "mtd: not writing bad block at 0x%08lx (ret %d errno %d)\n",
- pos, ret, errno);
+ "mtd: not writing bad block at 0x%08lx (ret %d): %s\n",
+ pos, ret, strerror(errno));
pos += partition->erase_size;
continue; // Don't try to erase known factory-bad blocks.
}
diff --git a/updater/blockimg.c b/updater/blockimg.c
index 9c39634fc..90b55b2d2 100644
--- a/updater/blockimg.c
+++ b/updater/blockimg.c
@@ -464,7 +464,7 @@ static void EnumerateStash(const char* dirname, StashCallback callback, void* da
if (directory == NULL) {
if (errno != ENOENT) {
- fprintf(stderr, "failed to opendir %s (errno %d)\n", dirname, errno);
+ fprintf(stderr, "opendir \"%s\" failed: %s\n", dirname, strerror(errno));
}
return;
}
@@ -495,7 +495,7 @@ static void EnumerateStash(const char* dirname, StashCallback callback, void* da
}
if (closedir(directory) == -1) {
- fprintf(stderr, "failed to closedir %s (errno %d)\n", dirname, errno);
+ fprintf(stderr, "closedir \"%s\" failed: %s\n", dirname, strerror(errno));
}
}
@@ -508,7 +508,7 @@ static void UpdateFileSize(const char* fn, void* data) {
}
if (stat(fn, &st) == -1) {
- fprintf(stderr, "failed to stat %s (errno %d)\n", fn, errno);
+ fprintf(stderr, "stat \"%s\" failed: %s\n", fn, strerror(errno));
return;
}
@@ -524,7 +524,7 @@ static void DeleteFile(const char* fn, void* data) {
fprintf(stderr, "deleting %s\n", fn);
if (unlink(fn) == -1 && errno != ENOENT) {
- fprintf(stderr, "failed to unlink %s (errno %d)\n", fn, errno);
+ fprintf(stderr, "unlink \"%s\" failed: %s\n", fn, strerror(errno));
}
}
}
@@ -553,7 +553,7 @@ static void DeleteStash(const char* base) {
if (rmdir(dirname) == -1) {
if (errno != ENOENT && errno != ENOTDIR) {
- fprintf(stderr, "failed to rmdir %s (errno %d)\n", dirname, errno);
+ fprintf(stderr, "rmdir \"%s\" failed: %s\n", dirname, strerror(errno));
}
}
@@ -587,7 +587,7 @@ static int LoadStash(const char* base, const char* id, int verify, int* blocks,
if (res == -1) {
if (errno != ENOENT || printnoent) {
- fprintf(stderr, "failed to stat %s (errno %d)\n", fn, errno);
+ fprintf(stderr, "stat \"%s\" failed: %s\n", fn, strerror(errno));
}
goto lsout;
}
@@ -602,7 +602,7 @@ static int LoadStash(const char* base, const char* id, int verify, int* blocks,
fd = TEMP_FAILURE_RETRY(open(fn, O_RDONLY));
if (fd == -1) {
- fprintf(stderr, "failed to open %s (errno %d)\n", fn, errno);
+ fprintf(stderr, "open \"%s\" failed: %s\n", fn, strerror(errno));
goto lsout;
}
@@ -663,7 +663,7 @@ static int WriteStash(const char* base, const char* id, int blocks, uint8_t* buf
fd = TEMP_FAILURE_RETRY(open(fn, O_WRONLY | O_CREAT | O_TRUNC | O_SYNC, STASH_FILE_MODE));
if (fd == -1) {
- fprintf(stderr, "failed to create %s (errno %d)\n", fn, errno);
+ fprintf(stderr, "failed to create \"%s\": %s\n", fn, strerror(errno));
goto wsout;
}
@@ -672,12 +672,12 @@ static int WriteStash(const char* base, const char* id, int blocks, uint8_t* buf
}
if (fsync(fd) == -1) {
- fprintf(stderr, "failed to fsync %s (errno %d)\n", fn, errno);
+ fprintf(stderr, "fsync \"%s\" failed: %s\n", fn, strerror(errno));
goto wsout;
}
if (rename(fn, cn) == -1) {
- fprintf(stderr, "failed to rename %s to %s (errno %d)\n", fn, cn, errno);
+ fprintf(stderr, "rename(\"%s\", \"%s\") failed: %s\n", fn, cn, strerror(errno));
goto wsout;
}
@@ -737,14 +737,14 @@ static int CreateStash(State* state, int maxblocks, const char* blockdev, char**
res = stat(dirname, &st);
if (res == -1 && errno != ENOENT) {
- ErrorAbort(state, "failed to stat %s (errno %d)\n", dirname, errno);
+ ErrorAbort(state, "stat \"%s\" failed: %s\n", dirname, strerror(errno));
goto csout;
} else if (res != 0) {
fprintf(stderr, "creating stash %s\n", dirname);
res = mkdir(dirname, STASH_DIRECTORY_MODE);
if (res != 0) {
- ErrorAbort(state, "failed to create %s (errno %d)\n", dirname, errno);
+ ErrorAbort(state, "mkdir \"%s\" failed: %s\n", dirname, strerror(errno));
goto csout;
}
@@ -1408,7 +1408,7 @@ static int PerformCommandErase(CommandParameters* params) {
}
if (fstat(params->fd, &st) == -1) {
- fprintf(stderr, "failed to fstat device to erase (errno %d)\n", errno);
+ fprintf(stderr, "failed to fstat device to erase: %s\n", strerror(errno));
goto pceout;
}
@@ -1437,7 +1437,7 @@ static int PerformCommandErase(CommandParameters* params) {
blocks[1] = (tgt->pos[i * 2 + 1] - tgt->pos[i * 2]) * (uint64_t) BLOCKSIZE;
if (ioctl(params->fd, BLKDISCARD, &blocks) == -1) {
- fprintf(stderr, "failed to blkdiscard (errno %d)\n", errno);
+ fprintf(stderr, "BLKDISCARD ioctl failed: %s\n", strerror(errno));
// Continue anyway, nothing we can do
}
}
@@ -1574,7 +1574,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, int argc,
params.fd = TEMP_FAILURE_RETRY(open(blockdev_filename->data, O_RDWR));
if (params.fd == -1) {
- fprintf(stderr, "failed to open %s: %s", blockdev_filename->data, strerror(errno));
+ fprintf(stderr, "open \"%s\" failed: %s\n", blockdev_filename->data, strerror(errno));
goto pbiudone;
}
@@ -1587,8 +1587,9 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, int argc,
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
- if (pthread_create(&params.thread, &attr, unzip_new_data, &params.nti) != 0) {
- fprintf(stderr, "failed to create a thread (errno %d)\n", errno);
+ int error = pthread_create(&params.thread, &attr, unzip_new_data, &params.nti);
+ if (error != 0) {
+ fprintf(stderr, "pthread_create failed: %s\n", strerror(error));
goto pbiudone;
}
}
@@ -1719,7 +1720,7 @@ static Value* PerformBlockImageUpdate(const char* name, State* state, int argc,
pbiudone:
if (params.fd != -1) {
if (fsync(params.fd) == -1) {
- fprintf(stderr, "failed to fsync device (errno %d)\n", errno);
+ fprintf(stderr, "fsync failed: %s\n", strerror(errno));
}
TEMP_FAILURE_RETRY(close(params.fd));
}
@@ -1875,7 +1876,7 @@ Value* RangeSha1Fn(const char* name, State* state, int argc, Expr* argv[]) {
int fd = open(blockdev_filename->data, O_RDWR);
if (fd < 0) {
- ErrorAbort(state, "failed to open %s: %s", blockdev_filename->data, strerror(errno));
+ ErrorAbort(state, "open \"%s\" failed: %s", blockdev_filename->data, strerror(errno));
goto done;
}