aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/eeprom.c
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-16 18:36:44 +0200
commit91d204e2db8f53a6ae4827ecc4b0ccb0137375d0 (patch)
tree95c214a13355d9fa1e9a39b43b29cd443c229dde /src/osmo-bts-sysmo/eeprom.c
parentf333387748898f9a896b771686a2b192c258f22d (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
Diffstat (limited to 'src/osmo-bts-sysmo/eeprom.c')
-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 ef66b39..6711243 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;