OSDN Git Service

2008-11-19 Craig Howland <howland@LGSInnovations.com>
authorjjohnstn <jjohnstn>
Wed, 19 Nov 2008 20:04:09 +0000 (20:04 +0000)
committerjjohnstn <jjohnstn>
Wed, 19 Nov 2008 20:04:09 +0000 (20:04 +0000)
        * libc/unix/collate.c (__collate_err): simplify to remove unnecessary
        strdup() and strlen() calls, also getting rid of a compiler warning.

newlib/ChangeLog
newlib/libc/posix/collate.c

index f253b1c..f8b1ccc 100644 (file)
@@ -1,3 +1,8 @@
+2008-11-19  Craig Howland  <howland@LGSInnovations.com>
+
+       * libc/unix/collate.c (__collate_err): simplify to remove unnecessary
+       strdup() and strlen() calls, also getting rid of a compiler warning.
+
 2008-11-19  Ralf Corsepius <ralf.corsepius@rtems.org>
 
        * libc/include/sys/config.h: Don't put 
index 4e717bc..8af8970 100644 (file)
@@ -175,14 +175,12 @@ __collate_strdup(s)
 void
 __collate_err(int ex, const char *f)
 {
-       const char *s = strdup("collate_error");
+       const char *s;
        int serrno = errno;
 
-       write(STDERR_FILENO, s, strlen(s));
-       write(STDERR_FILENO, ": ", 2);
-       free(s);
-       s = f;
-       write(STDERR_FILENO, s, strlen(s));
+       /* Be careful to change write counts if you change the strings */
+       write(STDERR_FILENO, "collate_error: ", 15);
+       write(STDERR_FILENO, f, strlen(f));
        write(STDERR_FILENO, ": ", 2);
        s = strerror(serrno);
        write(STDERR_FILENO, s, strlen(s));