changeset 2942:4058fc61890e draft

CBlock::WriteToDisk() properly checks ftell(3) for error return Rather than storing ftell(3)'s return value -- a long -- in an unsigned int, we store and check a properly typed temp. Then, assured a non-negative value, we store in nBlockPosRet.
author Jeff Garzik <jgarzik@exmulti.com>
date Sun, 22 Apr 2012 13:59:24 -0400
parents 524bed9dc266
children 592efe364fca
files src/main.h
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/main.h
+++ b/src/main.h
@@ -961,9 +961,10 @@
         fileout << FLATDATA(pchMessageStart) << nSize;
 
         // Write block
-        nBlockPosRet = ftell(fileout);
-        if (nBlockPosRet == -1)
+        long fileOutPos = ftell(fileout);
+        if (fileOutPos < 0)
             return error("CBlock::WriteToDisk() : ftell failed");
+        nBlockPosRet = fileOutPos;
         fileout << *this;
 
         // Flush stdio buffers and commit to disk before returning