* [PATCH] tst-tzset: output reason when creating 4GiB file fails
@ 2021-10-28 21:23 Stafford Horne
2021-10-29 12:14 ` Adhemerval Zanella
0 siblings, 1 reply; 2+ messages in thread
From: Stafford Horne @ 2021-10-28 21:23 UTC (permalink / raw)
To: GLIBC patches
Currently, if the temporary file creation fails the create_tz_file
function returns NULL. The NULL pointer is then passed to setenv which
causes a SIGSEGV. Rather than failing with a SIGSEGV print a warning
and exit.
---
timezone/tst-tzset.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/timezone/tst-tzset.c b/timezone/tst-tzset.c
index d6da2932bb..e6aef6bf51 100644
--- a/timezone/tst-tzset.c
+++ b/timezone/tst-tzset.c
@@ -103,6 +103,13 @@ static void
test_tz_file (off64_t size)
{
char *path = create_tz_file (size);
+ if (path == NULL)
+ {
+ printf ("creating timezone file of size: %lld MiB failed.\n",
+ size / (1024 * 1024));
+ exit (1);
+ }
+
if (setenv ("TZ", path, 1) < 0)
{
printf ("setenv failed: %m\n");
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] tst-tzset: output reason when creating 4GiB file fails
2021-10-28 21:23 [PATCH] tst-tzset: output reason when creating 4GiB file fails Stafford Horne
@ 2021-10-29 12:14 ` Adhemerval Zanella
0 siblings, 0 replies; 2+ messages in thread
From: Adhemerval Zanella @ 2021-10-29 12:14 UTC (permalink / raw)
To: Stafford Horne, GLIBC patches
On 28/10/2021 18:23, Stafford Horne via Libc-alpha wrote:
> Currently, if the temporary file creation fails the create_tz_file
> function returns NULL. The NULL pointer is then passed to setenv which
> causes a SIGSEGV. Rather than failing with a SIGSEGV print a warning
> and exit.
> ---
> timezone/tst-tzset.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/timezone/tst-tzset.c b/timezone/tst-tzset.c
> index d6da2932bb..e6aef6bf51 100644
> --- a/timezone/tst-tzset.c
> +++ b/timezone/tst-tzset.c
> @@ -103,6 +103,13 @@ static void
> test_tz_file (off64_t size)
> {
> char *path = create_tz_file (size);
> + if (path == NULL)
> + {
> + printf ("creating timezone file of size: %lld MiB failed.\n",
> + size / (1024 * 1024));
> + exit (1);
> + }
> +
> if (setenv ("TZ", path, 1) < 0)
> {
> printf ("setenv failed: %m\n");
>
On x86_64:
tst-tzset.c: In function ‘test_tz_file’:
tst-tzset.c:108:50: error: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘off64_t’ {aka ‘long int’} [-Werror=format=]
108 | printf ("creating timezone file of size: %lld MiB failed.\n",
You need to use PRId64:
diff --git a/timezone/tst-tzset.c b/timezone/tst-tzset.c
index e6aef6bf51..3dad42e041 100644
--- a/timezone/tst-tzset.c
+++ b/timezone/tst-tzset.c
@@ -25,6 +25,7 @@
#include <time.h>
#include <unistd.h>
#include <support/check.h>
+#include <inttypes.h>
static int do_test (void);
#define TEST_FUNCTION do_test ()
@@ -105,7 +106,7 @@ test_tz_file (off64_t size)
char *path = create_tz_file (size);
if (path == NULL)
{
- printf ("creating timezone file of size: %lld MiB failed.\n",
+ printf ("creating timezone file of size: %" PRId64 "MiB failed.\n",
size / (1024 * 1024));
exit (1);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-29 12:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 21:23 [PATCH] tst-tzset: output reason when creating 4GiB file fails Stafford Horne
2021-10-29 12:14 ` Adhemerval Zanella
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).