if (r < 0)
return r;
- if (!astate->exists) {
+ if (!astate || !astate->exists) {
return -ENOENT;
}
bool reading_from_head = (ofs < head_data_size);
if (reading_from_head) {
- if (astate) { // && astate->prefetch_data)?
- if (!ofs && astate->data.length() >= len) {
- bl = astate->data;
- return bl.length();
- }
+ if (!ofs && astate->data.length() >= len) {
+ bl = astate->data;
+ return bl.length();
+ }
- if (ofs < astate->data.length()) {
- unsigned copy_len = std::min((uint64_t)head_data_size - ofs, len);
- astate->data.begin(ofs).copy(copy_len, bl);
- return bl.length();
- }
+ if (ofs < astate->data.length()) {
+ unsigned copy_len = std::min((uint64_t)head_data_size - ofs, len);
+ astate->data.begin(ofs).copy(copy_len, bl);
+ return bl.length();
}
}