aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-01-26 00:01:20 +0000
committerUlrich Drepper <drepper@redhat.com>2005-01-26 00:01:20 +0000
commit792dcd77cdafb46c746119e250a5ba9d20598f8f (patch)
treebb604fb38044db5ee084d94996775399ac3de2ab /stdlib
parent1f25bddd621e1cad0d655ea9cedf3a718d6fdabb (diff)
downloadglibc-792dcd77cdafb46c746119e250a5ba9d20598f8f.zip
glibc-792dcd77cdafb46c746119e250a5ba9d20598f8f.tar.gz
glibc-792dcd77cdafb46c746119e250a5ba9d20598f8f.tar.bz2
Update.
2005-01-25 Jakub Jelinek <jakub@redhat.com> * stdlib/fmtmsg.c (addseverity): Remove new_string variable. (free_mem): Don't free string. * stdlib/tst-fmtmsg.c: Include string.h. (main): Add some more tests. 2005-01-25 Andreas Schwab <schwab@suse.de> * timezone/asia: Update from tzdata2005c. * timezone/backward: Likewise. * timezone/leapseconds: Likewise. * timezone/northamerica: Likewise. * timezone/southamerica: Likewise. * timezone/private.h: Update from tzcode2005c. * timezone/tzfile.h: Likewise. * timezone/zdump.c: Likewise. * timezone/zic.c: Likewise.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/fmtmsg.c20
-rw-r--r--stdlib/tst-fmtmsg.c25
2 files changed, 25 insertions, 20 deletions
diff --git a/stdlib/fmtmsg.c b/stdlib/fmtmsg.c
index 9e654c6..b5d7436 100644
--- a/stdlib/fmtmsg.c
+++ b/stdlib/fmtmsg.c
@@ -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
@@ -364,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);
@@ -408,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/tst-fmtmsg.c b/stdlib/tst-fmtmsg.c
index 0b244e2..0554789 100644
--- a/stdlib/tst-fmtmsg.c
+++ b/stdlib/tst-fmtmsg.c
@@ -1,6 +1,7 @@
#include <fmtmsg.h>
#include <mcheck.h>
#include <stdio.h>
+#include <string.h>
#define MM_TEST 10
@@ -12,11 +13,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")
@@ -54,5 +57,25 @@ main (void)
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;
}