summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-03-08 18:18:26 -0600
committerMark Salyzyn2017-02-08 15:37:44 -0600
commit96432fc6655fe035d0e66e593ffaf58856e1a826 (patch)
tree0f987fd49bc00c94f0fb499461aaab09b7c22275
parentcf983bcbae801e4660521b9747d9a7516e7df1c1 (diff)
downloadplatform-system-core-96432fc6655fe035d0e66e593ffaf58856e1a826.tar.gz
platform-system-core-96432fc6655fe035d0e66e593ffaf58856e1a826.tar.xz
platform-system-core-96432fc6655fe035d0e66e593ffaf58856e1a826.zip
liblog: add __android_log_config_*_close()
Add __android_log_config_read_close() and __android_log_config_write_close(). Fortify the list macros to detect for list corruption, looking for entries pointing to themselves, deleted entries in list. Test: gTest liblog-unit-tests Bug: 27405083 Change-Id: I33e8a0cae7e202f1989ddd7c2a96752b44c8e746
-rw-r--r--liblog/config_read.c12
-rw-r--r--liblog/config_read.h25
-rw-r--r--liblog/config_write.c14
-rw-r--r--liblog/config_write.h21
4 files changed, 58 insertions, 14 deletions
diff --git a/liblog/config_read.c b/liblog/config_read.c
index 1f54152b0..a4232f412 100644
--- a/liblog/config_read.c
+++ b/liblog/config_read.c
@@ -60,3 +60,15 @@ LIBLOG_HIDDEN void __android_log_config_read() {
60 __android_log_add_transport(&__android_log_persist_read, &pmsgLoggerRead); 60 __android_log_add_transport(&__android_log_persist_read, &pmsgLoggerRead);
61#endif 61#endif
62} 62}
63
64LIBLOG_HIDDEN void __android_log_config_read_close() {
65 struct android_log_transport_read *transport;
66 struct listnode *n;
67
68 read_transport_for_each_safe(transport, n, &__android_log_transport_read) {
69 list_remove(&transport->node);
70 }
71 read_transport_for_each_safe(transport, n, &__android_log_persist_read) {
72 list_remove(&transport->node);
73 }
74}
diff --git a/liblog/config_read.h b/liblog/config_read.h
index 49a3b7526..892e80dca 100644
--- a/liblog/config_read.h
+++ b/liblog/config_read.h
@@ -28,22 +28,31 @@ extern LIBLOG_HIDDEN struct listnode __android_log_persist_read;
28 28
29#define read_transport_for_each(transp, transports) \ 29#define read_transport_for_each(transp, transports) \
30 for ((transp) = node_to_item((transports)->next, \ 30 for ((transp) = node_to_item((transports)->next, \
31 struct android_log_transport_read, node); \ 31 struct android_log_transport_read, node); \
32 ((transp) != node_to_item(transports, \ 32 ((transp) != node_to_item((transports), \
33 struct android_log_transport_read, node)); \ 33 struct android_log_transport_read, \
34 node)) && \
35 ((transp) != node_to_item((transp)->node.next, \
36 struct android_log_transport_read, \
37 node)); \
34 (transp) = node_to_item((transp)->node.next, \ 38 (transp) = node_to_item((transp)->node.next, \
35 struct android_log_transport_read, node)) \ 39 struct android_log_transport_read, node))
36 40
37#define read_transport_for_each_safe(transp, n, transports) \ 41#define read_transport_for_each_safe(transp, n, transports) \
38 for ((transp) = node_to_item((transports)->next, \ 42 for ((transp) = node_to_item((transports)->next, \
39 struct android_log_transport_read, node), \ 43 struct android_log_transport_read, node), \
40 (n) = (transp)->node.next; \ 44 (n) = (transp)->node.next; \
41 ((transp) != node_to_item(transports, \ 45 ((transp) != node_to_item((transports), \
42 struct android_log_transport_read, node)); \ 46 struct android_log_transport_read, \
43 (transp) = node_to_item(n, struct android_log_transport_read, node), \ 47 node)) && \
48 ((transp) != node_to_item((n), struct android_log_transport_read, \
49 node)); \
50 (transp) = node_to_item((n), struct android_log_transport_read, \
51 node), \
44 (n) = (transp)->node.next) 52 (n) = (transp)->node.next)
45 53
46LIBLOG_HIDDEN void __android_log_config_read(); 54LIBLOG_HIDDEN void __android_log_config_read();
55LIBLOG_HIDDEN void __android_log_config_read_close();
47 56
48__END_DECLS 57__END_DECLS
49 58
diff --git a/liblog/config_write.c b/liblog/config_write.c
index d689f631b..0aaaea6e4 100644
--- a/liblog/config_write.c
+++ b/liblog/config_write.c
@@ -64,3 +64,17 @@ LIBLOG_HIDDEN void __android_log_config_write() {
64 __android_log_add_transport(&__android_log_transport_write, &fakeLoggerWrite); 64 __android_log_add_transport(&__android_log_transport_write, &fakeLoggerWrite);
65#endif 65#endif
66} 66}
67
68LIBLOG_HIDDEN void __android_log_config_write_close() {
69 struct android_log_transport_write *transport;
70 struct listnode *n;
71
72 write_transport_for_each_safe(transport, n, &__android_log_transport_write) {
73 transport->logMask = 0;
74 list_remove(&transport->node);
75 }
76 write_transport_for_each_safe(transport, n, &__android_log_persist_write) {
77 transport->logMask = 0;
78 list_remove(&transport->node);
79 }
80}
diff --git a/liblog/config_write.h b/liblog/config_write.h
index 3b01a9a80..882541130 100644
--- a/liblog/config_write.h
+++ b/liblog/config_write.h
@@ -29,21 +29,30 @@ extern LIBLOG_HIDDEN struct listnode __android_log_persist_write;
29#define write_transport_for_each(transp, transports) \ 29#define write_transport_for_each(transp, transports) \
30 for ((transp) = node_to_item((transports)->next, \ 30 for ((transp) = node_to_item((transports)->next, \
31 struct android_log_transport_write, node); \ 31 struct android_log_transport_write, node); \
32 ((transp) != node_to_item(transports, \ 32 ((transp) != node_to_item((transports), \
33 struct android_log_transport_write, node)); \ 33 struct android_log_transport_write, \
34 node)) && \
35 ((transp) != node_to_item((transp)->node.next, \
36 struct android_log_transport_write, \
37 node)); \
34 (transp) = node_to_item((transp)->node.next, \ 38 (transp) = node_to_item((transp)->node.next, \
35 struct android_log_transport_write, node)) \ 39 struct android_log_transport_write, node))
36 40
37#define write_transport_for_each_safe(transp, n, transports) \ 41#define write_transport_for_each_safe(transp, n, transports) \
38 for ((transp) = node_to_item((transports)->next, \ 42 for ((transp) = node_to_item((transports)->next, \
39 struct android_log_transport_write, node), \ 43 struct android_log_transport_write, node), \
40 (n) = (transp)->node.next; \ 44 (n) = (transp)->node.next; \
41 ((transp) != node_to_item(transports, \ 45 ((transp) != node_to_item((transports), \
42 struct android_log_transport_write, node)); \ 46 struct android_log_transport_write, \
43 (transp) = node_to_item(n, struct android_log_transport_write, node), \ 47 node)) && \
48 ((transp) != node_to_item((n), struct android_log_transport_write, \
49 node)); \
50 (transp) = node_to_item((n), struct android_log_transport_write, \
51 node), \
44 (n) = (transp)->node.next) 52 (n) = (transp)->node.next)
45 53
46LIBLOG_HIDDEN void __android_log_config_write(); 54LIBLOG_HIDDEN void __android_log_config_write();
55LIBLOG_HIDDEN void __android_log_config_write_close();
47 56
48__END_DECLS 57__END_DECLS
49 58