[Extractor-gtk-cvslog] SF.net SVN: extractor-gtk:[115] trunk/extractor/helpers.h
Extract files from unusual archive formats
Brought to you by:
someone-guy
From: <som...@us...> - 2009-02-08 15:43:39
|
Revision: 115 http://extractor-gtk.svn.sourceforge.net/extractor-gtk/?rev=115&view=rev Author: someone-guy Date: 2009-02-08 15:43:32 +0000 (Sun, 08 Feb 2009) Log Message: ----------- Check fread return value in some cases to avoid warnings. Modified Paths: -------------- trunk/extractor/helpers.h Modified: trunk/extractor/helpers.h =================================================================== --- trunk/extractor/helpers.h 2009-02-08 12:42:05 UTC (rev 114) +++ trunk/extractor/helpers.h 2009-02-08 15:43:32 UTC (rev 115) @@ -5,7 +5,8 @@ //! read a 32 bit little-endian value from file static inline uint32_t read_le32(FILE *f) { unsigned char t[4]; - fread(t, 4, 1, f); + if (!fread(t, 4, 1, f)) + return 0; return (t[3] << 8 | t[2]) << 16 | (t[1] << 8 | t[0]); } @@ -19,21 +20,24 @@ //! read a 32 bit big-endian value from file static inline uint32_t read_be32(FILE *f) { unsigned char t[4]; - fread(t, 4, 1, f); + if (!fread(t, 4, 1, f)) + return 0; return (t[0] << 8 | t[1]) << 16 | (t[2] << 8 | t[3]); } //! read a 16 bit little-endian value from file static inline uint16_t read_le16(FILE *f) { unsigned char t[2]; - fread(t, 2, 1, f); + if (!fread(t, 2, 1, f)) + return 0; return t[1] << 8 | t[0]; } //! read a 16 bit big-endian value from file static inline uint16_t read_be16(FILE *f) { unsigned char t[2]; - fread(t, 2, 1, f); + if (!fread(t, 2, 1, f)) + return 0; return t[0] << 8 | t[1]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |