aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-14 08:11:14 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-14 08:11:14 +0200
commit1d72e1f25420ef71950fc608223bfe47277f7645 (patch)
treed08c186263ec3edf43f49c2546e9af40e8b94898
parent4afc52a16e8132494fe324db2447d42190cbb332 (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.c23
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;