commit | bc7d6c0a2030ec19db7f7a8b98e8ee0c65c7ecb5 | [log] [tgz] |
---|---|---|
author | Bernie Innocenti <codewiz@google.com> | Tue Jun 22 16:59:52 2021 +0900 |
committer | Bernie Innocenti <codewiz@google.com> | Wed Jun 23 04:58:34 2021 +0000 |
tree | 57d543555e131d2e1bb0cd4fcd3e82ffccd6858f | |
parent | 0bff241f710c08b847c80987973b954fc33532dd [diff] |
Sanitize buffer alignment macros The ancient ALIGN() macros caused clang-tidy to complain: packages/modules/DnsResolver/gethnamaddr.cpp:367:10: error: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr,-warnings-as-errors] bp = (char*) ALIGN(bp); The new inline template align_ptr() sidesteps this issue as recommended by the clang-tidy documentation: https://clang.llvm.org/extra/clang-tidy/checks/performance-no-int-to-ptr.html Furthermore, align_ptr() is used to replace this... surprising piece of code: bp += sizeof(align) - (size_t)((uintptr_t)bp % sizeof(align)); See the bug there? When bp is already aligned to a multiple of sizeof(align), it will overalign! Also, 'align' was a union of a uint32_t and a char, which is obviously the same alignment of a plain uint32_t on any architecture ever created! Bug: 182416023 Change-Id: Id39c3030025e4510feeb55723760a2950067cece
This code uses LOG(X) for logging. Log levels are VERBOSE,DEBUG,INFO,WARNING and ERROR. The default setting is WARNING and logs relate to WARNING and ERROR will be shown. If you want to enable the DEBUG level logs, using following command. adb shell service call dnsresolver 10 i32 1 VERBOSE 0 DEBUG 1 INFO 2 WARNING 3 ERROR 4 Verbose resolver logs could contain PII -- do NOT enable in production builds.