public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5856] pch: Fix up Darwin and HPUX pch_use_address hooks [PR71934]
Date: Thu,  9 Dec 2021 14:55:59 +0000 (GMT)	[thread overview]
Message-ID: <20211209145559.0BD5D3858402@sourceware.org> (raw)

https://gcc.gnu.org/g:bf15cd665e74791aae87e7e151a0cf0c4cb54684

commit r12-5856-gbf15cd665e74791aae87e7e151a0cf0c4cb54684
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 9 15:54:33 2021 +0100

    pch: Fix up Darwin and HPUX pch_use_address hooks [PR71934]
    
    In the last change, I've changed the arguments from void * to void *&,
    but missed the fact that these hooks will in that case update the value
    the caller will see in an undesirable way.
    
    2021-12-09  Jakub Jelinek  <jakub@redhat.com>
    
            PR pch/71934
            * config/host-darwin.c (darwin_gt_pch_use_address): When reading
            manually the file into mapped area, update mapped_addr as
            an automatic variable rather than addr which is a reference parameter.
            * config/host-hpux.c (hpux_gt_pch_use_address): When reading
            manually the file into mapped area, update addr as
            an automatic variable rather than base which is a reference parameter.

Diff:
---
 gcc/config/host-darwin.c | 4 ++--
 gcc/config/host-hpux.c   | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/config/host-darwin.c b/gcc/config/host-darwin.c
index d3c2858c997..403cd38a248 100644
--- a/gcc/config/host-darwin.c
+++ b/gcc/config/host-darwin.c
@@ -185,10 +185,10 @@ darwin_gt_pch_use_address (void *&addr, size_t sz, int fd, size_t off)
     {
       ssize_t nbytes;
 
-      nbytes = read (fd, addr, MIN (sz, (size_t) -1 >> 1));
+      nbytes = read (fd, mapped_addr, MIN (sz, (size_t) -1 >> 1));
       if (nbytes <= 0)
 	return -1;
-      addr = (char *) addr + nbytes;
+      mapped_addr = (char *) mapped_addr + nbytes;
       sz -= nbytes;
     }
 
diff --git a/gcc/config/host-hpux.c b/gcc/config/host-hpux.c
index 796f501ebfb..c63dda89344 100644
--- a/gcc/config/host-hpux.c
+++ b/gcc/config/host-hpux.c
@@ -115,10 +115,10 @@ hpux_gt_pch_use_address (void *&base, size_t size, int fd, size_t offset)
     {
       ssize_t nbytes;
 
-      nbytes = read (fd, base, MIN (size, SSIZE_MAX));
+      nbytes = read (fd, addr, MIN (size, SSIZE_MAX));
       if (nbytes <= 0)
         return -1;
-      base = (char *) base + nbytes;
+      addr = (char *) addr + nbytes;
       size -= nbytes;
     }


                 reply	other threads:[~2021-12-09 14:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211209145559.0BD5D3858402@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).