From: Lucas De Marchi Date: Sat, 16 Jun 2012 01:14:00 +0000 (-0300) Subject: depmod: use ferror and fclose to check for error X-Git-Tag: v9~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f376cd87742246f00fe552596975a00ec5d60b1;p=platform%2Fupstream%2Fkmod.git depmod: use ferror and fclose to check for error Thanks to hpa for point this out. --- diff --git a/tools/depmod.c b/tools/depmod.c index 790cc76..834bb05 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -2236,8 +2236,7 @@ static int depmod_output(struct depmod *depmod, FILE *out) for (itr = depfiles; itr->name != NULL; itr++) { FILE *fp = out; char tmp[NAME_MAX] = ""; - int r; - long eof; + int r, ferr; if (fp == NULL) { int flags = O_CREAT | O_TRUNC | O_WRONLY; @@ -2263,8 +2262,8 @@ static int depmod_output(struct depmod *depmod, FILE *out) if (fp == out) continue; - eof = ftell(fp); - fclose(fp); + ferr = ferror(fp) | fclose(fp); + if (r < 0) { if (unlinkat(dfd, tmp, 0) != 0) ERR("unlinkat(%s, %s): %m\n", dname, tmp); @@ -2283,10 +2282,10 @@ static int depmod_output(struct depmod *depmod, FILE *out) break; } - if (eof == EOF) { + if (ferr) { err = -ENOSPC; - ERR("Could not create index: output truncated: %s\n", - strerror(-err)); + ERR("Could not create index '%s'. Output is truncated: %s\n", + itr->name, strerror(-err)); break; } }