diff --git a/base-linux/src/base/ipc/ipc.cc b/base-linux/src/base/ipc/ipc.cc index 3b8910e31..b21c78843 100644 --- a/base-linux/src/base/ipc/ipc.cc +++ b/base-linux/src/base/ipc/ipc.cc @@ -151,7 +151,7 @@ void Ipc_server::_prepare_next_reply_wait() _read_offset = sizeof(long); /* read client thread id from request buffer */ - long tid; + long tid = 0; if (_reply_needed) { _read_from_buf(tid); Ipc_ostream::_dst = Native_capability(tid, 0); /* only _tid member is used */ diff --git a/base/include/base/capability.h b/base/include/base/capability.h index a94b93036..6e2bed425 100644 --- a/base/include/base/capability.h +++ b/base/include/base/capability.h @@ -134,6 +134,27 @@ namespace Genode { */ Capability(void *ptr) : Untyped_capability(ptr) {} + /** + * Wrapper for the return type instantiated by 'call' overloads + * + * Each 'call' overload creates an instance of the return value + * type as local variable. A reference to this variable is passed + * to the '_call' function, which will assign its value. Even + * though the variable does not need to be initialized prior the + * call of '_call', the GCC will still complain "warning: ‘ret’ may + * be used uninitialized in this function". Wrapping the return + * value in a struct silences the compiler. + */ + template + struct Return + { + typedef typename Trait::Call_return::Type + Return_type; + + volatile Return_type _value; + Return_type &value() { return *(Return_type *)(&_value); } + }; + public: typedef RPC_INTERFACE Rpc_interface; @@ -178,24 +199,14 @@ namespace Genode { static RPC_INTERFACE* deref(Capability c) { return reinterpret_cast(c.local()); } - /* - * Suppress warning about uninitialized 'ret' variable in 'call' - * functions on compilers that support the #pragma. If this is - * not the case, the pragma can be masked by supplying the - * 'SUPPRESS_GCC_PRAGMA_WUNINITIALIZED' define to the compiler. - */ - #ifndef SUPPRESS_GCC_PRAGMA_WUNINITIALIZED - #pragma GCC diagnostic ignored "-Wuninitialized" call(); - #endif - template typename Trait::Call_return::Type call() const { Meta::Empty e; - typename Trait::Call_return::Type ret; - _call(e, ret); - return ret; + Return ret; + _call(e, ret.value()); + return ret.value(); } template @@ -204,9 +215,9 @@ namespace Genode { { Meta::Empty e; typename IF::Client_args args(v1, e); - typename Trait::Call_return::Type ret; - _call(args, ret); - return ret; + Return ret; + _call(args, ret.value()); + return ret.value(); } template @@ -215,9 +226,9 @@ namespace Genode { { Meta::Empty e; typename IF::Client_args args(v1, v2, e); - typename Trait::Call_return::Type ret; - _call(args, ret); - return ret; + Return ret; + _call(args, ret.value()); + return ret.value(); } template @@ -227,9 +238,9 @@ namespace Genode { { Meta::Empty e; typename IF::Client_args args(v1, v2, v3, e); - typename Trait::Call_return::Type ret; - _call(args, ret); - return ret; + Return ret; + _call(args, ret.value()); + return ret.value(); } template @@ -239,9 +250,9 @@ namespace Genode { { Meta::Empty e; typename IF::Client_args args(v1, v2, v3, v4, e); - typename Trait::Call_return::Type ret; - _call(args, ret); - return ret; + Return ret; + _call(args, ret.value()); + return ret.value(); } template @@ -252,9 +263,9 @@ namespace Genode { { Meta::Empty e; typename IF::Client_args args(v1, v2, v3, v4, v5, e); - typename Trait::Call_return::Type ret; - _call(args, ret); - return ret; + Return ret; + _call(args, ret.value()); + return ret.value(); } template @@ -265,9 +276,9 @@ namespace Genode { { Meta::Empty e; typename IF::Client_args args(v1, v2, v3, v4, v5, v6, e); - typename Trait::Call_return::Type ret; - _call(args, ret); - return ret; + Return ret; + _call(args, ret.value()); + return ret.value(); } template @@ -279,9 +290,9 @@ namespace Genode { { Meta::Empty e; typename IF::Client_args args(v1, v2, v3, v4, v5, v6, v7, e); - typename Trait::Call_return::Type ret; - _call(args, ret); - return ret; + Return ret; + _call(args, ret.value()); + return ret.value(); } }; diff --git a/demo/src/server/liquid_framebuffer/target.mk b/demo/src/server/liquid_framebuffer/target.mk index e31904642..567871102 100644 --- a/demo/src/server/liquid_framebuffer/target.mk +++ b/demo/src/server/liquid_framebuffer/target.mk @@ -4,6 +4,3 @@ SRC_CC = main.cc services.cc INC_DIR += $(REP_DIR)/src/app/scout/include \ $(REP_DIR)/src/app/scout/include/genode \ $(REP_DIR)/src/server/framebuffer/sdl - -# suppress non-critical but weird compiler warning, probably a bug in gcc-4.6.1 -CC_OPT_main += -Wno-uninitialized diff --git a/libports/src/test/python/target.mk b/libports/src/test/python/target.mk index 77ebb055e..75607edd4 100644 --- a/libports/src/test/python/target.mk +++ b/libports/src/test/python/target.mk @@ -2,5 +2,3 @@ TARGET = test-python LIBS = cxx env python libc libc_log libm REQUIRES = x86 SRC_CC = main.cc - -CC_OPT_main = -Wno-uninitialized diff --git a/os/src/app/chroot/target.mk b/os/src/app/chroot/target.mk index 34f42cc7f..5a49c45b4 100644 --- a/os/src/app/chroot/target.mk +++ b/os/src/app/chroot/target.mk @@ -2,18 +2,3 @@ TARGET = chroot REQUIRES = linux SRC_CC = main.cc LIBS = cxx env server lx_hybrid - -# -# XXX find a way to remove superfluous warning: -# -# base/include/util/token.h: In constructor ‘Genode::Config::Config()’: -# base/include/util/token.h:69:67: warning: ‘ret’ may be used uninitialized in -# this function [-Wuninitialized] -# base/include/base/capability.h:196:62: note: ‘ret’ was declared here -# base/include/util/token.h:100:68: warning: ‘prephitmp.1897’ may be used -# uninitialized in this function -# [-Wuninitialized] -# os/include/os/config.h:42:4: note: ‘prephitmp.1897’ was declared here -# -CC_WARN = -Wall -Wno-uninitialized -