summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2008-10-13 12:09:31 +0000
committerCedric BAIL <cedric.bail@free.fr>2008-10-13 12:09:31 +0000
commit6ee6cdeeb36b973de1b28590f17c7c6ea20be900 (patch)
tree0013aa3dffe89fd1317a90ac0a040ba85cc5ea42
parent4c0daa8810e0b793d8947ac431411515df3f2478 (diff)
Correctly use ferror.
SVN revision: 36617
-rw-r--r--legacy/eet/src/lib/eet_lib.c62
1 files changed, 34 insertions, 28 deletions
diff --git a/legacy/eet/src/lib/eet_lib.c b/legacy/eet/src/lib/eet_lib.c
index 831a540e9a..aebf181ea5 100644
--- a/legacy/eet/src/lib/eet_lib.c
+++ b/legacy/eet/src/lib/eet_lib.c
@@ -548,13 +548,16 @@ eet_flush2(Eet_File *ef)
548 return EET_ERROR_NONE; 548 return EET_ERROR_NONE;
549 549
550 write_error: 550 write_error:
551 switch (ferror(ef->fp)) 551 if (ferror(ef->fp))
552 { 552 {
553 case EFBIG: error = EET_ERROR_WRITE_ERROR_FILE_TOO_BIG; break; 553 switch (errno)
554 case EIO: error = EET_ERROR_WRITE_ERROR_IO_ERROR; break; 554 {
555 case ENOSPC: error = EET_ERROR_WRITE_ERROR_OUT_OF_SPACE; break; 555 case EFBIG: error = EET_ERROR_WRITE_ERROR_FILE_TOO_BIG; break;
556 case EPIPE: error = EET_ERROR_WRITE_ERROR_FILE_CLOSED; break; 556 case EIO: error = EET_ERROR_WRITE_ERROR_IO_ERROR; break;
557 default: error = EET_ERROR_WRITE_ERROR; break; 557 case ENOSPC: error = EET_ERROR_WRITE_ERROR_OUT_OF_SPACE; break;
558 case EPIPE: error = EET_ERROR_WRITE_ERROR_FILE_CLOSED; break;
559 default: error = EET_ERROR_WRITE_ERROR; break;
560 }
558 } 561 }
559 sign_error: 562 sign_error:
560 if (ef->fp) fclose(ef->fp); 563 if (ef->fp) fclose(ef->fp);
@@ -655,31 +658,34 @@ eet_flush(Eet_File *ef)
655 return EET_ERROR_NONE; 658 return EET_ERROR_NONE;
656 659
657 write_error: 660 write_error:
658 switch (ferror(ef->fp)) 661 if (ferror(ef->fp))
659 { 662 {
660 case EFBIG: 663 switch (errno)
661 fclose(ef->fp); 664 {
662 ef->fp = NULL; 665 case EFBIG:
663 return EET_ERROR_WRITE_ERROR_FILE_TOO_BIG; 666 fclose(ef->fp);
664 case EIO: 667 ef->fp = NULL;
665 fclose(ef->fp); 668 return EET_ERROR_WRITE_ERROR_FILE_TOO_BIG;
666 ef->fp = NULL; 669 case EIO:
667 return EET_ERROR_WRITE_ERROR_IO_ERROR; 670 fclose(ef->fp);
668 case ENOSPC: 671 ef->fp = NULL;
669 fclose(ef->fp); 672 return EET_ERROR_WRITE_ERROR_IO_ERROR;
670 ef->fp = NULL; 673 case ENOSPC:
671 return EET_ERROR_WRITE_ERROR_OUT_OF_SPACE; 674 fclose(ef->fp);
672 case EPIPE: 675 ef->fp = NULL;
673 fclose(ef->fp); 676 return EET_ERROR_WRITE_ERROR_OUT_OF_SPACE;
674 ef->fp = NULL; 677 case EPIPE:
675 return EET_ERROR_WRITE_ERROR_FILE_CLOSED; 678 fclose(ef->fp);
676 default: 679 ef->fp = NULL;
677 fclose(ef->fp); 680 return EET_ERROR_WRITE_ERROR_FILE_CLOSED;
678 ef->fp = NULL; 681 default:
679 return EET_ERROR_WRITE_ERROR; 682 fclose(ef->fp);
683 ef->fp = NULL;
684 return EET_ERROR_WRITE_ERROR;
685 }
680 } 686 }
681 sign_error: 687 sign_error:
682 fclose(ef->fp); 688 if (ef->fp) fclose(ef->fp);
683 ef->fp = NULL; 689 ef->fp = NULL;
684 return EET_ERROR_WRITE_ERROR; 690 return EET_ERROR_WRITE_ERROR;
685} 691}