From 2874ec67c7a111f09fd57add336a99461e567b73 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 Jul 2013 09:46:02 +1000 Subject: [PATCH] DataFlash: slight efficiency improvement fixes issue #314 thanks Dongfang! --- libraries/DataFlash/DataFlash_Block.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/DataFlash/DataFlash_Block.cpp b/libraries/DataFlash/DataFlash_Block.cpp index 4e75cbe6ba..44b8440301 100644 --- a/libraries/DataFlash/DataFlash_Block.cpp +++ b/libraries/DataFlash/DataFlash_Block.cpp @@ -50,7 +50,7 @@ void DataFlash_Block::WriteBlock(const void *pBuffer, uint16_t size) // if we are at the start of a page we need to insert a // page header if (n > df_PageSize - sizeof(struct PageHeader)) { - n -= sizeof(struct PageHeader); + n = df_PageSize - sizeof(struct PageHeader); } struct PageHeader ph = { df_FileNumber, df_FilePage }; BlockWrite(df_BufferNum, df_BufferIdx, &ph, sizeof(ph), pBuffer, n);