Fix unreachable state. 92/61392/1
authorMun, Gwan-gyeong <kk.moon@samsung.com>
Mon, 7 Mar 2016 10:45:35 +0000 (19:45 +0900)
committerMun, Gwan-gyeong <kk.moon@samsung.com>
Mon, 7 Mar 2016 10:45:35 +0000 (19:45 +0900)
 - fwrite() only retrurns a short item count (or zero). so program does not reach under zero state.

Change-Id: Ibed62e2933f88dcbaccc74a15d18253ea9681c77

src/tpl_utils.h

index 34912ee..642f091 100644 (file)
@@ -688,22 +688,22 @@ __tpl_util_image_dump_bmp(const char *file, const void *data, int width,
                bmp_dib_v3_header_t.nplanes = 1;
                bmp_dib_v3_header_t.bmp_bytesz = width * height * 3;
 
-               if (fwrite(&bmpfile_magic, sizeof (bmpfile_magic), 1, fp) < 0) {
+               if (fwrite(&bmpfile_magic, sizeof (bmpfile_magic), 1, fp) < 1) {
                        fclose (fp);
                        return -1;
                }
-               if (fwrite(&bmpfile_header, sizeof (bmpfile_header), 1, fp) < 0) {
+               if (fwrite(&bmpfile_header, sizeof (bmpfile_header), 1, fp) < 1) {
                        fclose (fp);
                        return -1;
                }
-               if (fwrite (&bmp_dib_v3_header_t, sizeof (bmp_dib_v3_header_t), 1, fp) < 0) {
+               if (fwrite(&bmp_dib_v3_header_t, sizeof (bmp_dib_v3_header_t), 1, fp) < 1) {
                        fclose (fp);
                        return -1;
                }
 
                blocks = (unsigned int *)data;
                for (i = 0; i < height * width; i++) {
-                       if (fwrite (&blocks[i], 3, 1, fp) < 0) {
+                       if (fwrite(&blocks[i], 3, 1, fp) < 1) {
                                fclose(fp);
                                return -1;
                        }