Const correctness handle / RedactionInfo.
Helps us CHECK that they're always constructed with valid
RedactionInfo etc.
Test: atest FuseDaemonHostTest
Test: atest fuse_node_test
Bug: 147274248
Change-Id: I2cc369574d14136521201b4c8b99fe22e7ec0463
diff --git a/jni/RedactionInfo.cpp b/jni/RedactionInfo.cpp
index 3494db7..d943c8a 100644
--- a/jni/RedactionInfo.cpp
+++ b/jni/RedactionInfo.cpp
@@ -56,7 +56,7 @@
*
* This function assumes redaction_ranges_ within RedactionInfo is sorted.
*/
-bool RedactionInfo::hasOverlapWithReadRequest(size_t size, off64_t off) {
+bool RedactionInfo::hasOverlapWithReadRequest(size_t size, off64_t off) const {
if (!isRedactionNeeded() || off > redaction_ranges_.back().second ||
off + size < redaction_ranges_.front().first) {
return false;
@@ -79,11 +79,11 @@
mergeOverlappingRedactionRanges(redaction_ranges_);
}
-int RedactionInfo::size() {
+int RedactionInfo::size() const {
return redaction_ranges_.size();
}
-bool RedactionInfo::isRedactionNeeded() {
+bool RedactionInfo::isRedactionNeeded() const {
return size() > 0;
}
@@ -93,13 +93,13 @@
}
unique_ptr<vector<RedactionRange>> RedactionInfo::getOverlappingRedactionRanges(size_t size,
- off64_t off) {
+ off64_t off) const {
LOG(DEBUG) << "Computing redaction ranges for request: sz = " << size << " off = " << off;
if (hasOverlapWithReadRequest(size, off)) {
auto first_redaction = redaction_ranges_.end();
auto last_redaction = redaction_ranges_.end();
for (auto iter = redaction_ranges_.begin(); iter != redaction_ranges_.end(); ++iter) {
- RedactionRange& rr = *iter;
+ const RedactionRange& rr = *iter;
// Look for the first range that overlaps with the read request
if (first_redaction == redaction_ranges_.end() && off <= rr.second &&
off + size >= rr.first) {
@@ -121,4 +121,4 @@
return std::make_unique<vector<RedactionRange>>();
}
} // namespace fuse
-} // namespace mediaprovider
\ No newline at end of file
+} // namespace mediaprovider