summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2015-02-28 14:45:07 -0300
committerLucas De Marchi <lucas.demarchi@intel.com>2015-02-28 14:57:00 -0300
commit22df456760cf9e42302235c82125c2eb578050b2 (patch)
tree8f64c0ed18967a14850135e3b893744dca641101
parentade6b25c9a66d4a4cbce4879000f6cbfdcd794c5 (diff)
downloadkmod-22df456760cf9e42302235c82125c2eb578050b2.tar.gz
depmod: add asserts to ensure positive return from ftell()
Also ignore some errors that will later be returned by ferror().
-rw-r--r--tools/depmod.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index 851af0c..231b9ab 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -407,6 +407,7 @@ static void index_write(const struct index_node *node, FILE *out)
/* Second word is reserved for the offset of the root node */
initial_offset = ftell(out);
+ assert(initial_offset >= 0);
u = 0;
fwrite(&u, sizeof(uint32_t), 1, out);
@@ -415,9 +416,10 @@ static void index_write(const struct index_node *node, FILE *out)
/* Update first word */
final_offset = ftell(out);
- fseek(out, initial_offset, SEEK_SET);
+ assert(final_offset >= 0);
+ (void)fseek(out, initial_offset, SEEK_SET);
fwrite(&u, sizeof(uint32_t), 1, out);
- fseek(out, final_offset, SEEK_SET);
+ (void)fseek(out, final_offset, SEEK_SET);
}
/* END: code from module-init-tools/index.c just modified to compile here.