carl9170 firmware tools: fix crash if source is a directory
authorChristian Lamparter <chunkeey@googlemail.com>
Mon, 30 Aug 2010 04:05:06 +0000 (06:05 +0200)
committerChristian Lamparter <chunkeey@googlemail.com>
Mon, 30 Aug 2010 04:05:06 +0000 (06:05 +0200)
The tools will no longer crash if the "firmware" file is
a directory.

Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
tools/lib/carlfw.c

index de942219833ecc87c3ca713d25a6022fcd8c6fdf..694e8d848a09f11dca33341aadf2d25288a534b0 100644 (file)
@@ -170,7 +170,7 @@ static int __carlfw_load(struct carlfw_file *file, const char *name, const char
 
        err = fread(file->data, file->len, 1, fh);
        if (err != 1)
-               return ferror(fh);
+               return -ferror(fh);
 
        file->name = strdup(name);
        fclose(fh);
@@ -563,14 +563,14 @@ int carlfw_store(struct carlfw *fw)
 
                err = fwrite(iter->data, elen, 1, fh);
                if (err != 1) {
-                       err = ferror(fh);
+                       err = -ferror(fh);
                        goto close_out;
                }
        }
 
        err = fwrite(&last_desc, sizeof(last_desc), 1, fh);
        if (err != 1) {
-               err = ferror(fh);
+               err = -ferror(fh);
                goto close_out;
        }