public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 0/1] libgfortran: Fix compilation of gf_vsnprintf
@ 2024-04-04 15:16 Ian McInerney
  2024-04-04 15:16 ` [PATCH 1/1] " Ian McInerney
  2024-04-12 10:41 ` [PATCH 0/1] " McInerney, Ian S
  0 siblings, 2 replies; 4+ messages in thread
From: Ian McInerney @ 2024-04-04 15:16 UTC (permalink / raw)
  To: fortran, gcc-patches; +Cc: Ian McInerney

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.

I am not actually sure what configurations are using this fallback, since
it was added in 2018 and no patches have been made to fix this compilation
error. Testing this also isn't straightforward, and I had to do a bit of a
hack to get it to use the codepath to show the compilation error:
 1) Configure and build as normal to generate the config.h header
 2) Modify config.h directly to undefine HAVE_VSNPRINTF
 3) Directly call the libgfortran compilation step

Ian McInerney (1):
  libgfortran: Fix compilation of gf_vsnprintf

 libgfortran/runtime/error.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


base-commit: b7bd2ec73d66f7487bc8842b24daecaa802a72e6
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] libgfortran: Fix compilation of gf_vsnprintf
  2024-04-04 15:16 [PATCH 0/1] libgfortran: Fix compilation of gf_vsnprintf Ian McInerney
@ 2024-04-04 15:16 ` Ian McInerney
  2024-04-12 10:41 ` [PATCH 0/1] " McInerney, Ian S
  1 sibling, 0 replies; 4+ messages in thread
From: Ian McInerney @ 2024-04-04 15:16 UTC (permalink / raw)
  To: fortran, gcc-patches; +Cc: Ian McInerney

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/1] libgfortran: Fix compilation of gf_vsnprintf
  2024-04-04 15:16 [PATCH 0/1] libgfortran: Fix compilation of gf_vsnprintf Ian McInerney
  2024-04-04 15:16 ` [PATCH 1/1] " Ian McInerney
@ 2024-04-12 10:41 ` McInerney, Ian S
  2024-04-12 11:53   ` FX Coudert
  1 sibling, 1 reply; 4+ messages in thread
From: McInerney, Ian S @ 2024-04-12 10:41 UTC (permalink / raw)
  To: fortran, gcc-patches

Gentle ping. If this looks good, can someone commit to main (I don't have commit privileges). This is also something that could be considered for stable, since it's been around for many years.

-Ian




From: McInerney, Ian S <i.mcinerney17@imperial.ac.uk>
Sent: Thursday, April 4, 2024 4:16 PM
To: fortran@gcc.gnu.org <fortran@gcc.gnu.org>; gcc-patches@gcc.gnu.org <gcc-patches@gcc.gnu.org>
Cc: McInerney, Ian S <i.mcinerney17@imperial.ac.uk>
Subject: [PATCH 0/1] libgfortran: Fix compilation of gf_vsnprintf
 
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.

I am not actually sure what configurations are using this fallback, since
it was added in 2018 and no patches have been made to fix this compilation
error. Testing this also isn't straightforward, and I had to do a bit of a
hack to get it to use the codepath to show the compilation error:
 1) Configure and build as normal to generate the config.h header
 2) Modify config.h directly to undefine HAVE_VSNPRINTF
 3) Directly call the libgfortran compilation step

Ian McInerney (1):
  libgfortran: Fix compilation of gf_vsnprintf

 libgfortran/runtime/error.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


base-commit: b7bd2ec73d66f7487bc8842b24daecaa802a72e6
--
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/1] libgfortran: Fix compilation of gf_vsnprintf
  2024-04-12 10:41 ` [PATCH 0/1] " McInerney, Ian S
@ 2024-04-12 11:53   ` FX Coudert
  0 siblings, 0 replies; 4+ messages in thread
From: FX Coudert @ 2024-04-12 11:53 UTC (permalink / raw)
  To: McInerney, Ian S; +Cc: fortran, gcc-patches

> Gentle ping. If this looks good, can someone commit to main (I don't have commit privileges). This is also something that could be considered for stable, since it's been around for many years.

Thanks for the patch. Pushed as https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=3bd3ca05b519b99b5ea570c10fd80737cd4c6c49

FX

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-12 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04 15:16 [PATCH 0/1] libgfortran: Fix compilation of gf_vsnprintf Ian McInerney
2024-04-04 15:16 ` [PATCH 1/1] " Ian McInerney
2024-04-12 10:41 ` [PATCH 0/1] " McInerney, Ian S
2024-04-12 11:53   ` FX Coudert

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).