Commit Graph

444 Commits

Author SHA1 Message Date
Frediano Ziglio
b92149f2b9 tests: Remove warning compiling
Remove:

    test-display-streaming.c: In function 'get_commands':
    test-display-streaming.c:218:42: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
      218 |     *commands = (Command*) calloc(sizeof(Command), *num_commands);
          |                                          ^~~~~~~
    test-display-streaming.c:218:42: note: earlier argument should specify number of elements, later size of each element

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2024-05-27 19:03:45 +01:00
Frediano Ziglio
fe1c25f530 test-listen: Use OpenSSL BIO instead of GIO library
test-listen using GIO had issues running under CI for a while.
GIO is reading some desktop configuration so it's not very CI
friendly.
So instead of using GIO use OpenSSL BIO. The code does not
get much bigger or complicated.
We are already using OpenSSL so we are not adding dependencies.

This fixes CI for Fedora 39 (just released and available on docker).

This allowed to remove an old workaround for GIO in .gitlab-ci.yml
(cfr commit 89edf80821
"ci: Workaround an issue with GLib on Fedora 30")

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-11-22 07:36:40 +00:00
Frediano Ziglio
fe4723d176 build: Remove support for GStreamer 0.10
Deprecated since 2016.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-09-17 10:00:41 +01:00
Frediano Ziglio
f60d61186f ci: Update makecheck-windows job to Meson
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-30 20:35:57 +01:00
Frediano Ziglio
6089c90a62 ci: Fix check-valgrind job
Avoid downgrading gstreamer1-plugins-good, no longer necessary.
Add suppression for pthread_create leak.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2023-05-10 10:56:42 +01:00
Frediano Ziglio
a225ebe921 test-leaks: Load DH parameters to test this part of code
Just loding the file is enough to test code in reds.cpp.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-08-03 19:03:08 +01:00
Frediano Ziglio
dd4c11ae98 ci: Exclude a system leak in Fedora 35
This leak causes a CI failure running test-listen test with
Valgrind.
Note that "check-valgrind" CI job will still fail but with
less issues.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2022-03-23 15:03:23 +00:00
Antonio Larrosa
46e3a57ccd Fix build with gstreamer 1.20.x
gstreamer-plugins-base 1.20 includes a new member in the
GstAppSinkCallbacks struct:

 gboolean      (*new_event)        (GstAppSink *appsink, gpointer user_data);

So it has to be initialized in order to build test-gst.cpp
successfully.

(added in
0a657d6db5
)

Acked-by: Frediano Ziglio <freddy77@gmail.com>
2022-03-23 13:39:52 +00:00
Simon Chopin
3d32295f9e test-leaks: fix the test with OpenSSL3
In OpenSSL3, the SSL_accept call now emits proper errors, which we dump
*before* emitting the expected "SSL_accept failed" error message. The
g_test_expect_message framework doesn't really allow us to discard
messages AFAICT, so instead we add a new expectation with fairly loose
criteria.

Fixes #63

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-11-11 09:23:51 +00:00
Rosen Penev
e2848118bf clang-tidy: use C++ casting
Found with google-readability-casting

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-09-28 09:36:49 +01:00
Rosen Penev
5513bce73e clang-tidy: replace C headers with C++
Found with modernize-deprecated-headers

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-08-26 07:35:09 +01:00
Frediano Ziglio
6eac8cc08f red-parse-qxl: Use a base reference class for RedSurfaceCmd
Don't code manually reference counting for this structure

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:07 +01:00
Frediano Ziglio
1d4fb2fee7 red-parse-qxl: Use a base reference class for RedCursorCmd
Don't code manually reference counting for this structure

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2021-08-04 13:01:05 +01:00
Frediano Ziglio
0b86b6808a tests: Fix -Wodr warning compiling tests with LTO enabled
Avoid the compiler to see 2 different defines of the same
structure.
Reported by Tomasz Kłoczko in
https://gitlab.freedesktop.org/spice/spice/-/issues/44

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-18 10:14:21 +01:00
Rosen Penev
9462537d24 clang-tidy: fix inconsistent declarations
Found with readability-inconsistent-declaration-parameter-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-09 11:19:30 +01:00
Rosen Penev
aefcd7d1c4 clang-tidy: use uppercase numeric literals
Found with readability-uppercase-literal-suffix

Avoids readability problems between lower case l and uppercase I.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-09 07:00:21 +01:00
Rosen Penev
9fb945c31b clang-tidy: replace typedef with using
Found with modernize-use-using

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-09 06:38:36 +01:00
Rosen Penev
0bc7e80ec6 clang-tidy: convert C casts to C++ ones
Found with google-readability-casting

https://google.github.io/styleguide/cppguide.html#Casting

Makes the operation clearer.

This commit uses const_cast where needed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-05-05 07:03:55 +01:00
Frediano Ziglio
62dd7e47e9 tests: Remove some compiler warnings
Remove warnings like:

In file included from /usr/include/glib-2.0/glib.h:86,
                 from ../server/tests/test-glib-compat.h:21,
                 from ../server/tests/test-channel.cpp:25:
In function 'void send_ack_sync(int, uint32_t)',
    inlined from 'void channel_loop()' at ../server/tests/test-channel.cpp:250:18:
../server/sys-socket.h:28:43: error: 'ssize_t write(int, const void*, size_t)' reading 10 bytes from a region of size 2 [-Werror=stringop-overread]
   28 | #define socket_write(sock, buf, len) write(sock, buf, len)
/usr/include/glib-2.0/glib/gtestutils.h:50:61: note: in definition of macro 'g_assert_cmpint'
   50 |                                              gint64 __n1 = (n1), __n2 = (n2); \
      |                                                             ^~
../server/tests/test-channel.cpp:132:21: note: in expansion of macro 'socket_write'
  132 |     g_assert_cmpint(socket_write(socket, &msg.type, 10), ==, 10);
      |                     ^~~~~~~~~~~~
../server/tests/test-channel.cpp: In function 'void channel_loop()':
../server/tests/test-channel.cpp:123:18: note: source object 'send_ack_sync(int, uint32_t)::<unnamed struct>::type' of size 2
  123 |         uint16_t type;
      |                  ^~~~
In file included from ../server/tests/test-channel.cpp:22:
/usr/include/unistd.h:367:16: note: in a call to function 'ssize_t write(int, const void*, size_t)' declared with attribute 'access (read_only, 2, 3)'
  367 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
      |                ^~~~~
cc1plus: all warnings being treated as errors

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-05-05 06:36:18 +01:00
Frediano Ziglio
e39412644c ci: Ignore a leak in glib threading pool
The leak is detected by Valgrind on Fedora 34as:

==19603== 400 bytes in 1 blocks are possibly lost in loss record 2,296 of 2,441
==19603==    at 0x4845464: calloc (vg_replace_malloc.c:1117)
==19603==    by 0x40135FB: _dl_allocate_tls (in /usr/lib64/ld-2.33.so)
==19603==    by 0x57EB008: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.33.so)
==19603==    by 0x53A1130: UnknownInlinedFun (gthread-posix.c:1323)
==19603==    by 0x53A1130: g_thread_new_internal (gthread.c:931)
==19603==    by 0x53C4953: g_thread_pool_start_thread.constprop.0 (gthreadpool.c:477)
==19603==    by 0x53A2902: g_thread_pool_push (gthreadpool.c:691)
==19603==    by 0x519AE11: g_task_run_in_thread_sync (gtask.c:1593)
==19603==    by 0x80D8A74: ??? (in /usr/lib64/gio/modules/libgiolibproxy.so)
==19603==    by 0x5181966: g_proxy_address_enumerator_next (gproxyaddressenumerator.c:176)
==19603==    by 0x519281A: g_socket_client_connect (gsocketclient.c:1098)

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-05-05 06:36:14 +01:00
Frediano Ziglio
7fe49b6465 Update glib.supp to new version
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-05-05 06:36:12 +01:00
Frediano Ziglio
9bd0d5cc81 Fix failure strings in tests
Otherwise tests will fail due to source code change.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-14 19:05:09 +04:00
Rosen Penev
8af176b15e clang-tidy: use nullptr
Found with modernize-use-nullptr

NULL in C++ is 0 whereas it is a void pointer in C. Avoids implicit
conversions.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-12 06:50:05 +01:00
Rosen Penev
944dc8662e clang-tidy: use auto
Found with modernize-use-auto

auto is shorter and can sometimes disambiguate pointer constness.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-11 07:44:42 +01:00
Rosen Penev
f64e61e44d clang-tidy: use override and remove virtual
Found with modernize-use-override

This can be useful as compilers can generate a compile time error when:
	The base class implementation function signature changes.
        The user has not created the override with the correct
	signature.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
2021-04-09 08:20:06 +01:00
Rosen Penev
11374b28b4 clang-tidy: remove pointless void
Found with modernize-redundant-void-arg

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-08 16:18:17 +01:00
Rosen Penev
9f1514b804 clang-tidy: use using
Found with modernize-use-using

Also manually removed a bunch of typedefs as they are no longer useful
in C++.

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rt-using

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-04-08 16:18:02 +01:00
Frediano Ziglio
9af2193f2c Fix non-trivial designated initializers for old Gnu C++ compilers
Fix this error reported by some older Gnu C++ compilers:

./server/tests/test-display-base.cpp:818:1: sorry, unimplemented: non-trivial designated initializers not supported

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2021-02-08 09:47:32 +00:00
Julien Ropé
d8c6ff25b6 ci: suppress new possible loss coming with Fedora 33
- remove entry for g-type-register-static: the "possible" flag has been
  re-introduced in glib.supp
- add new entries for several calloc issues

Signed-off-by: Julien Ropé <jrope@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-12-07 11:13:13 +00:00
Julien Ropé
5f06f847dd ci: update glib.supp file
Sync with Glib master file.

Signed-off-by: Julien Ropé <jrope@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-12-07 11:13:07 +00:00
Frediano Ziglio
65d7d24f21 test-gst: Handle better errors from callback
Exit more cleanly, otherwise sometimes some strange failures
occurs. This is due to the fact that a thread is cleaning up
everything while the others are still working.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-07-12 20:05:30 +01:00
Frediano Ziglio
1cd063d5fe test-gst: Returns specific error if encoder is not supported
This allows to detect missing required system packages.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2020-07-12 20:04:34 +01:00
Frediano Ziglio
b174e757fa Enable -Wshadow warning
This flag allows to catch variables or arguments hiding other
variables or attributes.
It helps avoiding some possible mistakes.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Julien Ropé <jrope@gmail.com>
2020-06-25 09:18:59 +01:00
Frediano Ziglio
0f2c28a63b test-display-base: Reuse SPICE_GNUC_NORETURN macro
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-19 13:34:55 +01:00
Uri Lublin
954eabaeb7 test-websocket: check setsockopt return value
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2020-06-17 12:48:25 +01:00
Frediano Ziglio
87270d3037 basic-event-loop: Remove useless "ring.h" include
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-06-10 16:52:32 +01:00
Frediano Ziglio
a21e66b7b3 test-dispatcher: Test dispatcher
Test that dispatcher work.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
2020-05-05 05:15:43 +01:00
Frediano Ziglio
46cda65123 build: Remove GObject dependency
Not used anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
f6f998004b Wrap spice.h in order to do some adjustment
Instead of including spice.h directly include an header that wraps
it. This allows to remove the SPICE_SERVER_INTERNAL define.
Currently is used to rename SpiceCharDeviceInstance to RedCharDevice
and reduce its visibility to hidden. This remove some warnings
and some weird code in the source.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
724f23e4bd Use red::shared_ptr_counted for RedChannelClient
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
597461e443 Add and use red::make_shared
Allow to create an object already contained in a shared pointer
to avoid having not owned objects.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
5126e38367 Use shared_ptr implementation to handle reference counting
This allows to make easier the management of owning.
Reference counting is automatically updated based on shared
pointers modification.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
cc86a7fb53 red-client: Automatically convert functions to methods
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
2bf72a5ce2 stream-channel: More incapsulation for StreamChannel
Put all functions into methods.
Separate public/private part.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
104aa6e1af Remove GObject from RedChannel
The patch seems pretty huge but mainly are mechanical steps:
- remove GObject declarations
- do not inherit from GObject
- add SPICE_CXX_GLIB_ALLOCATOR to avoid using C++ allocators
- CLASS_init and CLASS_constructor code goes into C++ constructor
- CLASS_dispose and CLASS_finalize code goes into C++ destructor
- g_object_new is replaced by new operator
- class members goes into virtual methods
- class parameters became argument to constructor
- use push-visibility.h and pop-visibility.h to limit visibility
- temporary use XXX_CAST for old GObject casts, they will
  be replaced
- g_object_get is replaced by accessors

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
435ea33540 Reduce C++ symbols visibility
This allows the compiler to do some more optimisations on the
produced binary.
To allows possible future portability include header/footer in
some helper header files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
669df4fb38 red-channel-client: Make send_item a virtual function
The items are send from RedChannelClient so move the callback
to a virtual function in RedChannelClient instead of RedChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
7720039ee0 red-channel-client: Move handle_message as a virtual function
The messages coming are from the client so it's a better place
to be in RedChannelClient instead of RedChannel.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
176970f3f1 red-channel-client: Remove GObject type
Make all RedChannelClient hierarchy a C++ class.
This allows to use virtual methods.
Added a normal contructor instead or properties and g_object_new.

As we remove GObject conversion macros I added a macro XXX_CAST
to create a function to replace the old macro.
They will be removed when more type safety is introduced.

There's a new SPICE_CXX_GLIB_ALLOCATOR macro in red-common.h.
This macro, added to a class define the class allocator allowing
to use, in this case, GLib for allocation. This to avoid C++ library
dependency and to initialize all structure to 0 (not all fields
are manually initialized, will be improved with more encapsulation).

Currently the methods are mainly public, access will be modified
when more encapsulation (all functions in method) are done.

Some classes are now defined in the header, C++ uses access to
limit accessibility but for efficiency and type safety/inline and
other features require types to be defined in the headers.

Some fields were moved from XxxPrivate structure to class, C++
has accessibility.

Many destructors are defined as protected to forbid the use of
stack, this as these objects uses internal reference counting
to have normal pointers. Maybe in the future pointers like
std::shared_ptr could be used instead.

Reference counting is now implemented very easily using atomic
operations.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00
Frediano Ziglio
38cd152952 automake: Link with C++ linker
If automake sees no C++ files in the source it assumes have to
use C linker settings not linking C++ library.
This was not a problem as code did not use C++ libraries but next
patch will use pure virtual function call.
It could be provided but as later we will use RTTI use C++ library.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2020-05-01 06:58:09 +01:00