This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: PATCH: fix fixincludes fake warnings



> > If someone would be kind enough to apply this patch,
> > ...
> 
> Well, I think anyone with CVS write access would ask you
> for a ChangeLog entry too.

:-)

I ought to have access in a few hours now, tho.
They just installed ssh-1 for me on my server.


2001-01-30  Bruce Korb  <bkorb@gnu.org>

	fixinc/fixincl.c(process):  Emit error message only if appropriate
:)
	(load_file): do not rely on load_file_data() to close file pointer
	fixinc/fixlib.c(load_file_data): do not close passed in file pointer

Index: fixincl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/fixincl.c,v
retrieving revision 1.49
diff -u -r1.49 fixincl.c
--- fixincl.c   2001/01/05 16:28:58     1.49
+++ fixincl.c   2001/01/29 18:32:46
@@ -364,14 +364,13 @@
     res = (char*)mmap ((void*)NULL, data_map_size, PROT_READ,
                        MAP_PRIVATE, data_map_fd, 0);
   if (res == (char*)BAD_ADDR)
+#endif
     {
+      FILE* fp = fdopen (data_map_fd, "r");
       curr_data_mapped = BOOL_FALSE;
-      res = load_file_data ( fdopen (data_map_fd, "r"));
+      res = load_file_data (fp);
+      fclose (fp);
     }
-#else
-  curr_data_mapped = BOOL_FALSE;
-  res = load_file_data ( fdopen (data_map_fd, "r"));
-#endif
 
   return res;
 }
@@ -1431,8 +1430,9 @@
   read_fd = open (pz_temp_file, O_RDONLY);
   if (read_fd < 0)
     {
-      fprintf (stderr, "error %d (%s) opening output (%s) for read\n",
-               errno, xstrerror (errno), pz_temp_file);
+      if (errno != ENOENT)
+        fprintf (stderr, "error %d (%s) opening output (%s) for
read\n",
+                 errno, xstrerror (errno), pz_temp_file);
     }
   else
     {
Index: fixlib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fixinc/fixlib.c,v
retrieving revision 1.15
diff -u -r1.15 fixlib.c
--- fixlib.c    2000/12/02 19:46:32     1.15
+++ fixlib.c    2001/01/29 18:40:08
@@ -39,6 +39,9 @@
   int    space_left = -1;  /* allow for terminating NUL */
   size_t space_used = 0;
 
+  if (fp == (FILE*)NULL)
+    return pz_data;
+
   do
     {
       size_t  size_read;
@@ -62,7 +65,6 @@
                 fprintf (stderr, "error %d (%s) reading input\n", err,
                          xstrerror (err));
               free ((void *) pz_data);
-              fclose (fp);
               return (char *) NULL;
             }
         }
@@ -73,7 +75,6 @@
 
   pz_data = xrealloc ((void*)pz_data, space_used+1 );
   pz_data[ space_used ] = NUL;
-  fclose (fp);
 
   return pz_data;
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]