public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian McInerney <i.mcinerney17@imperial.ac.uk>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc: Ian McInerney <i.mcinerney17@imperial.ac.uk>
Subject: [PATCH 1/1] libgfortran: Fix compilation of gf_vsnprintf
Date: Thu,  4 Apr 2024 16:16:32 +0100	[thread overview]
Message-ID: <20240404151632.3026631-2-i.mcinerney17@imperial.ac.uk> (raw)
In-Reply-To: <20240404151632.3026631-1-i.mcinerney17@imperial.ac.uk>

The fallback function (gf_vsnprintf) to provide a vsnprintf function
if the system library doesn't have one would not compile due to the
variable name for the string's destination buffer not being updated
after the refactor in 2018 in edaaef601d0d6d263fba87b42d6d04c99dd23dba.

This updates the internal logic of gf_vsnprintf to now use the str
variable defined in the function signature.

libgfortran/ChangeLog:

2024-04-04  Ian McInerney  <i.mcinerney17@imperial.ac.uk>

 * runtime/error.c (gf_vsnprintf): Fix compilation

Signed off by: Ian McInerney <i.mcinerney17@imperial.ac.uk>
---
 libgfortran/runtime/error.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libgfortran/runtime/error.c b/libgfortran/runtime/error.c
index e840f539599..044298294d8 100644
--- a/libgfortran/runtime/error.c
+++ b/libgfortran/runtime/error.c
@@ -142,15 +142,15 @@ gf_vsnprintf (char *str, size_t size, const char *format, va_list ap)
 {
   int written;
 
-  written = vsprintf(buffer, format, ap);
+  written = vsprintf(str, format, ap);
 
   if (written >= size - 1)
     {
-      /* The error message was longer than our buffer.  Ouch.  Because
+      /* The error message was longer than the string size.  Ouch.  Because
 	 we may have messed up things badly, report the error and
 	 quit.  */
-#define ERROR_MESSAGE "Internal error: buffer overrun in gf_vsnprintf()\n"
-      write (STDERR_FILENO, buffer, size - 1);
+#define ERROR_MESSAGE "Internal error: string overrun in gf_vsnprintf()\n"
+      write (STDERR_FILENO, str, size - 1);
       write (STDERR_FILENO, ERROR_MESSAGE, strlen (ERROR_MESSAGE));
       sys_abort ();
 #undef ERROR_MESSAGE
-- 
2.43.0


  reply	other threads:[~2024-04-04 15:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-04 15:16 [PATCH 0/1] " Ian McInerney
2024-04-04 15:16 ` Ian McInerney [this message]
2024-04-12 10:41 ` McInerney, Ian S
2024-04-12 11:53   ` FX Coudert

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=20240404151632.3026631-2-i.mcinerney17@imperial.ac.uk \
    --to=i.mcinerney17@imperial.ac.uk \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@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).