Merge "Simplify atoi*/strto* for signed integers."
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 0ff0785..517935b 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -159,24 +159,12 @@
#define _UB(fp) _EXT(fp)->_ub
#define _FLOCK(fp) _EXT(fp)->_lock
-#define _FILEEXT_INIT(fp) \
-do { \
- _UB(fp)._base = NULL; \
- _UB(fp)._size = 0; \
- WCIO_INIT(fp); \
- pthread_mutexattr_t attr; \
- pthread_mutexattr_init(&attr); \
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
- pthread_mutex_init(&_FLOCK(fp), &attr); \
- pthread_mutexattr_destroy(&attr); \
- _EXT(fp)->_caller_handles_locking = false; \
-} while (0)
-
-#define _FILEEXT_SETUP(f, fext) \
-do { \
- (f)->_ext._base = __BIONIC_CAST(reinterpret_cast, unsigned char*, fext); \
- _FILEEXT_INIT(f); \
-} while (0)
+#define _FILEEXT_SETUP(fp, fext) \
+ do { \
+ (fp)->_ext._base = __BIONIC_CAST(reinterpret_cast, unsigned char*, fext); \
+ memset(_EXT(fp), 0, sizeof(struct __sfileext)); \
+ _EXT(fp)->_caller_handles_locking = true; \
+ } while (0)
/*
* Android <= KitKat had getc/putc macros in <stdio.h> that referred
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index d627556..d3ac043 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -170,7 +170,10 @@
fp->_lb._base = nullptr; /* no line buffer */
fp->_lb._size = 0;
- _FILEEXT_INIT(fp);
+
+ memset(_EXT(fp), 0, sizeof(struct __sfileext));
+ _FLOCK(fp) = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+ _EXT(fp)->_caller_handles_locking = false;
// Caller sets cookie, _read/_write etc.
// We explicitly clear _seek and _seek64 to prevent subtle bugs.
diff --git a/libc/stdio/wcio.h b/libc/stdio/wcio.h
index 2c1fa3c..3c4f7a4 100644
--- a/libc/stdio/wcio.h
+++ b/libc/stdio/wcio.h
@@ -79,9 +79,6 @@
} \
} while (0)
-#define WCIO_INIT(fp) \
- memset(&(_EXT(fp)->_wcio), 0, sizeof(struct wchar_io_data))
-
__END_DECLS
#endif /*_WCIO_H_*/
diff --git a/tests/dlfcn_symlink_support.cpp b/tests/dlfcn_symlink_support.cpp
index be1839e..a5d3c3e 100644
--- a/tests/dlfcn_symlink_support.cpp
+++ b/tests/dlfcn_symlink_support.cpp
@@ -44,7 +44,7 @@
return 0;
}
- if (android::base::EndsWith(info->dlpi_name, suffix.c_str())) {
+ if (android::base::EndsWith(info->dlpi_name, suffix)) {
std::string* path = reinterpret_cast<std::string*>(data);
*path = info->dlpi_name;
return 1; // found