delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/06/12/05:07:35

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Message-ID: <37622161.87D858A@vinschen.de>
Date: Sat, 12 Jun 1999 10:59:13 +0200
From: Corinna Vinschen <corinna AT vinschen DOT de>
X-Mailer: Mozilla 4.6 [en] (WinNT; I)
X-Accept-Language: de,en
MIME-Version: 1.0
To: Chris Faylor <cgf AT cygnus DOT com>, cygwin-developers AT sourceware DOT cygnus DOT com
Subject: fhandler patch

This is a multi-part message in MIME format.
--------------AEF0B44504C221349F012281
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi!

I've found an error in fhandler.cc. The method `fhandler::read' didn't
return an error anymore if the `raw_read' method returns with -1!

The patch is attached.

Regards,
Corinna

ChangeLog:
==========

Sat Jun 12 10:54:00 1999  Corinna Vinschen  <corinna AT vinschen DOT de>

	* fhandler.cc (fhandler_base::read): Returns correct value
	if raw_read fails.
	* fhandler_raw.cc: More trace output.
	* fhandler_floppy.cc: Ditto.
	* fhandler_tape.cc: Ditto.
--------------AEF0B44504C221349F012281
Content-Type: text/plain; charset=us-ascii;
 name="fh-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="fh-patch"

Index: fhandler.cc
===================================================================
RCS file: /src/cvsroot/winsup-990602/fhandler.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fhandler.cc
--- fhandler.cc	1999/06/03 20:38:57	1.1.1.1
+++ fhandler.cc	1999/06/12 08:57:44
@@ -441,7 +441,7 @@ fhandler_base::read (void *in_ptr, size_
 
   int chars_to_process = len ? raw_read (ptr, len) : 0;
   if (chars_to_process <= 0)
-    return ptr - (char *) in_ptr;
+    return chars_to_process;
 
   chars_to_process += in_len - len;
 
Index: fhandler_floppy.cc
===================================================================
RCS file: /src/cvsroot/winsup-990602/fhandler_floppy.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fhandler_floppy.cc
--- fhandler_floppy.cc	1999/06/03 20:38:58	1.1.1.1
+++ fhandler_floppy.cc	1999/06/12 08:29:15
@@ -21,13 +21,19 @@ details. */
 int
 fhandler_dev_floppy::is_eom (int win_error)
 {
-  return win_error == ERROR_INVALID_PARAMETER;
+  int ret = (win_error == ERROR_INVALID_PARAMETER);
+  if (ret)
+    debug_printf ("end of medium");
+  return ret;
 }
 
 int
 fhandler_dev_floppy::is_eof (int win_error)
 {
-  return 0;
+  int ret = 0;
+  if (ret)
+    debug_printf ("end of file");
+  return ret;
 }
 
 fhandler_dev_floppy::fhandler_dev_floppy (const char *name, int unit) : fhandler_dev_raw (FH_FLOPPY, name, unit)
Index: fhandler_raw.cc
===================================================================
RCS file: /src/cvsroot/winsup-990602/fhandler_raw.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fhandler_raw.cc
--- fhandler_raw.cc	1999/06/03 20:38:58	1.1.1.1
+++ fhandler_raw.cc	1999/06/12 08:33:51
@@ -213,6 +213,7 @@ fhandler_dev_raw::raw_read (void *ptr, s
 				  get_name (), ret);
 		  if (!is_eof (ret) && !is_eom (ret))
 		    {
+                      debug_printf ("return -1, set errno to EACCES");
 		      set_errno (EACCES);
 		      return -1;
 		    }
@@ -226,6 +227,7 @@ fhandler_dev_raw::raw_read (void *ptr, s
 		    {
 		      if (!bytes_read && is_eom (ret))
 			{
+                          debug_printf ("return -1, set errno to ENOSPC");
 			  set_errno (ENOSPC);
 			  return -1;
 			}
@@ -256,6 +258,7 @@ fhandler_dev_raw::raw_read (void *ptr, s
 		      get_name (), ret);
       if (!is_eof (ret) && !is_eom (ret))
 	{
+          debug_printf ("return -1, set errno to EACCES");
 	  set_errno (EACCES);
 	  return -1;
 	}
@@ -268,6 +271,7 @@ fhandler_dev_raw::raw_read (void *ptr, s
 	}
       else if (is_eom (ret))
 	{
+          debug_printf ("return -1, set errno to ENOSPC");
 	  set_errno (ENOSPC);
 	  return -1;
 	}
Index: fhandler_tape.cc
===================================================================
RCS file: /src/cvsroot/winsup-990602/fhandler_tape.cc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 fhandler_tape.cc
--- fhandler_tape.cc	1999/06/03 20:38:58	1.1.1.1
+++ fhandler_tape.cc	1999/06/12 08:28:02
@@ -31,16 +31,22 @@ fhandler_dev_tape::clear (void)
 int
 fhandler_dev_tape::is_eom (int win_error)
 {
-  return ((win_error == ERROR_END_OF_MEDIA)
+  int ret = ((win_error == ERROR_END_OF_MEDIA)
 	  || (win_error == ERROR_EOM_OVERFLOW)
 	  || (win_error == ERROR_NO_DATA_DETECTED));
+  if (ret)
+    debug_printf ("end of medium");
+  return ret;
 }
 
 int
 fhandler_dev_tape::is_eof (int win_error)
 {
-  return ((win_error == ERROR_FILEMARK_DETECTED)
+  int ret = ((win_error == ERROR_FILEMARK_DETECTED)
 	  || (win_error == ERROR_SETMARK_DETECTED));
+  if (ret)
+    debug_printf ("end of file");
+  return ret;
 }
 
 fhandler_dev_tape::fhandler_dev_tape (const char *name, int unit) : fhandler_dev_raw (FH_TAPE, name, unit)


--------------AEF0B44504C221349F012281--


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019