diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-07-14 08:11:14 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-07-16 18:36:44 +0200 |
commit | 91d204e2db8f53a6ae4827ecc4b0ccb0137375d0 (patch) | |
tree | 95c214a13355d9fa1e9a39b43b29cd443c229dde | |
parent | f333387748898f9a896b771686a2b192c258f22d (diff) |
eeprom: Check the return value of the fseek in all calls
Coverity insists that we should check the return value of the
calls to fseek. In general this is a good idea.
Fixes: Coverity CID 1040770, CID 1040771, CID 1040772
-rw-r--r-- | src/osmo-bts-sysmo/eeprom.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/osmo-bts-sysmo/eeprom.c b/src/osmo-bts-sysmo/eeprom.c index ef66b399..67112435 100644 --- a/src/osmo-bts-sysmo/eeprom.c +++ b/src/osmo-bts-sysmo/eeprom.c @@ -1253,7 +1253,11 @@ int eeprom_dump( int addr, int size, int hex ) perror( "eeprom fopen" ); return -1; } - fseek( f, addr, SEEK_SET ); + if (fseek( f, addr, SEEK_SET ) != 0) + { + perror( "eeprom fseek" ); + return -1; + } for ( i = 0; i < size; ++i, ++addr ) { @@ -1319,7 +1323,12 @@ static int eeprom_read( int addr, int size, char *pBuff ) } g_file = f; } - fseek( f, addr, SEEK_SET ); + if (fseek( f, addr, SEEK_SET ) != 0) + { + perror( "eeprom fseek" ); + return -1; + } + n = fread( pBuff, 1, size, f ); return n; } @@ -1378,8 +1387,16 @@ static int eeprom_write( int addr, int size, const char *pBuff ) } g_file = f; } - fseek( f, addr, SEEK_SET ); + if (fseek( f, addr, SEEK_SET ) == 0) + { + perror( "eeprom fseek" ); + n = -1; + goto error; + } + n = fwrite( pBuff, 1, size, f ); + +error: fclose( f ); g_file = NULL; return n; |