[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
error.c has an unnecessary dependency on "program_name"
From: |
Bruce Korb |
Subject: |
error.c has an unnecessary dependency on "program_name" |
Date: |
Sun, 07 Nov 2010 11:50:49 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100914 SUSE/3.0.8 Thunderbird/3.0.8 |
It is fairly easy to fix, just make the definition weak
and check for a NULL value before using it. OK to push?
index ed9dba0..65f2d9d 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -106,7 +106,7 @@ char *strerror_r ();
/* The calling program should define program_name and set it to the
name of the executing program. */
-extern char *program_name;
+char *program_name;
# if HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
@@ -300,10 +300,11 @@ error (int status, int errnum, const char *message, ...)
(*error_print_progname) ();
else
{
+ char const *p = program_name ? program_name : "unknown";
#if _LIBC
- __fxprintf (NULL, "%s: ", program_name);
+ __fxprintf (NULL, "%s: ", p);
#else
- fprintf (stderr, "%s: ", program_name);
+ fprintf (stderr, "%s: ", p);
#endif
}
@@ -359,10 +360,11 @@ error_at_line (int status, int errnum, const char
*file_name,
(*error_print_progname) ();
else
{
+ char const *p = program_name ? program_name : "unknown";
#if _LIBC
- __fxprintf (NULL, "%s:", program_name);
+ __fxprintf (NULL, "%s: ", p);
#else
- fprintf (stderr, "%s:", program_name);
+ fprintf (stderr, "%s: ", p);
#endif
}
- error.c has an unnecessary dependency on "program_name",
Bruce Korb <=
- Re: error.c has an unnecessary dependency on "program_name", Bruno Haible, 2010/11/07
- Re: libposix stuff, Bruce Korb, 2010/11/08
- Re: libposix stuff, Gary V. Vaughan, 2010/11/08
- Re: libposix stuff, Ralf Wildenhues, 2010/11/08
- Re: libposix stuff, Bruce Korb, 2010/11/08
- Re: libposix stuff, Eric Blake, 2010/11/08
- Re: libposix stuff, Bruce Korb, 2010/11/08