[PATCH 5/5] Add dummy return 0 to Xnest & Xephyr io error handler for Sun compilers

Alan Coopersmith alan.coopersmith at oracle.com
Fri Dec 2 15:08:49 PST 2011


On 12/02/11 14:03, Mikhail Gusarov wrote:
>
> Twas brillig at 10:48:16 02.12.2011 UTC-08 when alan.coopersmith at oracle.com did gyre and gimble:
>
>   AC>  Required in order to build with Studio cc now that xorg-macros is
>   AC>  setting -errwarn=E_FUNC_HAS_NO_RETURN_STMT since it doesn't
>   AC>  recognize that the noreturn attribute makes it pointless.
>
> Is there any way to tell this compiler that exit(3) does not return?

I had assumed that wouldn't help, because the system headers already have the
noreturn attribute on the exit() prototype, but on digging deeper, a bug in
them causes that to only be applied when building with gcc, not Studio cc.

Adding the equivalent Studio pragma silences the warning without adding any
unreachable code to the function, so a revised patch follows.

	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System

 From dadabd4ee5ead35be75011c904102d1296bfcbf8 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersmith at oracle.com>
Date: Fri, 2 Dec 2011 00:09:07 -0800
Subject: [PATCH] Fix builds of Xnest & Xephyr with Solaris Studio compilers

Required in order to build with Studio cc now that xorg-macros is
setting -errwarn=E_FUNC_HAS_NO_RETURN_STMT since a bug in the Solaris
system headers causes the noreturn attribute to not be correctly
applied when building with Studio instead of gcc.

Otherwise compiler exits with errors:
"Display.c", line 65: Function has no return statement : x_io_error_handler
"hostx.c", line 341: Function has no return statement : x_io_error_handler

Uses Studio-specific pragma to avoid causing gcc to warn about having
a redundant prototype for the exit() function.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
  hw/kdrive/ephyr/hostx.c |    4 ++++
  hw/xnest/Display.c      |    4 ++++
  2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 47a6681..291d939 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -332,6 +332,10 @@ hostx_set_title (char *title)
    ephyrTitle = title;
  }

+#ifdef __SUNPRO_C
+#pragma does_not_return(exit)
+#endif
+
  static int _X_NORETURN
  x_io_error_handler (Display *dpy) {
      ErrorF("Lost connection to X server: %s\n", strerror(errno));
diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c
index 7acad75..c2783cf 100644
--- a/hw/xnest/Display.c
+++ b/hw/xnest/Display.c
@@ -55,6 +55,10 @@ Pixmap xnestScreenSaverPixmap;
  XlibGC xnestBitmapGC;
  unsigned long xnestEventMask;

+#ifdef __SUNPRO_C
+#pragma does_not_return(exit)
+#endif
+
  static int _X_NORETURN
  x_io_error_handler (Display *dpy) {
      ErrorF("Lost connection to X server: %s\n", strerror(errno));
-- 
1.7.3.2



More information about the xorg-devel mailing list