Merge "Add a pre-C++11 constexpr compatibility macro."
diff --git a/adb/get_my_path_darwin.c b/adb/get_my_path_darwin.c
index 9141b57..65dd226 100644
--- a/adb/get_my_path_darwin.c
+++ b/adb/get_my_path_darwin.c
@@ -20,11 +20,11 @@
void get_my_path(char *s, size_t maxLen)
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
- CFURLRef bundleURL = CFBundleCopyBundleURL(mainBundle);
- CFStringRef bundlePathString = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
- CFRelease(bundleURL);
+ CFURLRef executableURL = CFBundleCopyExecutableURL(mainBundle);
+ CFStringRef executablePathString = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle);
+ CFRelease(executableURL);
- CFStringGetCString(bundlePathString, s, maxLen, kCFStringEncodingASCII);
- CFRelease(bundlePathString);
+ CFStringGetCString(executablePathString, s, maxLen, kCFStringEncodingASCII);
+ CFRelease(executablePathString);
}
diff --git a/adb/transport_usb.c b/adb/transport_usb.c
index ee6b637..3d19803 100644
--- a/adb/transport_usb.c
+++ b/adb/transport_usb.c
@@ -23,10 +23,6 @@
#define TRACE_TAG TRACE_TRANSPORT
#include "adb.h"
-#if ADB_HOST
-#include "usb_vendors.h"
-#endif
-
#ifdef HAVE_BIG_ENDIAN
#define H4(x) (((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | (((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24)
static inline void fix_endians(apacket *p)
@@ -131,18 +127,6 @@
#if ADB_HOST
int is_adb_interface(int vid, int pid, int usb_class, int usb_subclass, int usb_protocol)
{
- unsigned i;
- for (i = 0; i < vendorIdCount; i++) {
- if (vid == vendorIds[i]) {
- if (usb_class == ADB_CLASS && usb_subclass == ADB_SUBCLASS &&
- usb_protocol == ADB_PROTOCOL) {
- return 1;
- }
-
- return 0;
- }
- }
-
- return 0;
+ return (usb_class == ADB_CLASS && usb_subclass == ADB_SUBCLASS && usb_protocol == ADB_PROTOCOL);
}
#endif
diff --git a/adb/usb_vendors.c b/adb/usb_vendors.c
index 3b08907..1b73521 100755
--- a/adb/usb_vendors.c
+++ b/adb/usb_vendors.c
@@ -298,7 +298,7 @@
int vendorIds[VENDOR_COUNT_MAX];
unsigned vendorIdCount = 0;
-int get_adb_usb_ini(char* buff, size_t len);
+static int get_adb_usb_ini(char* buff, size_t len);
void usb_vendors_init(void)
{
@@ -348,7 +348,7 @@
/* Utils methods */
/* builds the path to the adb vendor id file. returns 0 if success */
-int build_path(char* buff, size_t len, const char* format, const char* home)
+static int build_path(char* buff, size_t len, const char* format, const char* home)
{
if (snprintf(buff, len, format, home, ANDROID_PATH, ANDROID_ADB_INI) >= (signed)len) {
return 1;
@@ -358,7 +358,7 @@
}
/* fills buff with the path to the adb vendor id file. returns 0 if success */
-int get_adb_usb_ini(char* buff, size_t len)
+static int get_adb_usb_ini(char* buff, size_t len)
{
#ifdef _WIN32
const char* home = getenv("ANDROID_SDK_HOME");
diff --git a/fastboot/util_osx.c b/fastboot/util_osx.c
index e80a8f3..a8f5c31 100644
--- a/fastboot/util_osx.c
+++ b/fastboot/util_osx.c
@@ -32,12 +32,12 @@
void get_my_path(char s[PATH_MAX])
{
CFBundleRef mainBundle = CFBundleGetMainBundle();
- CFURLRef bundleURL = CFBundleCopyBundleURL(mainBundle);
- CFStringRef bundlePathString = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
- CFRelease(bundleURL);
+ CFURLRef executableURL = CFBundleCopyExecutableURL(mainBundle);
+ CFStringRef executablePathString = CFURLCopyFileSystemPath(executableURL, kCFURLPOSIXPathStyle);
+ CFRelease(executableURL);
- CFStringGetCString(bundlePathString, s, PATH_MAX - 1, kCFStringEncodingASCII);
- CFRelease(bundlePathString);
+ CFStringGetCString(executablePathString, s, PATH_MAX-1, kCFStringEncodingASCII);
+ CFRelease(executablePathString);
char *x;
x = strrchr(s, '/');
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index d5d4700..40416a0 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -744,7 +744,7 @@
// as a side effect of this call.
static inline ssize_t ReadAtOffset(int fd, uint8_t* buf, size_t len,
off64_t off) {
-#ifdef HAVE_PREAD
+#if !defined(_WIN32)
return TEMP_FAILURE_RETRY(pread64(fd, buf, len, off));
#else
// The only supported platform that doesn't support pread at the moment
@@ -756,7 +756,7 @@
}
return TEMP_FAILURE_RETRY(read(fd, buf, len));
-#endif // HAVE_PREAD
+#endif
}
static int32_t FindEntry(const ZipArchive* archive, const int ent,