summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-02-08 10:05:09 +0000
committerJakub Jelinek <jakub@redhat.com>2005-02-08 10:05:09 +0000
commitd585b66fa4d11059948f466c9080a6826932358d (patch)
tree8b06692920852c297635b46a7d616c3066f95fac /stdlib
parente7cbcee4982d8caa809a91c9cfef5fda67445f0a (diff)
Updated to fedora-glibc-20050208T0948cvs/fedora-glibc-2_3_4-6
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/Makefile1
-rw-r--r--stdlib/fmtmsg.c25
-rw-r--r--stdlib/stdlib.h2
-rw-r--r--stdlib/tst-fmtmsg.c32
4 files changed, 35 insertions, 25 deletions
diff --git a/stdlib/Makefile b/stdlib/Makefile
index b766fb8656..a0c0e71704 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -92,6 +92,7 @@ CFLAGS-bsearch.c = $(uses-callbacks)
CFLAGS-msort.c = $(uses-callbacks)
CFLAGS-qsort.c = $(uses-callbacks)
CFLAGS-system.c = -fexceptions
+CFLAGS-system.os = -fomit-frame-pointer
CFLAGS-fmtmsg.c = -fexceptions
ifneq (,$(filter %REENTRANT, $(defines)))
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 2ab97b7d90..b5d7436956 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1999,2000-2003,2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -316,7 +316,7 @@ internal_addseverity (int severity, const char *string)
int result = MM_OK;
/* First see if there is already a record for the severity level. */
- for (runp = severity_list, lastp = NULL; runp != NULL; runp = runp-> next)
+ for (runp = severity_list, lastp = NULL; runp != NULL; runp = runp->next)
if (runp->severity == severity)
break;
else
@@ -324,9 +324,6 @@ internal_addseverity (int severity, const char *string)
if (runp != NULL)
{
- /* Release old string. */
- free ((char *) runp->string);
-
if (string != NULL)
/* Change the string. */
runp->string = string;
@@ -367,34 +364,17 @@ int
addseverity (int severity, const char *string)
{
int result;
- const char *new_string;
/* Prevent illegal SEVERITY values. */
if (severity <= MM_INFO)
return MM_NOTOK;
- if (string == NULL)
- /* We want to remove the severity class. */
- new_string = NULL;
- else
- {
- new_string = __strdup (string);
-
- if (new_string == NULL)
- /* Allocation failed or illegal value. */
- return MM_NOTOK;
- }
-
/* Protect the global data. */
__libc_lock_lock (lock);
/* Do the real work. */
result = internal_addseverity (severity, string);
- if (result != MM_OK)
- /* Free the allocated string. */
- free ((char *) new_string);
-
/* Release the lock. */
__libc_lock_unlock (lock);
@@ -411,7 +391,6 @@ libc_freeres_fn (free_mem)
{
/* This is data we have to release. */
struct severity_info *here = runp;
- free ((char *) runp->string);
runp = runp->next;
free (here);
}
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index e1d60d7619..4a1571e7db 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -596,7 +596,7 @@ __BEGIN_NAMESPACE_STD
/* Re-allocate the previously allocated block
in PTR, making the new block SIZE bytes long. */
extern void *realloc (void *__ptr, size_t __size)
- __THROW __attribute_malloc__ __wur;
+ __THROW __attribute_malloc__ __attribute_warn_unused_result__;
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
extern void free (void *__ptr) __THROW;
__END_NAMESPACE_STD
diff --git a/stdlib/tst-fmtmsg.c b/stdlib/tst-fmtmsg.c
index d5369bda62..c3748d64d5 100644
--- a/stdlib/tst-fmtmsg.c
+++ b/stdlib/tst-fmtmsg.c
@@ -1,6 +1,8 @@
#include <fmtmsg.h>
#include <mcheck.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#define MM_TEST 10
@@ -12,11 +14,13 @@ main (void)
mtrace ();
- if (addseverity (MM_TEST, "TEST") != MM_OK)
+ char TEST[] = "ABCD";
+ if (addseverity (MM_TEST, TEST) != MM_OK)
{
puts ("addseverity failed");
result = 1;
}
+ strcpy (TEST, "TEST");
if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_HALT, "halt",
"should print message for MM_HALT", "GLIBC:tst-fmtmsg:1")
@@ -48,5 +52,31 @@ main (void)
!= MM_OK)
result = 1;
+ if (addseverity (MM_TEST, NULL) != MM_OK)
+ {
+ puts ("second addseverity failed");
+ result = 1;
+ }
+
+ if (addseverity (MM_TEST, NULL) != MM_NOTOK)
+ {
+ puts ("third addseverity unexpectedly succeeded");
+ result = 1;
+ }
+
+ char *p = strdup ("TEST2");
+ if (addseverity (MM_TEST, p) != MM_OK)
+ {
+ puts ("fourth addseverity failed");
+ result = 1;
+ }
+ if (addseverity (MM_TEST, "TEST3") != MM_OK)
+ {
+ puts ("fifth addseverity failed");
+ result = 1;
+ }
+
+ free (p);
+
return result;
}