summaryrefslogtreecommitdiffstats
path: root/init/property_service.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-02-06 12:19:48 -0800
committerElliott Hughes <enh@google.com>2015-02-06 14:20:30 -0800
commitf682b4786a4093efb23bf80d69bf80eb274b145b (patch)
tree8af209a035867fd30720e6e6da1b8b581aab871d /init/property_service.cpp
parentd558530ba90cb6218fe8e255c71a034c3fe1ea58 (diff)
downloadsystem_core-f682b4786a4093efb23bf80d69bf80eb274b145b.zip
system_core-f682b4786a4093efb23bf80d69bf80eb274b145b.tar.gz
system_core-f682b4786a4093efb23bf80d69bf80eb274b145b.tar.bz2
Clean up reading and writing in init.
This isn't particularly useful in and of itself, but it does introduce the first (trivial) unit test, improves the documentation (including details about how to debug init crashes), and made me aware of how unpleasant the existing parser is. I also fixed a bug in passing --- unless you thought the "peboot" and "pm" commands were features... Bug: 19217569 Change-Id: I6ab76129a543ce3ed3dab52ef2c638009874c3de
Diffstat (limited to 'init/property_service.cpp')
-rw-r--r--init/property_service.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/init/property_service.cpp b/init/property_service.cpp
index cc1ee34..05c03d6 100644
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -30,6 +30,8 @@
#include <cutils/sockets.h>
#include <cutils/multiuser.h>
+#include <utils/file.h>
+
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <sys/_system_properties.h>
@@ -416,14 +418,9 @@ static void load_properties(char *data, const char *filter)
*/
static void load_properties_from_file(const char *fn, const char *filter)
{
- char *data;
- unsigned sz;
-
- data = read_file(fn, &sz);
-
- if(data != 0) {
- load_properties(data, filter);
- free(data);
+ std::string data;
+ if (read_file(fn, &data)) {
+ load_properties(&data[0], filter);
}
}