Commit graph

548 commits

Author SHA1 Message Date
Steven Moreland
64b312bbd8 Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d am: dc99a094dd
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I79dcbb310a2515e7f17ad2ebbb0367070084dab2
2020-08-04 22:46:49 +00:00
Steven Moreland
dc99a094dd Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8 am: d05ecb8d9d
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: I816b8858c69e6481299f942401a16b5b39cd8b69
2020-08-04 22:21:36 +00:00
Steven Moreland
d05ecb8d9d Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542 am: d8801aaad8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: Ifa0692e4966e78f4e180a2efc53db991177b6006
2020-08-04 22:03:55 +00:00
Steven Moreland
d8801aaad8 Merge "libutils: check vsnprintf error" into oc-dev am: a03d37d542
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/12254459

Change-Id: Id247c7079c146da8eaf52f098027d5daa25ce8d8
2020-08-04 21:37:54 +00:00
Steven Moreland
a03d37d542 Merge "libutils: check vsnprintf error" into oc-dev 2020-08-04 21:20:36 +00:00
TreeHugger Robot
cf6c14c850 Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f am: cf91151364 am: 84dcff4c6b
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619803

Change-Id: Ie7b7a57f55ead23f8d382ac98eb5087a2c614b1b
2020-07-31 20:24:42 +00:00
TreeHugger Robot
84dcff4c6b Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f am: cf91151364
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619803

Change-Id: Idb480f2a4dc1aa0d929e17e7e568a9c1b05c8489
2020-07-31 20:03:44 +00:00
TreeHugger Robot
cf91151364 Merge "Fail explicitly on length overflow." into oc-dev am: ea8d38e77f
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619803

Change-Id: I9a6def9ff590fdadb457e9a011df3532829d23f4
2020-07-31 19:45:35 +00:00
TreeHugger Robot
ea8d38e77f Merge "Fail explicitly on length overflow." into oc-dev 2020-07-31 19:24:50 +00:00
TreeHugger Robot
30a74852b0 Merge "Fail explicitly on length overflow." into qt-dev 2020-07-30 21:21:49 +00:00
Steven Moreland
ee22384c54 libutils: check vsnprintf error
For encoding errors, this function will return a negative value which
causes problems down the line. Check for an error and return. Also,
integer overflows are guarded.

Bug: 161894517
Test: fuzzer test case
Change-Id: Ia85067d4258bde4b875c832d6223db5dd26b8838
Merged-In: Ia85067d4258bde4b875c832d6223db5dd26b8838
2020-07-30 17:29:34 +00:00
Steven Moreland
4e27b6992b String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0 am: 64fb5012b8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I03057c052a24f205c78ee600178d45e0cd51a3c1
2020-07-14 16:29:09 +00:00
Steven Moreland
64fb5012b8 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I3ab9771d898eea0158acfd07fbe5a2f4b7dad883
2020-07-14 16:12:53 +00:00
Steven Moreland
9be245c3f0 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I22f6b8299b4b77be31859a10b14efe01b297d531
2020-07-14 15:51:29 +00:00
Steven Moreland
107f18cb61 String16::remove - avoid overflow am: 4048e49956
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I4dedf81e3471473e589a858e14d7a9ae5f91b3d9
2020-07-14 15:37:25 +00:00
Christopher Ferris
4d14303653 Fail explicitly on length overflow.
Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.

Bug: 156997193

Test: Ran unit tests, including new unit test that aborted before.
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
(cherry picked from commit 68604b9c29)
2020-06-04 11:05:18 -07:00
Christopher Ferris
f846413e62 Fail explicitly on length overflow.
Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.

Bug: 156997193

Test: Ran unit tests, including new unit test that aborted before.
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
(cherry picked from commit 68604b9c29)
2020-05-28 18:38:18 -07:00
Steven Moreland
4048e49956 String16::remove - avoid overflow
Bug: 156999009
Test: libutils_test (cases added)
Change-Id: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
Merged-In: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
(cherry picked from commit f251c1c581)
(cherry picked from commit 9a9c8910e9296c9dc8d79c37f589895f5a2a836c)
2020-05-28 20:45:55 +00:00
Steven Moreland
4392bca7f7 FlattenableUtils::align memsets am: e62a9d7669 am: 59e7d4e8ea am: 3f273f49f1
am: f7724dfcfb

Change-Id: I0ecdb9a58418d0c65629c70fc6df2a4aad7a1784
2019-11-06 16:19:08 -08:00
Steven Moreland
f7724dfcfb FlattenableUtils::align memsets am: e62a9d7669 am: 59e7d4e8ea
am: 3f273f49f1

Change-Id: I91a8ef78619709fcdcb48cdad8e0e7a6b699b631
2019-11-06 16:13:06 -08:00
Steven Moreland
3f273f49f1 FlattenableUtils::align memsets am: e62a9d7669
am: 59e7d4e8ea

Change-Id: I1105027b52c3621e2031bdb747de61ce54d3ec74
2019-11-06 16:06:57 -08:00
Steven Moreland
59e7d4e8ea FlattenableUtils::align memsets
am: e62a9d7669

Change-Id: I51a5528d8544f374ff3ceb632e75a1d3ae97d963
2019-11-06 15:55:08 -08:00
Steven Moreland
e62a9d7669 FlattenableUtils::align memsets
Bug: 141890807
Test: boot, check data is zero'd
Change-Id: I45aaeac369f4c5cf3eb44f61c233e00f870a5c79
(cherry picked from commit bf824f8fa5)
2019-10-15 19:26:22 +00:00
Treehugger Robot
ee4cc04429 Merge "libutils: more detailed logging." 2019-04-02 02:45:41 +00:00
Steven Moreland
d33a2ee172 libutilscallstack: removed from darwin
libbacktrace only includes its Backtrace.cpp on the linux targets
but not windows or darwin targets. So, both should be disabled.

Previously, libutilscallstack was only ever a static library on
these platforms. Since nothing provided the symbols, these targets
couldn't have been used.

Fixes: 129636352
Test: m

Change-Id: I3f0b09e1d67c485b3ea57f58d1220d9516b326f2
2019-04-01 15:16:13 -07:00
Elliott Hughes
fd12160087 libutils: more detailed logging.
The question arose on the bug of whether this is a legit errno or just
a stale value.

Bug: http://b/129139241
Test: ran tests
Change-Id: I486176496028f04d4fcccdd0b29a3df6b13849c9
2019-04-01 12:24:19 -07:00
Steven Moreland
43f29072a9 Merge "libutils/libcutils: make host more like device" 2019-03-29 23:05:20 +00:00
Mikhail Naganov
e1a285ddc1 libutils: Fix thread safety annotations in Mutex
The annotations for Mutex::tryLock and timedLock were
incorrectly specifying the return value for the successful
acquisition.

Test: make libutils_test
Change-Id: I9729b6555ede5cb1d6db046e33c35bf5926c7755
2019-03-29 12:21:57 -07:00
Steven Moreland
e6132be529 libutils/libcutils: make host more like device
Having shared host libraries allows libraries depending on these to use
'shared_libs' for these. This simplifies configurations since these
libraries don't have to specify 'shared_libs' on all non-host targets.

Bug: 124524556
Test: build only

Change-Id: I09fb4a4fb66ea0a87cb76b1e6f400c537a11f082
2019-03-28 18:44:32 -07:00
Hans Boehm
6e75ad6e13 Revert "Revert "Fix wp and sp comparison bugs""
Fix wp and sp comparison bugs

Make clear() actually clear wp m_refs, so that nulls compare equal.

Make equality consistent with < and >, ensuring that a weak pointer
cannot be both equal to and greater than another.

Don't rely on the built-in < and > operators to correctly order
different objects. The standard does not guarantee that, and there is
a risk of compiler relying on that lack of guarantee.

Remove unnecessary comparison overloads, especially those
comparing a wp<> to an sp<>.

Change the remaining wp<> to sp<> comparisons to check for equivalence
of the mRefs pointer instead of the object address, thus eliminating
the dubious equal comparison result for a dead wp<> and an sp<> that
happen to point to the same object address.

Add comparison tests.

This reverts commit a2a2ad8057.

The original code, and my original CL, both failed to initialize m_refs
in various wp<> constructors. This now became more important, since
comparisons now rely more on m_refs. However I believe it was always
a bug, since some comparisons always relied on m_refs.

Test: Treehugger, boot AOSP, atest RefBase
Bug: 126922090
This reverts commit a2a2ad8057.

Reason for revert: Reapply after constructor fixes.

Change-Id: I2c8917416a2306e36d2b6bb7b397f653020e5688
2019-03-13 13:26:35 -07:00
Hans Boehm
a2a2ad8057 Revert "Fix wp and sp comparison bugs"
This reverts commit 029b12ebde.

Reason for revert: There appear to be problems with null comparisons. Reported failure in HwcBufferCacheTest.

Change-Id: I19745bb281dabe8b05c2df3fe95e7be7a49dcd51
2019-03-13 03:24:12 +00:00
Hans Boehm
029b12ebde Fix wp and sp comparison bugs
Make clear() actually clear wp m_refs, so that nulls compare equal.

Make equality consistent with < and >, ensuring that a weak pointer
cannot be both equal to and greater than another.

Don't rely on the built-in < and > operators to correctly order
different objects. The standard does not guarantee that, and there is
a risk of compiler relying on that lack of guarantee.

Remove unnecessary comparison overloads, especially those
comparing a wp<> to an sp<>.

Change the remaining wp<> to sp<> comparisons to check for equivalence
of the mRefs pointer instead of the object address, thus eliminating
the dubious equal comparison result for a dead wp<> and an sp<> that
happen to point to the same object address.

Add comparison tests.

Test: Treehugger, boot AOSP, atest RefBase
Bug: 126922090
Change-Id: I15911150e0fc85ace2c4b77d337826e12793c690
2019-03-09 21:41:37 -08:00
Elliott Hughes
cb65c354a0 Add test_suites to libutils_test.
Also move the singleton test out because our infrastructure can't cope
with tests that have their own test libraries.

Bug: http://b/124838889
Test: atest
Change-Id: Iddce3325a56d44a4288ace2a29921a3e02367413
2019-02-25 12:26:00 -08:00
Elliott Hughes
01705e4f1d Clean up libcutils/libutils tests.
Move tests in the same directory as the corresponding code, so it's
easier to see what is/isn't tested.

Fix naming of libcutils_tests (plural) to match the singular that's more
common (even though the plural makes more sense to me).

Add these two to system/core/'s TEST_MAPPING.

Remove obsolete AndroidTest.xml.

Fix a flaky (timing-dependent) libcutils test.

Test: ran tests
Change-Id: I7e0a31ff45c8a152562bf66fc97161594249366e
2019-02-11 13:15:56 -08:00
Elliott Hughes
eb0ef145fd MappedFile and FileMap should support zero-length mappings.
Bug: http://b/119818070 "app crashes when reading asset of zero length"
Test: ran tests
Change-Id: Idd2ad6f6e72c8e445aff78a460fac96dea41c950
2019-02-06 14:29:35 -08:00
Suren Baghdasaryan
1bcb634958 Merge changes from topic "re-revert move sched_policy functions"
* changes:
  DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for sched_policy users""
  DO NOT MERGE: Revert "Revert "libcutils: Move sched_policy functions into libprocessgroup""
  DO NOT MERGE: Revert "Revert "Add libprocessgroup into VNDK""
2019-01-25 17:09:02 +00:00
Elliott Hughes
cdd0aaa3ae Merge "Remove dead code." 2019-01-25 17:01:27 +00:00
Suren Baghdasaryan
9491078300 DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for sched_policy users""
This reverts commit 1bef8c550c.

Reason for revert: AOSP is fixed with new vendor image

Change-Id: Ib341ac80e2f88c13a7815a490ea2d9422ebdf55f
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-25 16:49:18 +00:00
Elliott Hughes
d2962c8a15 Remove dead code.
If this was strlcpy16 it wouldn't be such a bad idea, but strncpy16 is
just an accident waiting to happen...

Test: N/A
Change-Id: Id296fdeadfb9f1f70ddc8fb6d31b3b6b5178a12c
2019-01-24 13:07:18 -08:00
Suren Baghdasaryan
1bef8c550c DO NOT MERGE: Revert "Add dependencies on libprocessgroup for sched_policy users"
This reverts commit 02843339f9.

Reason for revert: Broke AOSP

Change-Id: I62f91c0adf440b5da0a145862b04dd27a7016faf
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-23 20:43:28 -08:00
Suren Baghdasaryan
02843339f9 Add dependencies on libprocessgroup for sched_policy users
After moving sched_policy functions into libprocessgroup its users require
additional dependency and inclusion of sched_policy_ctrl.h header.

Exempt-From-Owner-Approval: janitorial

Bug: 111307099
Test: builds, boots

Merged-In: Icc052080e1bce46ce06f7264446950cab0490a95
Change-Id: Icc052080e1bce46ce06f7264446950cab0490a95
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-22 18:19:45 +00:00
Treehugger Robot
d0dec304c5 Merge "libutils: use libbase_headers instead of libbase." 2019-01-08 06:42:22 +00:00
Steven Moreland
8338072591 CallStack: include prefix/tag when unlinked
Bug: N/A
Test: manual
Change-Id: I8f7a19744af938a02d876ab81c1dafee04744f96
2019-01-03 10:17:07 -08:00
Josh Gao
f0ea1e6e5d libutils: use libbase_headers instead of libbase.
Bug: http://b/121391019
Test: treehugger
Change-Id: I0e5d218b9afe6f832cc6bd0ef78bc1a5581f3e2f
2019-01-02 14:31:26 -08:00
Nick Kralevich
0a8b4d1a8b use epoll_create1
epoll_create leaks file descriptors. Use epoll_create1(EPOLL_CLOEXEC)
instead.

Bug: 120983106
Test: compiles and boots
Change-Id: I7c135ee22aee61cc7895486fda904b1790c093d1
2018-12-17 09:39:24 -08:00
Jiyong Park
4f301cd977 Suppress lint warnings on google-default-arguments
The lint rule google-default-arguments ensures that virtual or override
methods do not have default arguments, because different default values
across the hierarchy chain (e.g. Base::foo(int a=0) v.s.
Derived::foo(int a=10)) can cause confusions.

However, since the uses of the default arguments in libbinder don't lead
to such problem, suppress the warnings.

Test: WITH_TIDY=true WITH_TIDY_CHECKS=google-default-arguments m
libbinder does not show any warning about google-default-arguments

Change-Id: Ica41034ab0ad1037a0facc447ee47e0c77fa9c55
2018-10-29 23:06:23 +09:00
Elliott Hughes
9fbebc5d55 "utils/Errors.h": include <stdint.h> for int32_t.
No need for a Unix/Windows difference here.

Bug: N/A
Test: builds
Change-Id: If7b27f939f9c13ef336d2015608f2a24db8cc96d
2018-10-16 13:17:15 -07:00
Elliott Hughes
643268f325 Move system/core/ off NO_ERROR.
It causes trouble for Windows, and OK already exists.

Bug: N/A
Test: builds
Change-Id: Ida22fd658b0ebb259c710ba39049b07c9e495d9c
2018-10-08 11:15:52 -07:00
Chih-Hung Hsieh
747eb149d0 Add noexcept to move constructors and assignment operators.
Bug: 116614593
Test: build with WITH_TIDY=1
Change-Id: I5a7461386946ca623ab509609092aa0ac8418b80
2018-10-05 16:43:47 +00:00
Chih-Hung Hsieh
502f4864d6 Suppress implicit-fallthrough warnings.
Add FALLTHROUGH_INTENDED for clang compiler.

Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
2018-09-17 16:50:11 +00:00