Re: [PATCH 07/22] Since we use a namespace, simplify name of local classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> From: Christophe de Dinechin <dinechin@xxxxxxxxxx>
> 
> With namespaces, the fully qualified names of the classes are
> unambiguous e.g. spice::streaming_agent::Stream. So following the KISS
> principle, it makes the code simpler when class names are short.
> 
> Signed-off-by: Christophe de Dinechin <dinechin@xxxxxxxxxx>

Rebased at
https://cgit.freedesktop.org/~fziglio/spice-streaming-agent/commit/?h=style3&id=042589c6744bb0ebaa90e1422746477ca9ebcd90

> ---
>  src/spice-streaming-agent.cpp | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
> index 7b56458..5c36906 100644
> --- a/src/spice-streaming-agent.cpp
> +++ b/src/spice-streaming-agent.cpp
> @@ -44,19 +44,24 @@ static size_t write_all(int fd, const void *buf, const
> size_t len);
>  
>  static ConcreteAgent agent;
>  
> -struct SpiceStreamFormatMessage
> +namespace spice
> +{
> +namespace streaming_agent
> +{
> +

style, they should be

namespace spice {
namespace streaming_agent {

> +struct FormatMessage
>  {
>      StreamDevHeader hdr;
>      StreamMsgFormat msg;
>  };
>  
> -struct SpiceStreamDataMessage
> +struct DataMessage
>  {
>      StreamDevHeader hdr;
>      StreamMsgData msg;
>  };
>  
> -struct SpiceStreamCursorMessage
> +struct CursorMessage
>  {
>      StreamDevHeader hdr;
>      StreamMsgCursorSet msg;
> @@ -82,6 +87,9 @@ private:
>      int fd = -1;
>  };
>  
> +}} // namespace spice::streaming_agent
> +
> +

I would use one line separation.

>  static bool streaming_requested = false;
>  static bool quit_requested = false;
>  static bool log_binary = false;
> @@ -223,9 +231,9 @@ write_all(int fd, const void *buf, const size_t len)
>  
>  static int spice_stream_send_format(int streamfd, unsigned w, unsigned h,
>  uint8_t c)
>  {
> -    const size_t msgsize = sizeof(SpiceStreamFormatMessage);
> +    const size_t msgsize = sizeof(FormatMessage);
>      const size_t hdrsize  = sizeof(StreamDevHeader);
> -    SpiceStreamFormatMessage msg = {
> +    FormatMessage msg = {
>          .hdr = {
>              .protocol_version = STREAM_DEVICE_PROTOCOL,
>              .padding = 0,       // Workaround GCC "not implemented" bug
> @@ -250,8 +258,8 @@ static int spice_stream_send_format(int streamfd,
> unsigned w, unsigned h, uint8_
>  static int spice_stream_send_frame(int streamfd, const void *buf, const
>  unsigned size)
>  {
>      ssize_t n;
> -    const size_t msgsize = sizeof(SpiceStreamFormatMessage);
> -    SpiceStreamDataMessage msg = {
> +    const size_t msgsize = sizeof(FormatMessage);
> +    DataMessage msg = {
>          .hdr = {
>              .protocol_version = STREAM_DEVICE_PROTOCOL,
>              .padding = 0,       // Workaround GCC "not implemented" bug
> @@ -333,9 +341,7 @@ send_cursor(int streamfd, unsigned width, unsigned
> height, int hotspot_x, int ho
>          return;
>      }
>  
> -    size_t cursor_size =
> -        sizeof(StreamDevHeader) + sizeof(StreamMsgCursorSet) +
> -        width * height * sizeof(uint32_t);
> +    size_t cursor_size = sizeof(CursorMessage) + width * height *
> sizeof(uint32_t);
>      std::unique_ptr<uint8_t[]> msg(new uint8_t[cursor_size]);
>  
>      StreamDevHeader
>      &dev_hdr(*reinterpret_cast<StreamDevHeader*>(msg.get()));

Otherwise is fine.

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]