]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Stdio/fseeko.c
StdLib/LibC/StdLib/Malloc.c: Revert cast removal to fix GCC build breakage.
[mirror_edk2.git] / StdLib / LibC / Stdio / fseeko.c
index 3c406eaec83d14b36999fb66b6bb95ab966e0c90..662d25f91a3ded9631e2bfafea7ce92cc3505f66 100644 (file)
@@ -1,6 +1,13 @@
-/*  $NetBSD: fseeko.c,v 1.5 2005/03/04 16:04:58 dsl Exp $ */\r
+/*\r
+    Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+    This program and the accompanying materials are licensed and made available\r
+    under the terms and conditions of the BSD License that accompanies this\r
+    distribution.  The full text of the license may be found at\r
+    http://opensource.org/licenses/bsd-license.\r
+\r
+    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-/*-\r
  * Copyright (c) 1990, 1993\r
  *  The Regents of the University of California.  All rights reserved.\r
  *\r
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
  * SUCH DAMAGE.\r
+\r
+    NetBSD: fseeko.c,v 1.5 2005/03/04 16:04:58 dsl Exp\r
  */\r
 //#include <Uefi.h>               // REMOVE, For DEBUG only\r
 //#include <Library/UefiLib.h>    // REMOVE, For DEBUG only\r
 \r
 #include  <LibConfig.h>\r
 #include <sys/EfiCdefs.h>\r
-#if defined(LIBC_SCCS) && !defined(lint)\r
-__RCSID("$NetBSD: fseeko.c,v 1.5 2005/03/04 16:04:58 dsl Exp $");\r
-#endif /* LIBC_SCCS and not lint */\r
 \r
 #include "namespace.h"\r
 #include <sys/types.h>\r
@@ -72,6 +78,10 @@ fseeko(FILE *fp, off_t offset, int whence)
   int havepos;\r
 \r
   _DIAGASSERT(fp != NULL);\r
+  if(fp == NULL) {\r
+    errno = EINVAL;\r
+    return -1;\r
+  }\r
 \r
 #ifdef __GNUC__\r
   /* This outrageous construct just to shut up a GCC warning. */\r
@@ -228,6 +238,7 @@ fseeko(FILE *fp, off_t offset, int whence)
     fp->_r = (int)(n - o);\r
     if (HASUB(fp))\r
       FREEUB(fp);\r
+    WCIO_FREE(fp);    /* Should this really be unconditional??? */\r
     fp->_flags &= ~__SEOF;\r
     FUNLOCKFILE(fp);\r
     return (0);\r
@@ -251,6 +262,7 @@ fseeko(FILE *fp, off_t offset, int whence)
   fp->_p = fp->_bf._base;\r
   if (HASUB(fp))\r
     FREEUB(fp);\r
+  WCIO_FREE(fp);    /* Should this really be unconditional??? */\r
   fp->_flags &= ~__SEOF;\r
   n = (int)(target - curoff);\r
   if (n) {\r
@@ -280,9 +292,10 @@ dumb:
   /* success: clear EOF indicator and discard ungetc() data */\r
   if (HASUB(fp))\r
     FREEUB(fp);\r
+  WCIO_FREE(fp);    /* Should this really be unconditional??? */\r
   fp->_p = fp->_bf._base;\r
   fp->_r = 0;\r
-  /* fp->_w = 0; */ /* unnecessary (I think...) */\r
+  fp->_w = 0;\r
   fp->_flags &= ~__SEOF;\r
   FUNLOCKFILE(fp);\r
 //Print(L"%a: %d\n", __func__, __LINE__);\r