Commit graph

2099 commits

Author SHA1 Message Date
Miodrag Dinic
192be1dcae [qemu]: Fix payload size format in qemu_pipe_frame_send()
The following change introduced regression for booting AOSP
on emulator for all architectures:

7c7990e Fix warnings in system/ headers

qemu_pipe expects payload size in the message header to be in hex format,
as stated in the comment for qemu_pipe_frame_send().

Change-Id: I32cfa9c9b2af56f93bbda0ea5597451c389ae45e
Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
2016-09-30 13:58:11 +02:00
Colin Cross
18fbd80504 Merge "Fix more system/core/include warnings" 2016-09-29 17:20:30 +00:00
Colin Cross
1811d156e9 Fix more system/core/include warnings
The warnings in these files were hidden by -isystem
framework/native/include.

Bug: 31752268
Test: m -j
Change-Id: I2a54376aea380ee24e6483fb7d35fdfe8991c490
2016-09-27 16:21:12 -07:00
Mark Salyzyn
70a83dc7b3 liblog: fix errno issues with event tag map
Cleanup.

Save the errno for the calls that fail, and reinstate them for
return. Drop fprintf stutter, one succinct line. Solve a memory
leak in close.  Change android_lookupEventTag() to use an
unsigned int so that we can use the full range of uint32_t tags.

Make sure this file compiles clean in C++.

Test: gTest liblog-unit-tests
Bug: 30963384
Bug: 31456426
Change-Id: I6a5efa6fb7e991431caba75ef0971e111968f6bf
2016-09-26 09:23:55 -07:00
David Pursell
b2356a6993 Merge "Flattenable: switch from assignment to memcpy()." 2016-09-23 22:46:03 +00:00
David Pursell
2ebce7384b Flattenable: switch from assignment to memcpy().
FlattenableUtils read() and write() currently use assignment to copy
bytes. However, by casting the void* buffer to type T, the compiler is
allowed to assume that buffer obeys the alignment requirements of T,
which is not necessarily the case during serialization. On some
architectures, we can get SIGBUS when this alignment is violated.

We don't want the users of these routines to have to worry about
alignment when packing structures, so use memcpy() instead which should
always be safe since the compiler won't assume any alignment for the
void* buffer.

On architectures that can handle unaligned direct read/write of type T,
the compiler should be smart enough to optimize this code back to a
direct read/write anyway, but architectures that can't handle it will
fall back to memcpy; this means that this change shouldn't have any
impact on current Android devices. See the linked bug for more details.

Bug: http://b/31671510
Test: libgui Sensor serialization no longer gives SIGBUS.
Test: libgui.so unchanged on Shamu before and after this CL.
Change-Id: I2197127e8cbfb43f4f553bda6464f6ebe087febd
2016-09-23 13:56:40 -07:00
Colin Cross
e8ffa449fd Move android_get_control_socket out of line
android_get_control_socket has a warning from the implicit cast from
long to int.  The warning was being hidden because cutils/sockets.h was
included with -isystem.  Move android_get_control_socket to sockets.cpp,
since we don't want header only dependencies anyways, and fix the
warning with a range check and a static_cast.

Bug: 31492149
Test: m -j <module that uses sockets.h and -Wall>
Change-Id: I1f394ab26d4ec8a7dd0e7907c10416d7f8647624
2016-09-23 11:26:08 -07:00
Colin Cross
17b5b82d64 Fix warnings in libutils headers
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in libutils
headers in preparation for moving from -isystem to -I.

- Fix implicit cast from int64_t to long in Condition.h.  Remove
  the __LP64__ check and always compare against LONG_MAX before
  casting.
- Fix implicit cast from size_t to ssize_t in KeyedVector.h
- Fix -Wshadow-field-in-constructor warnings in Looper.h and RefBase.h
- Move destructors for MessageHandler and LooperCallback to Looper.cpp
  and ReferenceRenamer and VirtualLightRefBase to RefBase.cpp to prevent
  vtables in every compilation unit.
- Declare template variables in Singleton.h
- Fix old-style casts in StrongPointer.h and TypeHelpers.h
- Use template metaprogramming in TypeHelpers.h to avoid warnings on
  memmove on non-trivial types.
- Add an assignment operator to key_value_pair_t to complete
  rule-of-three
- Use memcpy instead of dereferencing a reinterpret_casted pointer to
  treat the bits of a float or double as int32_t or int64_t
- Escape unicode sequences inside doxygen comments between \code and
  \endcode
- Remove WIN32 ZD definition in Compat.h, %zd works fine with mingw
- Fix WIN32 printf warnings in Filemap.cpp
- Initialize mNullValue with 0 in LruCache.h, some of the tests use a
  non-pointer type for TValue.

Test: m -j native
Bug: 31492149
Change-Id: I385a05a3ca01258e44fe3b37ef77e4aaff547b26
2016-09-22 13:03:15 -07:00
Colin Cross
588b3b0c03 Merge "Remove has_trivial_move trait from Vector<T>" 2016-09-22 19:44:28 +00:00
Colin Cross
097395532b Remove has_trivial_move trait from Vector<T>
Vector<T> objects are a dynamic type with a vtable, which is not
trivially moveable.

Impact on aapt for frameworks-res is negligible, ~3%.

Bug: 31595853
Test: m -j framework-res
Change-Id: I8a3269c35d95affb6e86d60588bcfca46db7f445
2016-09-22 10:14:05 -07:00
Treehugger Robot
d7f60fd871 Merge "Fix warnings in system/ headers" 2016-09-22 02:46:51 +00:00
Ajay Panicker
7875407bb7 Merge "Remove net_bt_stack group and replace it with bluetooth" 2016-09-22 01:32:34 +00:00
Colin Cross
7c7990e6fd Fix warnings in system/ headers
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in
system/core/include/system in preparation for moving from -isystem to -I.

- Fix invalid doxygen syntax in graphics.h
- Use a pragma to hide a C99 extension warning on the flexible length
  array in graphics.h
- Make static functions in radio.h static inline
- Fix size_t printf and size_t vs. ssize_t comparision in qemu_pipe.h
- Fix old style cast in window.h

Test: m -j native
Bug: 31492149
Change-Id: I857f289e4c8e303494831873282bbb69de155c10
2016-09-21 17:46:59 -07:00
Colin Cross
5cf3db6d2b Merge "Hide warning in cutils/trace.h" 2016-09-22 00:46:13 +00:00
Colin Cross
9993e799f1 Hide warning in cutils/trace.h
system/core/include is included in the global include path using
-isystem, which hides all warnings.  cutils/trace.h has an ignored
return value warning, move the implementation to trace-dev.c so it
doesn't cause warnings in every module that includes it in preparation
for moving from -isystem to -I.

Test: m -j native
Bug: 31492149
Change-Id: If8b3fe13059c9e59c2d5208294d427d84fa6e588
2016-09-21 17:45:31 -07:00
Colin Cross
21049e5c91 Merge "Hide gnu extension warnings in log/log.h" 2016-09-22 00:45:02 +00:00
Ajay Panicker
604208e957 Remove net_bt_stack group and replace it with bluetooth
Bug: 31549206
Change-Id: I667963e5f9fd1a5dc9ad74378b318e3b782e6883
2016-09-20 12:01:33 -07:00
Colin Cross
7c6c7f0b9f Fix warnings in libziparchive
system/core/include is included in the global include path using
-isystem, which hides all warnings.  zlib.h is included through
system/core/include/ziparchive/zip_archive.h, which was hiding warnings
in it.  Use a #pragma around the call to deflateInit2, it is a macro
that expands to an old-style cast, in preparation for moving from
-isystem to -I.  Also move the ZipString constructor to zip_archive.cc
so it can assert on the length of the string parameter and fix an
implicit conversion from size_t to uint16_t.

Test: m -j native
Bug: 31492149
Change-Id: I74cdad7fe9c723859b5cfbea73c8f27d9d9ca265
2016-09-20 09:23:47 -07:00
Treehugger Robot
36b88ce975 Merge "Move libusbhost's headers into libusbhost." 2016-09-17 01:33:11 +00:00
Treehugger Robot
5e093f367c Merge "Fix warnings in cutils/atomic.h" 2016-09-16 19:31:10 +00:00
Colin Cross
412ad0dad8 Hide gnu extension warnings in log/log.h
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in log/log.h
in preparation for moving from -isystem to -I.

log/log.h uses gnu extensions for zero-argument variadic macro token
pasting, which clang warns about with -Weverything.  Hide the warnings
using pragmas.

Test: m -j native
Bug: 31492149
Change-Id: Ib2113f877d811a6ecc0e91c035640b506f04bd86
2016-09-16 11:13:20 -07:00
Elliott Hughes
e0a7c773ed Move libusbhost's headers into libusbhost.
Change-Id: Ic5ff65bd6456ea3cc92e0c8f9d7a6f499e58dbfc
2016-09-16 10:43:56 -07:00
Elliott Hughes
40104501fa Move libbinderwrapper's headers into libbinderwrapper.
It was probably the LOCAL_EXPORT_C_INCLUDE_DIRS that made me miss this on the
original code review...

Change-Id: I55bc0b0698604338cd206bf5f336798929b6d8f9
2016-09-16 09:02:47 -07:00
Colin Cross
ec69c05463 Fix warnings in cutils/atomic.h
system/core/include is included in the global include path using
-isystem, which hides all warnings.  Fix warnings in cutils/atomic.h in
preparation for moving from -isystem to -I.

Test: m -j native
Bug: 31492149
Change-Id: I2a212f192309090a16d507e9ab6acf0fd7cac02d
2016-09-15 19:22:32 -07:00
Courtney Goeltzenleuchter
a2e874eabc Add color mode enums
The android_color_mode_t defines the color modes supported
by a display. A display can support multiple different
color modes.

sRGB mode and AdobeRGB are deliberately placed at 7 and 8
so that they match mode ID's used on prior devices.

bug: http://b/27926012
Change-Id: I9ab41b56ec0b495c02539665da5be158ffddf843
2016-09-08 11:39:32 -07:00
Lajos Molnar
0e10df4dd6 add android_flex_layout for describing all flexible formats.
Bug: 22767098
Bug: 24759202
Change-Id: I61e4ca9bd71e8da88a9571ec4effc7165026715b
2016-09-08 11:38:53 -07:00
Sergio Giro
1cfa56d46c libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8
Inconsistent behaviour between utf16_to_utf8 and utf16_to_utf8_length
is causing a heap overflow.

Correcting the length computation and adding bound checks to the
conversion functions.

Test: ran libutils_tests
Bug: 29250543
Change-Id: I6115e3357141ed245c63c6eb25fc0fd0a9a7a2bb
(cherry picked from commit c4966a363e)
2016-08-25 20:07:51 +00:00
Sergio Giro
9de6776321 Unicode: specify destination length in utf8_to_utf16 methods
String16(const char *utf8) now returns the empty string in case
a string ends halfway throw a utf8 character.

Bug: 29267949
Clean cherry-pick from 1dcc0c8239

Change-Id: I5223caa7d42f4582a982609a898a02043265c6d3
2016-08-25 19:57:06 +00:00
Hans Boehm
daac359be7 Merge "Make RefBase more robust and debuggable" 2016-08-24 23:36:13 +00:00
Mark Salyzyn
6322efe522 Merge "liblog: add __android_log_close()"
am: 812d1c7ea2

Change-Id: I2ba5ed22e78564a864bab6b550b6d2bd2609a629
2016-08-24 16:05:05 +00:00
Mark Salyzyn
2d562c9dce Merge "logger: validate hdr_size field in logger entry"
am: fcf7ab8b1b

Change-Id: Ic88fe616256ab4949040771d3bed1dfb823ab981
2016-08-24 16:05:04 +00:00
Treehugger Robot
812d1c7ea2 Merge "liblog: add __android_log_close()" 2016-08-24 15:58:48 +00:00
Treehugger Robot
fcf7ab8b1b Merge "logger: validate hdr_size field in logger entry" 2016-08-24 15:56:23 +00:00
Mark Salyzyn
8b1f7b595c Merge "libcutils: Add ashmem_valid() function"
am: d00c7470ea

Change-Id: Ib09d3ee7bb131c30f59ea273f357c045394206fb
2016-08-24 15:48:55 +00:00
Mark Salyzyn
ee431112ff libcutils: Add ashmem_valid() function
Bug: 30310689
Change-Id: I14c52c5d52745a725799652b87c86281ac214899
2016-08-23 15:29:28 -07:00
Mark Salyzyn
df7a4c6bae liblog: add __android_log_close()
Bug: 30963384
Change-Id: I901e6ac2cc3c601bbecc2d64e00a98e2ab448210
2016-08-23 15:25:03 -07:00
Mark Salyzyn
305374cf0f logger: validate hdr_size field in logger entry
- check hdr_size to make sure it is in the expected range
  from sizeof entry_v1 to entry (entry_v4).
- alter msg() method to report NULL on invalid hdr_size
- alter all users of msg() method.

Bug: 30947841
Change-Id: I9bc1740d7aa9f37df5be966c18de1fb9de63d5dd
2016-08-23 14:51:50 -07:00
Dmitriy Filchenko
97e3cb7074 Merge "Remove process_name.c"
am: e5b7ad1c39

Change-Id: I8f98f5fe9ff526ed8780971eddef128ed46de271
2016-08-19 01:30:34 +00:00
Dmitriy Filchenko
1bb49f483b Remove process_name.c
BUG: 29824203

Change-Id: I88d67cafb8ec0c4eea3db047bac0671de698ba02
2016-08-18 23:54:46 +00:00
Hans Boehm
23c857ebd6 Make RefBase more robust and debuggable
This prevents two different kinds of client errors from causing
undetected memory corruption, and helps with the detection of others:

1. We no longer deallocate objects when the weak count goes to zero
and there have been no strong references.  This otherwise causes
us to return a garbage object from a constructor if the constructor
allocates and deallocates a weak pointer to this. And we do know
that clients allocate such weak pointers in constructors and their
lifetime is hard to trace.

2. We abort if a RefBase object is explicitly destroyed while
the weak count is nonzero.  Otherwise a subsequent decrement
would cause a write to potentially reallocated memory.

3. We check counter values returned by atomic decrements for
plausibility, and fail immediately if they are not plausible.

We unconditionally log any cases in which 1 changes behavior
from before. We abort in cases in which 2 changes behavior, since
those reflect clear bugs.
In case 1, a log message now indicates a possible leak. We have
not seen such a message in practice.

The third point introduces a small amount of overhead into the
reference count decrement path. But this should be negligible
compared to the actual decrement cost.

Add a test for promote/attemptIncStrong that tries to check for
both (1) above and concurrent operation of attemptIncStrong.

Add some additional warnings and explanations to the RefBase
documentation.

Bug: 30503444
Bug: 30292291
Bug: 30292538

Change-Id: Ida92b9a2e247f543a948a75d221fbc0038dea66c
2016-08-13 11:17:51 -07:00
Hans Boehm
df6c464e9a Merge "Improve RefBase documentation, especially for clients."
am: 0f39fe22ae

Change-Id: I804989b192142dc9d69ca36f0122079822625e7e
2016-08-10 16:24:01 +00:00
Hans Boehm
0f39fe22ae Merge "Improve RefBase documentation, especially for clients." 2016-08-10 16:16:22 +00:00
Hans Boehm
9ba7192c1f Improve RefBase documentation, especially for clients.
Add basic interface documentation to RefBase.h.

Much, but not all, of this is cut-and-pasted from an email message
from Mathias Agopian. The rest is reconstructed from the code.

Delete some, now redundant, text from Refbase.cpp, and add a bit
more about the implementation strategy.

Some minor fixes to internal comments.

Bug: 30292291
Change-Id: I56518ae5553bc6de0cc2331778e7fcf2e6c4fd87
2016-08-09 15:12:19 -07:00
Chih-Hung Hsieh
4d031d6358 Merge "Fix google-explicit-constructor warnings in utils."
am: 5b7e3b9a2a

Change-Id: I88b7d5f20f26a028c90efdb837730e5b8631ce80
2016-08-04 21:48:20 +00:00
Chih-Hung Hsieh
2a929968e1 Fix google-explicit-constructor warnings in utils.
* Declare explicit conversion constructors.
* Use NOLINT(implicit) for implicit conversion constructors.

Bug: 28341362
Change-Id: I4fb58fa32aafc520b2ed862a05a8bdbfabbc6c35
Test: build with WITH_TIDY=1
2016-08-02 12:20:06 -07:00
Sergio Giro
4476929073 Merge \"LruCache: avoid copying keys in lookup\"
am: 896c6b14ae

Change-Id: If8223e90988510385378506cd3a05d382ab73fc9
2016-07-20 19:48:44 +00:00
Sergio Giro
896c6b14ae Merge "LruCache: avoid copying keys in lookup" 2016-07-20 19:38:47 +00:00
Sergio Giro
4c56e0a222 LruCache: avoid copying keys in lookup
Create objects of type KeyedEntry for lookups that only have
a key reference

Bug: 27567036
Change-Id: I5e609a3db63d3b9277ff1547a3cca37dce70251c
2016-07-20 18:38:44 +00:00
Elliott Hughes
8932be864d Merge \"Remove no-op klog_init.\"
am: 5558cd362b

Change-Id: I3f2112bead6740f1df48bc5b028f62c91d40425b
2016-07-19 19:48:36 +00:00
Elliott Hughes
489e3fbaa0 Remove no-op klog_init.
Change-Id: I467edad1d004ac16647f4aa1f0eead04e808efa0
2016-07-19 11:45:36 -07:00