Add to check the return of fseek() 87/198687/1 accepted/tizen/unified/20190207.120249 submit/tizen/20190131.041045
authorjiyong.min <jiyong.min@samsung.com>
Tue, 29 Jan 2019 00:37:27 +0000 (09:37 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Tue, 29 Jan 2019 00:37:27 +0000 (09:37 +0900)
 - If fseek() is failed, -1 is returned and errno is set to indicate the errors.

Change-Id: I7174ca625da1026ebe07cb72fd97459d89c05d75

tests/mm_file_test.c

index 3116ddc..65c9c6b 100755 (executable)
@@ -175,9 +175,9 @@ inline static int mm_file_is_little_endian(void)
        do {    \
                FILE *fp = fopen(FILE_PATH, "r");       \
                if (fp) {       \
-                       fseek(fp, 0, SEEK_END); \
+                       if (fseek(fp, 0, SEEK_END) < 0) { printf("fseek failed\n"); fclose(fp); break; }        \
                        size = ftell(fp);       \
-                       fseek(fp, 0, SEEK_SET); \
+                       if (fseek(fp, 0, SEEK_SET) < 0) { printf("fseek failed\n"); fclose(fp); break; }        \
                        if (size > 0) data = malloc(size);      \
                        if (data != NULL) { if (fread(data, size, sizeof(char), fp) != size) { printf("fread error\n"); } }     \
                        fclose(fp);     \