[Spice-devel] [PATCH v2 21/24] Reformat 'if' statments according to style guide
Christophe de Dinechin
christophe.de.dinechin at gmail.com
Thu Feb 22 08:31:17 UTC 2018
> On 22 Feb 2018, at 09:27, Frediano Ziglio <fziglio at redhat.com> wrote:
>
>>
>> From: Christophe de Dinechin <dinechin at redhat.com>
>>
>> Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
>> ---
>> src/spice-streaming-agent.cpp | 27 +++++++++++++++++----------
>> 1 file changed, 17 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
>> index 61a73ce..4aae2cb 100644
>> --- a/src/spice-streaming-agent.cpp
>> +++ b/src/spice-streaming-agent.cpp
>> @@ -46,6 +46,8 @@ namespace spice
>> namespace streaming_agent
>> {
>>
>> +static bool quit_requested = false;
>> +
>> /* returns current time in micro-seconds */
>> static uint64_t get_time(void)
>> {
>
> Spurious.
Just trying to move all the file / non-class stuff together, since the intent is to move classes in their own files as one last patch in the series. (which I will only do once the series as a while is accepted).
>
>> @@ -73,8 +75,9 @@ public:
>> : codecs()
>> {
>> streamfd = open(name, O_RDWR);
>> - if (streamfd < 0)
>> + if (streamfd < 0) {
>> throw std::runtime_error("failed to open streaming device");
>> + }
>> }
>> ~Stream()
>> {
>> @@ -250,8 +253,9 @@ FrameLog::FrameLog(const char *filename, bool binary)
>>
>> FrameLog::~FrameLog()
>> {
>> - if (log)
>> + if (log) {
>> fclose(log);
>> + }
>> }
>>
>> void FrameLog::dump(const void *buffer, size_t length)
>> @@ -308,30 +312,32 @@ void X11CursorThread::cursor_changes()
>> Window rootwindow = DefaultRootWindow(display);
>> XFixesSelectCursorInput(display, rootwindow,
>> XFixesDisplayCursorNotifyMask);
>>
>> - while (true) {
>> + while (!quit_requested) {
>> XEvent event;
>> XNextEvent(display, &event);
>> - if (event.type != event_base + 1)
>> + if (event.type != event_base + 1) {
>> continue;
>> + }
>>
>> XFixesCursorImage *cursor = XFixesGetCursorImage(display);
>> - if (!cursor)
>> + if (!cursor) {
>> continue;
>> + }
>>
>> - if (cursor->cursor_serial == last_serial)
>> + if (cursor->cursor_serial == last_serial) {
>> continue;
>> + }
>>
>> last_serial = cursor->cursor_serial;
>> - if (!stream.send<X11CursorMessage>(cursor))
>> + if (!stream.send<X11CursorMessage>(cursor)) {
>> syslog(LOG_WARNING, "FAILED to send cursor\n");
>> + }
>> }
>> }
>>
>> }} // namespace spice::streaming_agent
>>
>>
>> -static bool quit_requested = false;
>> -
>> int Stream::have_something_to_read(int timeout)
>> {
>> struct pollfd pollfd = {streamfd, POLLIN, 0};
>> @@ -516,8 +522,9 @@ void ConcreteAgent::CaptureLoop(Stream &stream, FrameLog
>> &frame_log)
>> uint64_t time_last = 0;
>>
>> std::unique_ptr<FrameCapture>
>> capture(GetBestFrameCapture(stream.client_codecs()));
>> - if (!capture)
>> + if (!capture) {
>> throw std::runtime_error("cannot find a suitable capture
>> system");
>> + }
>>
>> while (!quit_requested && stream.streaming_requested()) {
>> if (++frame_count % 100 == 0) {
>
> Lot of these hunks should be moved in the proper patches in
> this series introducing the problem.
Yes. But since in the end, I cleaned up stuff that was not introduced by me as well, I thought it was cleaner to have a single pass that fixed all the ifs, rather than making the code temporarily inconsistent.
>
> Frediano
More information about the Spice-devel
mailing list