de6bd50d4238d19ec401127bcf2321dc679d908d |
|
14-Feb-2018 |
Tom Cherry <tomcherry@google.com> |
init: add host side parser for init Create a host side parser for init such that init rc files can be verified for syntax correctness before being used on the device. Bug: 36970783 Test: run the parser on init files on host Change-Id: I7e8772e278ebaff727057308596ebacf28b6fdda
/system/core/init/parser.cpp
|
579e682628805dd9c3f8c96765c0beb3f56f1494 |
|
20-Dec-2017 |
Elliott Hughes <enh@google.com> |
Add std::string StartsWith*/EndsWith* overloads. We should have done this from the beginning. Thanks to Windows, we're not going to be able to switch libbase over to std::string_view any time soon. Bug: N/A Test: ran tests Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
/system/core/init/parser.cpp
|
7d0a5c3656ee56eb81e442b58063d500b4f506e0 |
|
10-Nov-2017 |
Steven Moreland <smoreland@google.com> |
EndSection returns Result<Success> Allow it to fail. When there is an error for a section ending, print the error pointing to the line where the section starts. Bug: 69050941 Test: boot, init_tests Change-Id: I1d8ed25f4b74cc9ac24d38b8075751c7d606aea8
/system/core/init/parser.cpp
|
b592dd8afff487e5ba73bbd782cfa7501a65e88e |
|
03-Aug-2017 |
Tom Cherry <tomcherry@google.com> |
init: use Result<T> for the parsing functions Test: boot bullhead Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
/system/core/init/parser.cpp
|
62ca663475ff5284503cb82cae3e92e93d56bbea |
|
03-Aug-2017 |
Tom Cherry <tomcherry@google.com> |
init: introduce Result<T> for return values and error handling init tries to propagate error information up to build context before logging errors. This is a good thing, however too often init has the overly verbose paradigm for error handling, below: bool CalculateResult(const T& input, U* output, std::string* err) bool CalculateAndUseResult(const T& input, std::string* err) { U output; std::string calculate_result_err; if (!CalculateResult(input, &output, &calculate_result_err)) { *err = "CalculateResult " + input + " failed: " + calculate_result_err; return false; } UseResult(output); return true; } Even more common are functions that return only true/false but also require passing a std::string* err in order to see the error message. This change introduces a Result<T> that is use to either hold a successful return value of type T or to hold an error message as a std::string. If the functional only returns success or a failure with an error message, Result<Success> may be used. The classes Error and ErrnoError are used to indicate a failed Result<T>. A successful Result<T> is constructed implicitly from any type that can be implicitly converted to T or from the constructor arguments for T. This allows you to return a type T directly from a function that returns Result<T>. Error and ErrnoError are used to construct a Result<T> has failed. Each of these classes take an ostream as an input and are implicitly cast to a Result<T> containing that failure. ErrnoError() additionally appends ": " + strerror(errno) to the end of the failure string to aid in interacting with C APIs. The end result is that the above code snippet is turned into the much clearer example below: Result<U> CalculateResult(const T& input); Result<Success> CalculateAndUseResult(const T& input) { auto output = CalculateResult(input); if (!output) { return Error() << "CalculateResult " << input << " failed: " << output.error(); } UseResult(*output); return Success(); } This change also makes this conversion for some of the util.cpp functions that used the old paradigm. Test: boot bullhead, init unit tests Change-Id: I1e7d3a8820a79362245041251057fbeed2f7979b
/system/core/init/parser.cpp
|
67dee626e0185096bbaf73042f1a891ce436f714 |
|
27-Jul-2017 |
Tom Cherry <tomcherry@google.com> |
init: remove Parser singleton and related cleanup * Remove the Parser singleton (Hooray!) * Rename parser.* to tokenizer.* as this is actually a tokenizer * Rename init_parser.* to parser.* as this is a generic parser * Move contents of init_parser_test.cpp to service_test.cpp as this actually is a test of the parsing in MakeExecOneshotService() and nothing related to (init_)parser.cpp Test: boot bullhead Test: bool sailfish Test: init unit tests Change-Id: I4fe39e6483f58ebd3ce5ee715a45dbba0acf5d91
/system/core/init/parser.cpp
|
81f5d3ebef2c3789737bf718fc2a2cdd7b9e8b33 |
|
22-Jun-2017 |
Tom Cherry <tomcherry@google.com> |
init: create android::init:: namespace With some small fixups along the way Test: Boot bullhead Test: init unit tests Change-Id: I7beaa473cfa9397f845f810557d1631b4a462d6a
/system/core/init/parser.cpp
|
ad6741c6f82febee62bbfc439d03654c2cb3ba3e |
|
25-Apr-2017 |
Tom Cherry <tomcherry@google.com> |
init: remove unused parts of parser.cpp Now that ueventd is using init's parser, we no longer need anything other than the tokenizer from parser.cpp. Test: Boot bullhead Change-Id: I1f70f2c4479af576174bd74dd919d81817500216
/system/core/init/parser.cpp
|
3f5eaae526413a29de899270714469c76dc91ec8 |
|
07-Apr-2017 |
Tom Cherry <tomcherry@google.com> |
init: more header cleanup Remove includes of "log.h" that really want <android-base/logging.h> Fix header include order Remove headers included in .cpp files that their associated .h already includes Remove some unused headers Test: boot bullhead Change-Id: I2b415adfe86a5c8bbe4fb1ebc53c7b0ee2253824
/system/core/init/parser.cpp
|
f86b5a6b90619e02d1d034ef7b0adc3b439f4abb |
|
25-Jun-2016 |
Elliott Hughes <enh@google.com> |
Move init to libbase logging. Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
/system/core/init/parser.cpp
|
e7aa2b2c8378b458345477d1f6d9904490263bb6 |
|
02-Mar-2016 |
George Burgess IV <gbiv@google.com> |
Cleanup uses of sprintf so we can deprecate it. Also cleans up two instances of open() with useless mode params, and changes a few uses of snprintf to use sizeof(buffer) instead of hardcoded buffer sizes. Change-Id: If11591003d910c995e72ad8f75afd072c255a3c5
/system/core/init/parser.cpp
|
c0e919c92062360a69b771722677d041c9998403 |
|
04-Feb-2015 |
Elliott Hughes <enh@google.com> |
Stop using #if for conditional compilation. Use regular 'if' to prevent bitrot. Also remove remaining typedefs. Change-Id: I2e6ca928e2db29b88b643cf990ff05cfb0be94a6
/system/core/init/parser.cpp
|
f3cf438714aa1284d8a58e2f3b108ba93f6d3abb |
|
04-Feb-2015 |
Elliott Hughes <enh@google.com> |
Build init as C++. This is just the minimal change to keep it building. Change-Id: I245c5b8413a1db114576c81462eb5737f5ffcef2
/system/core/init/parser.cpp
|