[Patch, libgfortran, 4.5] PR25561, 37754: New low level I/O library

Thomas Schwinge thomas@codesourcery.com
Fri Sep 5 15:52:00 GMT 2014


Hi!

On Tue, 06 Jan 2009 00:10:02 +0200, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:
> attached is a substantially reworked low level I/O library for gfortran.
> [...]

Due to a recent improvement in GCC, it is now pointing out an issue in
the following code:

> 2009-01-05  Janne Blomqvist  <jb@gcc.gnu.org>
> 
>         PR libfortran/25561 libfortran/37754
> 	* [...]

> --- a/libgfortran/io/transfer.c
> +++ b/libgfortran/io/transfer.c
> [...]
>    if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0)
> -    dtp->u.p.size_used += (GFC_IO_INT) nread;
> +    dtp->u.p.size_used += (GFC_IO_INT) *nbytes;
>  
> -  if (nread != *nbytes)
> -    {                          /* Short read, this shouldn't happen.  */
> -      if (likely (dtp->u.p.current_unit->pad_status == PAD_YES))
> -       *nbytes = nread;
> -      else
> +  if (norig != *nbytes)
> +    {                          
> +      /* Short read, this shouldn't happen.  */
> +      if (!dtp->u.p.current_unit->pad_status == PAD_YES)
>         {
>           generate_error (&dtp->common, LIBERROR_EOR, NULL);
>           source = NULL;
>         }
>      }
>  
> -  dtp->u.p.current_unit->strm_pos += (gfc_offset) nread;
> +  dtp->u.p.current_unit->strm_pos += (gfc_offset) *nbytes;
> [...]

    ../../../source/libgfortran/io/transfer.c: In function 'read_block_form':
    ../../../source/libgfortran/io/transfer.c:478:46: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
           if (!dtp->u.p.current_unit->pad_status == PAD_YES)
                                                  ^

I assume the following is what is intended, but I have not made an
attempt to verify this:

diff --git libgfortran/io/transfer.c libgfortran/io/transfer.c
index af2932c..710de7a 100644
--- libgfortran/io/transfer.c
+++ libgfortran/io/transfer.c
@@ -475,7 +475,7 @@ read_block_form (st_parameter_dt *dtp, int * nbytes)
   if (norig != *nbytes)
     {
       /* Short read, this shouldn't happen.  */
-      if (!dtp->u.p.current_unit->pad_status == PAD_YES)
+      if (!(dtp->u.p.current_unit->pad_status == PAD_YES))
 	{
 	  generate_error (&dtp->common, LIBERROR_EOR, NULL);
 	  source = NULL;


Grüße,
 Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140905/5589f4e7/attachment.sig>


More information about the Gcc-patches mailing list