2001-10-05 H.J. Lu <hjl@gnu.org>
[deliverable/binutils-gdb.git] / bfd / opncls.c
index 57ca0d0a25948b5180397c65ff1311e290057222..0cf6723266ddd9fcd59666cef1ab934446276724 100644 (file)
@@ -1,5 +1,6 @@
 /* opncls.c -- open and close a BFD.
-   Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 1997
+   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
+   2001
    Free Software Foundation, Inc.
 
    Written by Cygnus Support.
@@ -48,7 +49,7 @@ _bfd_new_bfd ()
 {
   bfd *nbfd;
 
-  nbfd = (bfd *) bfd_zmalloc (sizeof (bfd));
+  nbfd = (bfd *) bfd_zmalloc ((bfd_size_type) sizeof (bfd));
   if (nbfd == NULL)
     return NULL;
 
@@ -67,7 +68,7 @@ _bfd_new_bfd ()
   nbfd->sections = (asection *) NULL;
   nbfd->format = bfd_unknown;
   nbfd->my_archive = (bfd *) NULL;
-  nbfd->origin = 0;                            
+  nbfd->origin = 0;
   nbfd->opened_once = false;
   nbfd->output_has_begun = false;
   nbfd->section_count = 0;
@@ -106,7 +107,7 @@ FUNCTION
        bfd_openr
 
 SYNOPSIS
-        bfd *bfd_openr(CONST char *filename, CONST char *target);
+        bfd *bfd_openr(const char *filename, const char *target);
 
 DESCRIPTION
        Open the file @var{filename} (using <<fopen>>) with the target
@@ -121,8 +122,8 @@ DESCRIPTION
 
 bfd *
 bfd_openr (filename, target)
-     CONST char *filename;
-     CONST char *target;
+     const char *filename;
+     const char *target;
 {
   bfd *nbfd;
   const bfd_target *target_vec;
@@ -168,7 +169,7 @@ FUNCTION
          bfd_fdopenr
 
 SYNOPSIS
-         bfd *bfd_fdopenr(CONST char *filename, CONST char *target, int fd);
+         bfd *bfd_fdopenr(const char *filename, const char *target, int fd);
 
 DESCRIPTION
          <<bfd_fdopenr>> is to <<bfd_fopenr>> much like <<fdopen>> is to <<fopen>>.
@@ -191,8 +192,8 @@ DESCRIPTION
 
 bfd *
 bfd_fdopenr (filename, target, fd)
-     CONST char *filename;
-     CONST char *target;
+     const char *filename;
+     const char *target;
      int fd;
 {
   bfd *nbfd;
@@ -248,7 +249,7 @@ bfd_fdopenr (filename, target, fd)
      be written through, although doing so requires that we end
      the previous clause with a preposition.  */
   /* (O_ACCMODE) parens are to avoid Ultrix header file bug */
-  switch (fdflags & O_ACCMODE)
+  switch (fdflags & (O_ACCMODE))
     {
     case O_RDONLY: nbfd->direction = read_direction; break;
     case O_WRONLY: nbfd->direction = write_direction; break;
@@ -306,7 +307,7 @@ bfd_openstreamr (filename, target, streamarg)
   nbfd->iostream = (PTR) stream;
   nbfd->filename = filename;
   nbfd->direction = read_direction;
-                               
+
   if (! bfd_cache_init (nbfd))
     {
       objalloc_free ((struct objalloc *) nbfd->memory);
@@ -327,7 +328,7 @@ FUNCTION
        bfd_openw
 
 SYNOPSIS
-       bfd *bfd_openw(CONST char *filename, CONST char *target);
+       bfd *bfd_openw(const char *filename, const char *target);
 
 DESCRIPTION
        Create a BFD, associated with file @var{filename}, using the
@@ -339,8 +340,8 @@ DESCRIPTION
 
 bfd *
 bfd_openw (filename, target)
-     CONST char *filename;
-     CONST char *target;
+     const char *filename;
+     const char *target;
 {
   bfd *nbfd;
   const bfd_target *target_vec;
@@ -428,7 +429,7 @@ bfd_close (abfd)
 
       if (stat (abfd->filename, &buf) == 0)
        {
-         int mask = umask (0);
+         unsigned int mask = umask (0);
          umask (mask);
          chmod (abfd->filename,
                 (0777
@@ -483,7 +484,7 @@ bfd_close_all_done (abfd)
 
       if (stat (abfd->filename, &buf) == 0)
        {
-         int mask = umask (0);
+         unsigned int mask = umask (0);
          umask (mask);
          chmod (abfd->filename,
                 (0777
@@ -502,7 +503,7 @@ FUNCTION
        bfd_create
 
 SYNOPSIS
-       bfd *bfd_create(CONST char *filename, bfd *templ);
+       bfd *bfd_create(const char *filename, bfd *templ);
 
 DESCRIPTION
        Create a new BFD in the manner of
@@ -514,7 +515,7 @@ DESCRIPTION
 
 bfd *
 bfd_create (filename, templ)
-     CONST char *filename;
+     const char *filename;
      bfd *templ;
 {
   bfd *nbfd;
@@ -559,9 +560,10 @@ bfd_make_writable(abfd)
       return false;
     }
 
-  bim = (struct bfd_in_memory *) bfd_malloc (sizeof (struct bfd_in_memory));
+  bim = ((struct bfd_in_memory *)
+        bfd_malloc ((bfd_size_type) sizeof (struct bfd_in_memory)));
   abfd->iostream = (PTR) bim;
-  /* bfd_write will grow these as needed */
+  /* bfd_bwrite will grow these as needed */
   bim->size = 0;
   bim->buffer = 0;
 
@@ -612,7 +614,7 @@ bfd_make_readable(abfd)
   abfd->sections = (asection *) NULL;
   abfd->format = bfd_unknown;
   abfd->my_archive = (bfd *) NULL;
-  abfd->origin = 0;                            
+  abfd->origin = 0;
   abfd->opened_once = false;
   abfd->output_has_begun = false;
   abfd->section_count = 0;
@@ -649,10 +651,16 @@ DESCRIPTION
 PTR
 bfd_alloc (abfd, size)
      bfd *abfd;
-     size_t size;
+     bfd_size_type size;
 {
   PTR ret;
 
+  if (size != (unsigned long) size)
+    {
+      bfd_set_error (bfd_error_no_memory);
+      return NULL;
+    }
+
   ret = objalloc_alloc (abfd->memory, (unsigned long) size);
   if (ret == NULL)
     bfd_set_error (bfd_error_no_memory);
@@ -662,13 +670,13 @@ bfd_alloc (abfd, size)
 PTR
 bfd_zalloc (abfd, size)
      bfd *abfd;
-     size_t size;
+     bfd_size_type size;
 {
   PTR res;
 
   res = bfd_alloc (abfd, size);
   if (res)
-    memset (res, 0, size);
+    memset (res, 0, (size_t) size);
   return res;
 }
 
This page took 0.026597 seconds and 4 git commands to generate.