otherwise we will read from uninitialized memory for blocksize.
update tests accordingly, as the number of decoded chunks is 0 if
* the number of available chunks is 0 and
* the number of requested chunks is not 0
after this change, because, in that case, the decode fails before any
chunk is allocated. but otherwise, the output chunks are still
allocated. so instead checking the number of output chunks, the test is
removed.
Signed-off-by: Kefu Chai <kchai@redhat.com>
   if (!decoded || !decoded->empty()){
     return -EINVAL;
   }
+  if (!want_to_read.empty() && chunks.empty()) {
+    // i need to get the blocksize from the first element of chunks
+    return -1;
+  }
 
   have.reserve(chunks.size());
   for (map<int, bufferlist>::const_iterator i = chunks.begin();
 
               EXPECT_EQ(-EIO, result);
              EXPECT_EQ(0u, minimum_chunks.size());
               EXPECT_EQ(-1, dresult);
-              EXPECT_EQ(shec->get_chunk_count(), decoded.size());
               if (result != -EIO || dresult != -1) {
                 ++unexpected_count;
               }
                 EXPECT_EQ(-EIO, result);
                EXPECT_EQ(0u, minimum_chunks.size());
                 EXPECT_EQ(-1, dresult);
-                EXPECT_EQ(shec->get_chunk_count(), decoded.size());
                 if (result != -EIO || dresult != -1) {
                   ++unexpected_count;
                 }