typedef int (* kblock_store_t) (struct KBlock *b, block_idx_t index);
typedef int (* kblock_error_t) (struct KBlock *b);
-typedef int (* kblock_clearerr_t) (struct KBlock *b);
+typedef void (* kblock_clearerr_t) (struct KBlock *b);
typedef int (* kblock_close_t) (struct KBlock *b);
/* \} */
*
* \sa kblock_error()
*/
-INLINE int kblock_clearerr(struct KBlock *b)
+INLINE void kblock_clearerr(struct KBlock *b)
{
KB_ASSERT_METHOD(b, clearerr);
- return b->priv.vt->clearerr(b);
+ b->priv.vt->clearerr(b);
}
+
+/**
+ * Flush the cache (if any) to the device.
+ *
+ * This function will write any pending modifications to the device.
+ * If the device does not have a cache, this function will do nothing.
+ *
+ * \return 0 if all is OK, EOF on errors.
+ * \sa kblock_read(), kblock_write(), kblock_buffered().
+ */
+int kblock_flush(struct KBlock *b);
+
/**
* Close the device.
*
INLINE int kblock_close(struct KBlock *b)
{
KB_ASSERT_METHOD(b, close);
- return b->priv.vt->close(b);
+ return kblock_flush(b) | b->priv.vt->close(b);
}
/**
*/
size_t kblock_write(struct KBlock *b, block_idx_t idx, const void *buf, size_t offset, size_t size);
-
-/**
- * Flush the cache (if any) to the device.
- *
- * This function will write any pending modifications to the device.
- * If the device does not have a cache, this function will do nothing.
- *
- * \return 0 if all is OK, EOF on errors.
- * \sa kblock_read(), kblock_write(), kblock_buffered().
- */
-int kblock_flush(struct KBlock *b);
-
-
/**
* Copy one block to another.
*
.store = kblockram_store,
.error = kblockram_dummy,
- .clearerr = kblockram_dummy,
+ .clearerr = (kblock_clearerr_t)kblockram_dummy,
.close = kblockram_dummy,
};
.store = kblock_swStore,
.error = kblockram_dummy,
- .clearerr = kblockram_dummy,
+ .clearerr = (kblock_clearerr_t)kblockram_dummy,
.close = kblockram_dummy,
};
.writeDirect = kblockram_writeDirect,
.error = kblockram_dummy,
- .clearerr = kblockram_dummy,
+ .clearerr = (kblock_clearerr_t)kblockram_dummy,
.close = kblockram_dummy,
};