[PATCH] os: Remove Error()

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 11 16:59:32 PDT 2011


On Mon, Oct 10, 2011 at 08:54:54PM -0700, Jeremy Huddleston wrote:
> 
> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
  Peter

> ---
>  doc/Xserver-spec.xml |   10 +---------
>  include/os.h         |    1 -
>  os/backtrace.c       |    5 +++--
>  os/log.c             |   14 --------------
>  os/xprintf.c         |    5 +++--
>  5 files changed, 7 insertions(+), 28 deletions(-)
> 
> diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml
> index 37fd2b2..2bf4fb3 100644
> --- a/doc/Xserver-spec.xml
> +++ b/doc/Xserver-spec.xml
> @@ -1324,10 +1324,6 @@ This re-enables X request processing for the specified client.
>  
>  	void
>  	FatalError(char *f, ...)
> -
> -	void
> -	Error(str)
> -	    char *str;
>  </programlisting></blockquote>
>  You should write these three routines to provide for diagnostic output
>  from the dix and ddx layers, although implementing them to produce no
> @@ -1335,11 +1331,7 @@ output will not affect the correctness of your server.  ErrorF() and
>  FatalError() take a printf() type of format specification in the first
>  argument and an implementation-dependent number of arguments following
>  that.  Normally, the formats passed to ErrorF() and FatalError()
> -should be terminated with a newline.  Error() provides an os interface
> -for printing out the string passed as an argument followed by a
> -meaningful explanation of the last system error.  Normally the string
> -does not contain a newline, and it is only called by the ddx layer.
> -In the sample implementation, Error() uses the perror() function.
> +should be terminated with a newline.
>  </para>
>  <para>
>  After printing the message arguments, FatalError() must be implemented
> diff --git a/include/os.h b/include/os.h
> index 5401ea4..b489211 100644
> --- a/include/os.h
> +++ b/include/os.h
> @@ -551,7 +551,6 @@ extern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X
>  
>  extern _X_EXPORT void VErrorF(const char *f, va_list args) _X_ATTRIBUTE_PRINTF(1,0);
>  extern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
> -extern _X_EXPORT void Error(const char *str);
>  extern _X_EXPORT void LogPrintMarkers(void);
>  
>  extern _X_EXPORT void xorg_backtrace(void);
> diff --git a/os/backtrace.c b/os/backtrace.c
> index 7ca6dab..58b4b1f 100644
> --- a/os/backtrace.c
> +++ b/os/backtrace.c
> @@ -27,6 +27,8 @@
>  
>  #include "os.h"
>  #include "misc.h"
> +#include <errno.h>
> +#include <string.h>
>  
>  #ifdef HAVE_BACKTRACE
>  #ifndef _GNU_SOURCE
> @@ -199,9 +201,8 @@ void xorg_backtrace(void) {
>  	    walkcontext(&u, xorg_backtrace_frame, &depth);
>  	else
>  #  endif
> -	    Error("Failed to get backtrace info");
> +	    ErrorF("Failed to get backtrace info: %s\n", strerror(errno));
>      }
> -    ErrorF("\n");	
>  }
>  
>  # else
> diff --git a/os/log.c b/os/log.c
> index 0aa4429..9ee32c9 100644
> --- a/os/log.c
> +++ b/os/log.c
> @@ -87,7 +87,6 @@ OR PERFORMANCE OF THIS SOFTWARE.
>  #include <sys/stat.h>
>  #include <stdarg.h>
>  #include <stdlib.h>	/* for malloc() */
> -#include <errno.h>
>  
>  #include "input.h"
>  #include "site.h"
> @@ -638,19 +637,6 @@ ErrorF(const char * f, ...)
>      va_end(args);
>  }
>  
> -/* A perror() workalike. */
> -
> -void
> -Error(const char *str)
> -{
> -    const char *err = strerror(errno);
> -
> -    if (str)
> -	LogWrite(-1, "%s: %s\n", str, err);
> -    else
> -	LogWrite(-1, "%s\n", err);
> -}
> -
>  void
>  LogPrintMarkers(void)
>  {
> diff --git a/os/xprintf.c b/os/xprintf.c
> index 254b737..3b4bb41 100644
> --- a/os/xprintf.c
> +++ b/os/xprintf.c
> @@ -64,6 +64,8 @@
>  #include "os.h"
>  #include <stdarg.h>
>  #include <stdio.h>
> +#include <errno.h>
> +#include <string.h>
>  
>  #ifdef asprintf
>  # undef asprintf
> @@ -154,8 +156,7 @@ XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
>  {
>      int size = vasprintf(ret, format, va);
>      if ((size == -1) || (*ret == NULL)) {
> -	Error("XNFvasprintf");
> -	FatalError("XNFvasprintf failed");
> +	FatalError("XNFvasprintf failed: %s", strerror(errno));
>      }
>      return size;
>  }
> -- 
> 1.7.5.4



More information about the xorg-devel mailing list