Commit graph

548 commits

Author SHA1 Message Date
Bernie Innocenti
804e7d8c4f Fix clang-tidy warnings in log_time.h
- Zero initialize log_time instances by default
 - Disable implicit conversions by making constructors explicit
 - Explicitly initialize to EPOCH in most places
 - Change sniffTime() to avoid in-place modification of a log_time

I stopped here, but we could consider following up with a more invasive
change to make log_time instances immutable and perhaps also remove the
default constructor to force explicit initialization to EPOCH.

Test: atest libbase_test netd_unit_test
Change-Id: I67e716ef74adaaf40ab2c6e2e0dddb8d309bc7ca
2019-01-17 14:45:19 +09:00
Treehugger Robot
6a462405d0 Merge "Remove liblog's rate limiting" 2019-01-17 01:25:27 +00:00
Tom Cherry
9ddb1ddf14 Merge "liblog: statically link tests" 2019-01-16 23:45:18 +00:00
Tom Cherry
4f8246122f Merge "Use #pragma one for all liblog includes" 2019-01-16 22:25:53 +00:00
Treehugger Robot
1d69860960 Merge "Remove <log/logd.h> and <log/logger.h>" 2019-01-16 19:50:23 +00:00
Tom Cherry
bab52203b7 Use #pragma one for all liblog includes
Test: build
Change-Id: I0ffe40853a89acffc1af4fd3838ef488706d23dc
2019-01-16 10:49:45 -08:00
Treehugger Robot
3a4591c750 Merge "Remove checks for _USING_LIBCXX" 2019-01-16 18:43:18 +00:00
Tom Cherry
3b4bddc638 Remove liblog's rate limiting
After a few years of being available, there only ended up being one
user of this, so it is clear that logd's duplicate message mechanism
is the favored solution.

The one user of this rate limiting is questionable as is, since due to
the nature of storaged, the mainloop only runs once per minute by
default as is, so there is essentially nothing to be gained by rate
limiting any further.

Test: build
Change-Id: I0610d11efda1ce8b581b939bad11ff295cb2daa6
2019-01-16 10:37:14 -08:00
Treehugger Robot
e780431345 Merge "Remove __ANDROID_USE_LIBLOG_* guards" 2019-01-16 18:28:21 +00:00
Tom Cherry
a6d599815c Remove <log/logd.h> and <log/logger.h>
These are deprecated and no one is currently using them, so remove
them.

Test: build
Change-Id: Ia8d96e8aacdc3dd80e061c835072a3df4e8d38d9
2019-01-15 20:53:37 -08:00
Tom Cherry
1e1b9155f4 Remove __ANDROID_USE_LIBLOG_* guards
These headers are platforms headers, so by definition they'll never be
compiled for a platform less than the current one.

Test: build
Change-Id: Ic1c1535b935929d713806faf17fbf9cd82275329
2019-01-15 20:51:01 -08:00
Tom Cherry
e5b615076b Remove checks for _USING_LIBCXX
__cplusplus is enough

Test: build
Change-Id: Ia0cf3b5beafe41ae1ce17335b5b06c753e665a32
2019-01-15 20:49:06 -08:00
Tom Cherry
71ba16488b liblog: convert to C++
Bug: 119867234
Test: liblog, logcat, logd unit tests

Change-Id: I2a33b6fc37f9860c0041e3573bfb59ea389f623c
2019-01-15 15:57:33 -08:00
Tom Cherry
bbf2a0d797 liblog: statically link tests
Some liblog tests test symbols that aren't otherwise used on the
platform.  Statically link the tests such that we can add version
scripts that expose only the symbols used by the platform, and still
allow the tests to test the rest.

Test: build + unit tests
Change-Id: I898280fa52d31a2c7ad4eafdaa85e8b5f2e87971
2019-01-15 13:12:44 -08:00
Tom Cherry
d1febd3316 liblog: remove LOGGER_LOCAL
No users ever signed up to use this, so remove it to ease the
refactoring of liblog/libbase.

Bug: 119867234
Test: liblog unit tests
Change-Id: I37b99644112bae7b4a2e3f4d06749db08de4ea14
2019-01-10 10:39:35 -08:00
Treehugger Robot
b9d6cef75e Merge "liblog: convert README to markdown" 2019-01-10 18:34:23 +00:00
Tom Cherry
afd483c645 liblog: convert README to markdown
Android uses markdown for its readmes, not man pages, so update
appropriately.

Test: n/a

Change-Id: I674a9da5af56aeebfaca852764eb6c1ca0b166ff
2019-01-09 14:04:05 -08:00
Tom Cherry
ff4e07076d Use the existing .clang-format-2 for liblog
Test: n/a
Change-Id: Iadbb88d99aecbc2f7485a5dfa91f5b54846a5b67
2019-01-09 13:08:10 -08:00
Elliott Hughes
bfb465c733 Merge "Add missing <android/log.h> documentation." 2018-11-02 23:32:43 +00:00
Elliott Hughes
a38c2b6910 Add missing <android/log.h> documentation.
Bug: N/A
Test: N/A
Change-Id: Iec6db210055eb2765b98fd76c53bc77f3c28aaea
2018-11-02 13:18:41 -07:00
Dan Willemsen
3e963f9df7 Convert more modules to Android.bp
Test: cd system/core; mma
Test: check for mkbootfs in build artifacts
Test: out/host/linux-x86/nativetest64/libcrypto_utils_test/libcrypto_utils_test
Test: out/host/linux-x86/nativetest64/libnativebridge-tests/*_test
Change-Id: I71141bd85f052d5d86763a8b79b219cc4c46aafb
2018-10-31 21:53:37 -07:00
Treehugger Robot
91c47309a0 Merge "liblog: Fix memory leaks" 2018-11-01 02:11:31 +00: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
George Burgess IV
559387df56 liblog: Fix memory leaks
If realloc returns NULL, the memory passed to it will remain allocated.
That doesn't appear to be intended here.

Caught by our static analyzer.

Bug: None
Test: Ran the static analyzer.

Change-Id: I579bee6827146d404fc6f6b86074366aefbda63f
2018-10-03 21:20:21 +00:00
Chih-Hung Hsieh
9cb232b4de Declare __fake_use_va_args as a constexpr function.
* Need a body and return value for this function
  so the constexpr check can inline it.
* C mode can just use an extern function declaration, but not constexpr.

Bug: 116854606
Bug: 111614304
Test: build with WITH_TIDY=1 and enable static analyzer checks
Change-Id: Ie3f4efbcabed99416d196b6c361a772b8c6a4035
2018-10-02 17:38:41 -07:00
Tom Cherry
692c9973e1 Merge "liblog#__android_log_btwrite__android_logger_list_read fail" 2018-09-21 20:34:15 +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
Yuxian Xu
0e16d89960 liblog#__android_log_btwrite__android_logger_list_read fail
With replaced AOSP system.img, adb can be root by other test.
The fail is caused by the reason that logdw is still active after
__android_log_close().

This test has a potential bug.
proc/net/unix may contain '\0', then "grep" command will treat this file
as a bianry file.
Using "grep -a" instead of "grep" could be a safer way to get the right
results from bianry file.

bug: 112250722
Test: Build CTS
Test: Pixel 2 XL PPP5.180610.010 passed the following tests
Test: run cts-on-gsi -m CtsLiblogTestCases --skip-preconditions
Change-Id: I9bfca1522e90ebb68e6cecbdb63e3b67248e47c4
Signed-off-by: Xinghua Yang <xinghua.yang@mediatek.com>
2018-09-13 04:56:37 +00:00
Suren Baghdasaryan
bb20b9e6b8 liblog: Add functions to reset log context
Add android_log_parser_reset and android_log_reset to reset reader/writer
log context. This allows to generate multiple log messages of the same
format without context reallocation.

Change-Id: Icb0f15855378aa4e66fc671ffefd15d9df6fee1e
2018-08-02 00:55:01 +00:00
Chih-Hung Hsieh
cd3965e425 Suppress gnu-zero-variadic-macro-arguments warning.
Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I2a52073202f42d1912363ae864f2f7f892589cea
2018-07-26 14:33:12 -07:00
Chih-Hung Hsieh
62b0ef556d Declare __fake_use_va_args as a variadic function.
* New clang compiler requires variadic function to have
  at least one named parameter type.
* Use ##__VA_ARGS__ to work with empty __VA_ARGS__.
* Fix one ALOG_ASSERT parameter bug in lmkd/lmkd.c.

Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I90f35aa88527a6897954f69a35b256a157a725c5
2018-07-25 14:36:35 -07:00
Chih-Hung Hsieh
67f72bde26 Declare __FAKE_USE_VA_ARGS as a variadic function.
This avoids 2 static analysis warnings:
* assigned but unused variables in __VA_ARGS__
* unused expression result in __VA_ARGS__

Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I4faae8787f6cc76de7ff4b6d08d25d0cb47324ea
2018-07-23 13:03:19 -07:00
Chih-Hung Hsieh
fdd3f5ec74 Use __VA_ARGS__ when in clang static analyzer.
Clang static analyzer can optimize out if (false) ...
and report unused variables in __VA_ARGS__.

Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I214ced736230fda847031fd4eee23015fd988ffc
2018-07-18 17:07:45 -07:00
Yi Kong
c8d09ddceb [logd] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I15ccb9cfc9967dae4320d9690f5097bc2f7d5bfe
2018-07-13 17:50:55 -07:00
Yi Kong
c1a1562548 Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning for binder.

Test: m
Bug: 68236239
Change-Id: I8184bd6aa4ebff1bd8c88dad16886e98df853b03
2018-07-13 15:28:59 -07:00
Treehugger Robot
b8f4fe4fd4 Merge changes from topic "mingw-clang"
* changes:
  Do not customize __format__ for Windows/MinGW to gnu_printf
  Adapt to switch to Clang for Windows host builds
  Update cflags for building Windows modules with Clang
2018-06-26 19:47:53 +00:00
Pirama Arumuga Nainar
a2df1ef441 Do not customize __format__ for Windows/MinGW to gnu_printf
Bug: http://b/69933090
Bug: http://b/69933068

MinGW uses gnu_printf to force C99 printf analysis with GCC, but clang
does not support gnu_printf.  So just use the default that's used for
other platforms.  This also mirrors upstream commit
015e637b4b/.

Test: m native-host-cross with Clang.
Change-Id: I3deb266d70e25296c4ae1d58637afbabc3d949c1
2018-06-25 11:52:54 -07:00
chenhg
7d8880e50c Remove pstore case ibc.__pstore_append from CTS
BUG: 110118705
Change-Id: I946c645af0cfb3f3b0e9344c51940da226fd08ce
2018-06-21 16:04:10 -07:00
Elliott Hughes
6427c363df logd: remove failing test.
Bug: N/A
Test: ran tests manually
Change-Id: I3ebb97d757077acaab1b51809a1c2be90ceb1ad9
2018-06-19 15:06:53 -07:00
Mark Salyzyn
42fb2821cc liblog: expect content only if ro.logd.kernel is enabled
On svelte devices, CTS test liblog#android_logger_get_ fails on the
missing kernel buffer because it is not enabled to save space.

Test: gTest liblog_unit_tests
Bug: 109669791
Change-Id: Iaf46fe9713d3462a56885515a67db640544345ab
2018-06-05 07:43:15 -07:00
Chih-Hung Hsieh
462df10d91 Work around b/24465209, do not pack relocation table.
Global flag --pack-dyn-relocs=android is used with clang lld.
For b/24465209, we need to override that with pack_relocations:false.

Bug: 24465209
Bug: 80093890
Test: build with USE_CLANG_LLD=true and run dlext.compat_elf_hash_and_relocation_tables
Change-Id: I4edcdf49e184fa45ea2b6b6417654d81bcd09e1d
2018-05-24 09:34:54 -07:00
Chih-hung Hsieh
85bd9ca978 Merge "Work around b/24465209, do not use clang lld" 2018-05-23 17:17:14 +00:00
Chih-Hung Hsieh
0f975a2099 Work around b/24465209, do not use clang lld
See longer explanation in b/80093890.
Clang lld does not generate expected DT_REL and DT_RELA tags
with --hash-style=both and --pack-dyn-relocs=android.
I am not sure about the extent of b/24465209, so
I would rather not to use lld for these .so files for now.

Bug: 80093890
Bug: 24465209
Test: build with USE_CLANG_LLD=true and run dlext.compat_elf_hash_and_relocation_tables
Change-Id: I645dbe25c5b9975605e3af5e717ed36c276f14d4
2018-05-23 17:15:48 +00:00
Treehugger Robot
2a1c0dd6df Merge "Simplify code" 2018-05-22 22:44:56 +00:00
George Burgess IV
487de27345 Simplify code
The static analyzer is concerned about the strcpys below this, since it
apparently doesn't try to model snprintf's potential behaviors. (In
particular, it was concerned that suffixLen might be >=
sizeof(suffixBuf)). While that's clearly suboptimal, this code can also
be simplified to make it more obvious what's happening and to appease
the analyzer.

No functionality change is intended.

Bug: None
Test: Ran the analyzer. It's no longer angry about strcpy overflows.

Change-Id: I4aa812144c90f6d3e833bbcb23c0694476a0e53e
2018-05-16 03:06:59 +00:00
Jiyong Park
612210c75b Mark as recovery_available: true
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. toybox) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.

Bug: 67916654
Bug: 64960723
Test: m -j
Change-Id: Ie59155c08890e96ce1893fa3687afcf763d7aea3
2018-05-15 09:47:04 +09:00
Dan Albert
55a76719e2 Add missing @addtogroup tags.
These NDK docs weren't in any groups, so they don't show up in the
new site.

Test: https://irina-dot-devsite.googleplex.com/ndk/reference/group/logging
Test: https://irina-dot-devsite.googleplex.com/ndk/reference/group/sync
Bug: http://b/77236573
Change-Id: I300f96585dec94359ecf96fbf39c6dc3ec4579e5
2018-04-13 14:49:41 -07:00
Mark Salyzyn
72d3724ee5 liblog: save errno through log writing
Test: compile
Bug: 74258013
Change-Id: I5163527826855bc506ed324aaba47f8695aaf668
2018-03-07 10:56:51 -08:00
Tom Cherry
73ac28b408 Expose __android_log_buf_print and __android_log_buf_write to NDK
These are needed to build libbase with the NDK.

Bug: 73658597
Test: tree hugger
Change-Id: Icf4a82c5c08975731c180be155743ac63f4bfd50
2018-02-20 14:59:28 -08:00
Pavel Grafov
446d01c2c7 Make log_event_list.h available to vendor code.
This is required in order to be able to log audit
events from wpa_supplicant. Only log writing functions
from log_event_list.h are made available.

Test: manually
Bug: 70886042
Change-Id: I097d4ad1de573662658678e6a9f1fc8f17820542
2018-02-13 19:21:43 +00:00