[Spice-devel] [PATCH] Fix two build errors for clang

Lukáš Hrázký lhrazky at redhat.com
Tue Jul 17 12:16:30 UTC 2018


On Tue, 2018-07-17 at 14:10 +0200, Christophe de Dinechin wrote:
> From: Christophe de Dinechin <dinechin at redhat.com>
> 
> Clang complains about:
> 1. [[noreturn]] used on implementation instead of header
> 2. errno used without <errno.h>
> 
> Details:
> 
> clang complains about [[noreturn]] not being on the first declaration.
> 
> cursor-updater.cpp:77:3: error: function declared '[[noreturn]]' after its first declaration
> [[noreturn]] void CursorUpdater::operator()()
>   ^
> ./cursor-updater.hpp:24:10: note: declaration missing '[[noreturn]]' attribute is here
>     void operator()();
>          ^
> 1 error generated.
> 
> Indeed, it makes no sense to mark a function as [[noreturn]] at a
> point which the call sites cannot see.
> 
> Also add missing <errno.h> before use of errno
> 
> frame-log.cpp:27:96: error: use of undeclared identifier 'errno'
>             throw Error(std::string("Failed to open log file '") + log_name + "': " + strerror(errno));

Sorry about the issues, I was a bit clueless about the attribute.

This should really be split into two patches though...

> Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
> ---
>  src/cursor-updater.cpp | 2 +-
>  src/cursor-updater.hpp | 2 +-
>  src/frame-log.cpp      | 1 +
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cursor-updater.cpp b/src/cursor-updater.cpp
> index 8f65e83..9f39c7b 100644
> --- a/src/cursor-updater.cpp
> +++ b/src/cursor-updater.cpp
> @@ -74,7 +74,7 @@ CursorUpdater::CursorUpdater(StreamPort *stream_port) : stream_port(stream_port)
>      XFixesSelectCursorInput(display, DefaultRootWindow(display), XFixesDisplayCursorNotifyMask);
>  }
>  
> -[[noreturn]] void CursorUpdater::operator()()
> +void CursorUpdater::operator()()
>  {
>      unsigned long last_serial = 0;
>  
> diff --git a/src/cursor-updater.hpp b/src/cursor-updater.hpp
> index d5f00af..6dbadac 100644
> --- a/src/cursor-updater.hpp
> +++ b/src/cursor-updater.hpp
> @@ -21,7 +21,7 @@ class CursorUpdater
>  public:
>      CursorUpdater(StreamPort *stream_port);
>  
> -    void operator()();
> +    [[noreturn]] void operator()();
>  
>  private:
>      StreamPort *stream_port;
> diff --git a/src/frame-log.cpp b/src/frame-log.cpp
> index 63a8ac0..cc993cd 100644
> --- a/src/frame-log.cpp
> +++ b/src/frame-log.cpp
> @@ -12,6 +12,7 @@
>  #include <chrono>
>  #include <cstdarg>
>  #include <string.h>
> +#include <errno.h>
>  
>  
>  namespace spice {


More information about the Spice-devel mailing list