<feed xmlns='http://www.w3.org/2005/Atom'>
<title>replicant/core/init/parser.cpp, branch master</title>
<subtitle>Patches not merged yet, used for building and testing them
</subtitle>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/'/>
<entry>
<title>init: add host side parser for init</title>
<updated>2018-02-28T18:45:45+00:00</updated>
<author>
<name>Tom Cherry</name>
<email>tomcherry@google.com</email>
</author>
<published>2018-02-14T00:50:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=de6bd50d4238d19ec401127bcf2321dc679d908d'/>
<id>de6bd50d4238d19ec401127bcf2321dc679d908d</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>Add std::string StartsWith*/EndsWith* overloads.</title>
<updated>2017-12-20T17:42:22+00:00</updated>
<author>
<name>Elliott Hughes</name>
<email>enh@google.com</email>
</author>
<published>2017-12-20T17:41:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=579e682628805dd9c3f8c96765c0beb3f56f1494'/>
<id>579e682628805dd9c3f8c96765c0beb3f56f1494</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>EndSection returns Result&lt;Success&gt;</title>
<updated>2017-11-15T18:39:29+00:00</updated>
<author>
<name>Steven Moreland</name>
<email>smoreland@google.com</email>
</author>
<published>2017-11-10T22:20:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=7d0a5c3656ee56eb81e442b58063d500b4f506e0'/>
<id>7d0a5c3656ee56eb81e442b58063d500b4f506e0</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>init: use Result&lt;T&gt; for the parsing functions</title>
<updated>2017-08-14T17:27:33+00:00</updated>
<author>
<name>Tom Cherry</name>
<email>tomcherry@google.com</email>
</author>
<published>2017-08-03T00:01:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=b592dd8afff487e5ba73bbd782cfa7501a65e88e'/>
<id>b592dd8afff487e5ba73bbd782cfa7501a65e88e</id>
<content type='text'>
Test: boot bullhead
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Test: boot bullhead
Change-Id: I7f00c5f0f54dd4fe05df73e1d6a89b56d788e113
</pre>
</div>
</content>
</entry>
<entry>
<title>init: introduce Result&lt;T&gt; for return values and error handling</title>
<updated>2017-08-14T17:26:57+00:00</updated>
<author>
<name>Tom Cherry</name>
<email>tomcherry@google.com</email>
</author>
<published>2017-08-03T19:54:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=62ca663475ff5284503cb82cae3e92e93d56bbea'/>
<id>62ca663475ff5284503cb82cae3e92e93d56bbea</id>
<content type='text'>
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&amp; input, U* output, std::string* err)

bool CalculateAndUseResult(const T&amp; input, std::string* err) {
  U output;
  std::string calculate_result_err;
  if (!CalculateResult(input, &amp;output, &amp;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&lt;T&gt; 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&lt;Success&gt; may be used.  The classes Error and
ErrnoError are used to indicate a failed Result&lt;T&gt;.

A successful Result&lt;T&gt; 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&lt;T&gt;.

Error and ErrnoError are used to construct a Result&lt;T&gt; has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result&lt;T&gt; 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&lt;U&gt; CalculateResult(const T&amp; input);

Result&lt;Success&gt; CalculateAndUseResult(const T&amp; input) {
  auto output = CalculateResult(input);
  if (!output) {
    return Error() &lt;&lt; "CalculateResult " &lt;&lt; input &lt;&lt; " failed: "
                   &lt;&lt; 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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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&amp; input, U* output, std::string* err)

bool CalculateAndUseResult(const T&amp; input, std::string* err) {
  U output;
  std::string calculate_result_err;
  if (!CalculateResult(input, &amp;output, &amp;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&lt;T&gt; 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&lt;Success&gt; may be used.  The classes Error and
ErrnoError are used to indicate a failed Result&lt;T&gt;.

A successful Result&lt;T&gt; 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&lt;T&gt;.

Error and ErrnoError are used to construct a Result&lt;T&gt; has
failed. Each of these classes take an ostream as an input and are
implicitly cast to a Result&lt;T&gt; 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&lt;U&gt; CalculateResult(const T&amp; input);

Result&lt;Success&gt; CalculateAndUseResult(const T&amp; input) {
  auto output = CalculateResult(input);
  if (!output) {
    return Error() &lt;&lt; "CalculateResult " &lt;&lt; input &lt;&lt; " failed: "
                   &lt;&lt; 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
</pre>
</div>
</content>
</entry>
<entry>
<title>init: remove Parser singleton and related cleanup</title>
<updated>2017-07-27T20:23:32+00:00</updated>
<author>
<name>Tom Cherry</name>
<email>tomcherry@google.com</email>
</author>
<published>2017-07-27T19:54:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=67dee626e0185096bbaf73042f1a891ce436f714'/>
<id>67dee626e0185096bbaf73042f1a891ce436f714</id>
<content type='text'>
* 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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* 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
</pre>
</div>
</content>
</entry>
<entry>
<title>init: create android::init:: namespace</title>
<updated>2017-06-23T20:21:20+00:00</updated>
<author>
<name>Tom Cherry</name>
<email>tomcherry@google.com</email>
</author>
<published>2017-06-22T19:53:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=81f5d3ebef2c3789737bf718fc2a2cdd7b9e8b33'/>
<id>81f5d3ebef2c3789737bf718fc2a2cdd7b9e8b33</id>
<content type='text'>
With some small fixups along the way

Test: Boot bullhead
Test: init unit tests
Change-Id: I7beaa473cfa9397f845f810557d1631b4a462d6a
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
With some small fixups along the way

Test: Boot bullhead
Test: init unit tests
Change-Id: I7beaa473cfa9397f845f810557d1631b4a462d6a
</pre>
</div>
</content>
</entry>
<entry>
<title>init: remove unused parts of parser.cpp</title>
<updated>2017-04-25T18:24:33+00:00</updated>
<author>
<name>Tom Cherry</name>
<email>tomcherry@google.com</email>
</author>
<published>2017-04-24T23:47:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=ad6741c6f82febee62bbfc439d03654c2cb3ba3e'/>
<id>ad6741c6f82febee62bbfc439d03654c2cb3ba3e</id>
<content type='text'>
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
</pre>
</div>
</content>
</entry>
<entry>
<title>init: more header cleanup</title>
<updated>2017-04-07T01:06:34+00:00</updated>
<author>
<name>Tom Cherry</name>
<email>tomcherry@google.com</email>
</author>
<published>2017-04-06T23:30:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=3f5eaae526413a29de899270714469c76dc91ec8'/>
<id>3f5eaae526413a29de899270714469c76dc91ec8</id>
<content type='text'>
Remove includes of "log.h" that really want &lt;android-base/logging.h&gt;
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
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove includes of "log.h" that really want &lt;android-base/logging.h&gt;
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
</pre>
</div>
</content>
</entry>
<entry>
<title>Move init to libbase logging.</title>
<updated>2016-06-27T15:11:31+00:00</updated>
<author>
<name>Elliott Hughes</name>
<email>enh@google.com</email>
</author>
<published>2016-06-24T22:12:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.replicant.us/contrib/GNUtoo/replicant/core/commit/?id=f86b5a6b90619e02d1d034ef7b0adc3b439f4abb'/>
<id>f86b5a6b90619e02d1d034ef7b0adc3b439f4abb</id>
<content type='text'>
Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
</pre>
</div>
</content>
</entry>
</feed>
