Loading include/utils/Compat.h +23 −0 Original line number Diff line number Diff line Loading @@ -39,4 +39,27 @@ static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) #endif /* !HAVE_OFF64_T */ #if HAVE_PRINTF_ZD # define ZD "%zd" # define ZD_TYPE ssize_t #else # define ZD "%ld" # define ZD_TYPE long #endif /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif #endif /* __LIB_UTILS_COMPAT_H */ libs/utils/ZipFileRO.cpp +1 −23 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #define LOG_TAG "zipro" //#define LOG_NDEBUG 0 #include <utils/Log.h> #include <utils/Compat.h> #include <utils/ZipFileRO.h> #include <utils/misc.h> #include <utils/threads.h> Loading @@ -32,14 +33,6 @@ #include <assert.h> #include <unistd.h> #if HAVE_PRINTF_ZD # define ZD "%zd" # define ZD_TYPE ssize_t #else # define ZD "%ld" # define ZD_TYPE long #endif /* * We must open binary files using open(path, ... | O_BINARY) under Windows. * Otherwise strange read errors will happen. Loading @@ -48,21 +41,6 @@ # define O_BINARY 0 #endif /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif using namespace android; /* Loading libs/utils/ZipUtils.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #define LOG_TAG "ziputil" #include <utils/Log.h> #include <utils/Compat.h> #include <utils/ZipUtils.h> #include <utils/ZipFileRO.h> Loading Loading @@ -98,10 +99,11 @@ using namespace android; ALOGV("+++ reading %ld bytes (%ld left)\n", getSize, compRemaining); int cc = read(fd, readBuf, getSize); if (cc != (int) getSize) { ALOGD("inflate read failed (%d vs %ld)\n", cc, getSize); int cc = TEMP_FAILURE_RETRY(read(fd, readBuf, getSize)); if (cc < 0) { ALOGW("inflate read failed: %s", strerror(errno)); } else if (cc != (int) getSize) { ALOGW("inflate read failed (%d vs %ld)", cc, getSize); goto z_bail; } Loading Loading
include/utils/Compat.h +23 −0 Original line number Diff line number Diff line Loading @@ -39,4 +39,27 @@ static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) #endif /* !HAVE_OFF64_T */ #if HAVE_PRINTF_ZD # define ZD "%zd" # define ZD_TYPE ssize_t #else # define ZD "%ld" # define ZD_TYPE long #endif /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif #endif /* __LIB_UTILS_COMPAT_H */
libs/utils/ZipFileRO.cpp +1 −23 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #define LOG_TAG "zipro" //#define LOG_NDEBUG 0 #include <utils/Log.h> #include <utils/Compat.h> #include <utils/ZipFileRO.h> #include <utils/misc.h> #include <utils/threads.h> Loading @@ -32,14 +33,6 @@ #include <assert.h> #include <unistd.h> #if HAVE_PRINTF_ZD # define ZD "%zd" # define ZD_TYPE ssize_t #else # define ZD "%ld" # define ZD_TYPE long #endif /* * We must open binary files using open(path, ... | O_BINARY) under Windows. * Otherwise strange read errors will happen. Loading @@ -48,21 +41,6 @@ # define O_BINARY 0 #endif /* * TEMP_FAILURE_RETRY is defined by some, but not all, versions of * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's * not already defined, then define it here. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ #define TEMP_FAILURE_RETRY(exp) ({ \ typeof (exp) _rc; \ do { \ _rc = (exp); \ } while (_rc == -1 && errno == EINTR); \ _rc; }) #endif using namespace android; /* Loading
libs/utils/ZipUtils.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #define LOG_TAG "ziputil" #include <utils/Log.h> #include <utils/Compat.h> #include <utils/ZipUtils.h> #include <utils/ZipFileRO.h> Loading Loading @@ -98,10 +99,11 @@ using namespace android; ALOGV("+++ reading %ld bytes (%ld left)\n", getSize, compRemaining); int cc = read(fd, readBuf, getSize); if (cc != (int) getSize) { ALOGD("inflate read failed (%d vs %ld)\n", cc, getSize); int cc = TEMP_FAILURE_RETRY(read(fd, readBuf, getSize)); if (cc < 0) { ALOGW("inflate read failed: %s", strerror(errno)); } else if (cc != (int) getSize) { ALOGW("inflate read failed (%d vs %ld)", cc, getSize); goto z_bail; } Loading