Skip to content
Snippets Groups Projects
  1. May 14, 2020
  2. May 11, 2020
  3. Mar 26, 2020
  4. Mar 10, 2020
  5. Mar 09, 2020
    • Victor Toso's avatar
      ci: Use meson instead of autotools in spice-protocol · 3b4b4d02
      Victor Toso authored
      
      It was dropped in git master.
      
      Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
      3b4b4d02
    • Aral Balkan's avatar
    • Jakub Janků's avatar
      udscs-server: split initialization · e6c14d0e
      Jakub Janků authored
      
      Divide creation of udscs_server into 2 steps:
      
      1) udscs_server_new()
       - allocates new udscs_server struct and inits it
      
      2) udscs_server_listen_to_fd(), udscs_server_listen_to_address()
       - starts accepting new connections
      
      Remove udscs_create_server() and udscs_create_server_for_fd().
      
      This makes the code a bit shorter and nicer.
      
      Signed-off-by: default avatarJakub Janků <jjanku@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      e6c14d0e
    • Jakub Janků's avatar
      virtio: use GObject macro · ab7901ce
      Jakub Janků authored
      
      Use G_DECLARE_FINAL_TYPE().
      
      Rename
      struct vdagent_virtio_port --> VirtioPort
      
      Signed-off-by: default avatarJakub Janků <jjanku@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      ab7901ce
    • Jakub Janků's avatar
      udscs: use GObject macro · 15f710da
      Jakub Janků authored
      
      Use G_DECLARE_FINAL_TYPE().
      
      Rename
      struct udscs_connection --> UdscsConnection
      
      Signed-off-by: default avatarJakub Janků <jjanku@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      15f710da
    • Jakub Janků's avatar
      introduce VDAgentConnection · 3257a1f7
      Jakub Janků authored
      
      1) VDAgentConnection
      
      Add vdagent-connection.{c,h} files,
      define a new derivable class VDAgentConnection.
      
      VDAgentConnection uses GIO and therefore integrates well with GMainLoop.
      
      Read messages must begin with a header of a fixed size.
      Message body size can vary.
      
      Note:
      vdagent_connection_destroy() cancels ongoing I/O-ops
      and closes the underlying FD.
      However, the I/O-ops do not finish immediately,
      but asynchronously in the next iteration of the main loop.
      At the beginning of each op, VDAgentConnection is referenced,
      so the object isn't finalized until the ops themselves finish.
      To solve this, call g_main_context_iteration() before the agent exits.
      
      2) udscs
      
      Make udscs_connection a subclass of VDAgentConnection.
      
      Rewrite udscs_server using GSocketService.
      Use GList to store server's connections.
      
      Drop support for select(), remove:
       * udscs_server_fill_fds()
       * udscs_server_handle_fds()
      
      Remove udscs_{set,get}_user_data(). Custom data can be
      associated with the GObject using g_object_set_data().
      
      3) virtio_port
      
      Make vdagent_virtio_port a subclass of VDAgentConnection.
      
      Drop support for select(), remove:
       * vdagent_virtio_port_fill_fds()
       * vdagent_virtio_port_handle_fds()
      
      4) vdagentd
      
      Replace the main_loop() with a GMainLoop.
      
      Use g_unix_signal_add() to handle SIGINT, SIGHUP, SIGTERM.
      SIGQUIT handling is not supported by GLib.
      
      Integrate the session_info into the loop using
      GIOChannel and g_io_add_watch().
      
      Signed-off-by: default avatarJakub Janků <jjanku@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      3257a1f7
    • Jakub Janků's avatar
      build: add GIO dependency · 5c136cb3
      Jakub Janků authored
      
      Require UNIX-specific GIO package to build spice-vdagent.
      
      This package includes:
      
      - GDBus which is going to be used instead of libdbus in
        console-kit.c and systemd-login.c
      
      - I/O stream classes and networking APIs that are going to
        be used in VDAgentConnection
      
      Version 2.44 is required because of the following definitions:
      - g_input_stream_read_all_*
      - g_output_stream_write_all_*
      - GSimpleIOStream
      
      GIO requires GLib and GObject, so we can depend solely on it.
      
      GLib version across different distributions:
          Fedora 30:    2.60
          Fedora 29:    2.58
          Fedora 28:    2.56
      
          RHEL 7.6:     2.56
          RHEL 7.5:     2.54
          RHEL 7.4:     2.50
      
          Debian 10:    2.58
          Debian 9:     2.50
          Debian 8:     2.42
      
          Ubuntu 19.04: 2.60
          Ubuntu 18.04: 2.56
          Ubuntu 16.04: 2.48
      
      Signed-off-by: default avatarJakub Janků <jjanku@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      5c136cb3
  6. Mar 06, 2020
  7. Oct 17, 2019
    • Benjamin Berg's avatar
      vdagentd: Fix session lookup for new GNOME versions · b67ff71f
      Benjamin Berg authored
      
      New GNOME versions have started to manage the session using the systemd
      user instance. The effect of this is that the spice-vdagent running in
      the user session is forked off (indirectly) from the systemd user
      instance and does technically not belong to any session.
      
      The correct way of handling this situation is to simply assume that the
      process belongs to the users graphical session. Add a heuristic to find
      the graphical session based on the UID, fixing spice-vdagent running on
      GNOME 3.34 with systemd integration.
      
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      b67ff71f
  8. Aug 31, 2019
  9. Aug 28, 2019
  10. Aug 27, 2019
    • Victor Toso's avatar
      covscan: initialize argv's copy · cedab5fe
      Victor Toso authored
      
      Otherwise we get a CLANG_WARNING due accessing garbage.
      
      Covscan report:
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:471:9: warning: 1st function call argument is an uninitialized value
       > #        execvp(orig_argv[0], orig_argv);
       > #        ^      ~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:421:24: note: Storing uninitialized value
       > #    char **orig_argv = g_memdup(argv, sizeof(char*) * (argc+1));
       > #                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:434:9: note: Assuming 'error' is equal to NULL
       > #    if (error != NULL) {
       > #        ^~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:434:5: note: Taking false branch
       > #    if (error != NULL) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:442:9: note: Assuming 'portdev' is not equal to NULL
       > #    if (portdev == NULL)
       > #        ^~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:442:5: note: Taking false branch
       > #    if (portdev == NULL)
       > #    ^
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:445:9: note: Assuming 'vdagentd_socket' is not equal to NULL
       > #    if (vdagentd_socket == NULL)
       > #        ^~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:445:5: note: Taking false branch
       > #    if (vdagentd_socket == NULL)
       > #    ^
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:448:30: note: Assuming 'do_daemonize' is 0
       > #    openlog("spice-vdagent", do_daemonize ? LOG_PID : (LOG_PID | LOG_PERROR),
       > #                             ^~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:448:30: note: '?' condition is false
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:451:9: note: Assuming the condition is false
       > #    if (!g_file_test(portdev, G_FILE_TEST_EXISTS)) {
       > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:451:5: note: Taking false branch
       > #    if (!g_file_test(portdev, G_FILE_TEST_EXISTS)) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:457:9: note: Assuming 'do_daemonize' is 0
       > #    if (do_daemonize)
       > #        ^~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:457:5: note: Taking false branch
       > #    if (do_daemonize)
       > #    ^
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:468:9: note: Assuming 'version_mismatch' is not equal to 0
       > #    if (version_mismatch) {
       > #        ^~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:468:5: note: Taking true branch
       > #    if (version_mismatch) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagent/vdagent.c:471:9: note: 1st function call argument is an uninitialized value
       > #        execvp(orig_argv[0], orig_argv);
       > #        ^      ~~~~~~~~~~~~
       > #  469|           syslog(LOG_INFO, "Version mismatch, restarting");
       > #  470|           sleep(1);
       > #  471|->         execvp(orig_argv[0], orig_argv);
       > #  472|       }
       > #  473|
      
      Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
      Acked-by: default avatarUri Lublin <uril@redhat.com>
      cedab5fe
    • Victor Toso's avatar
      covscan: avoid false positive on g_clear_pointer() · 83d2dbba
      Victor Toso authored
      
      This is a CLANG_WARNING found by covscan. It is a false positive as
      g_clear_pointer() does set vportp to NULL, meaning that the situation
      described by covscan below should not be reached. Moving away from
      g_clear_pointer() in this specific case just to make our tool happy.
      
      Covscan report:
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:458:9: warning: Use of memory after it is freed
       > #    if (wbuf->write_pos != wbuf->size) {
       > #        ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:268:12: note: Assuming the condition is true
       > #    while (*vportp && (*vportp)->write_buf)
       > #           ^~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:268:12: note: Left side of '&&' is true
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:268:5: note: Loop condition is true.  Entering loop body
       > #    while (*vportp && (*vportp)->write_buf)
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:269:9: note: Calling 'vdagent_virtio_port_do_write'
       > #        vdagent_virtio_port_do_write(vportp);
       > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:453:5: note: Taking false branch
       > #    if (!wbuf) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:458:9: note: Assuming the condition is false
       > #    if (wbuf->write_pos != wbuf->size) {
       > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:458:5: note: Taking false branch
       > #    if (wbuf->write_pos != wbuf->size) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:465:9: note: Assuming 'n' is < 0
       > #    if (n < 0) {
       > #        ^~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:465:5: note: Taking true branch
       > #    if (n < 0) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:466:13: note: Assuming the condition is false
       > #        if (errno == EINTR)
       > #            ^~~~~~~~~~~~~~
       > /usr/include/errno.h:38:16: note: expanded from macro 'errno'
       > ## define errno (*__errno_location ())
       > #               ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:466:9: note: Taking false branch
       > #        if (errno == EINTR)
       > #        ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:469:9: note: Calling 'vdagent_virtio_port_destroy'
       > #        vdagent_virtio_port_destroy(vportp);
       > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:130:5: note: Taking false branch
       > #    if (!vport)
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:133:9: note: Assuming the condition is false
       > #    if (vport->disconnect_callback)
       > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:133:5: note: Taking false branch
       > #    if (vport->disconnect_callback)
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:137:5: note: Loop condition is true.  Entering loop body
       > #    while (wbuf) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:140:9: note: Memory is released
       > #        g_free(wbuf);
       > #        ^~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:137:5: note: Loop condition is false. Execution continues on line 144
       > #    while (wbuf) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:144:5: note: Loop condition is true.  Entering loop body
       > #    for (i = 0; i < VDP_END_PORT; i++) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:144:5: note: Loop condition is true.  Entering loop body
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:144:5: note: Loop condition is true.  Entering loop body
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:144:5: note: Loop condition is false. Execution continues on line 148
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:149:5: note: Assuming '_p' is null
       > #    g_clear_pointer(vportp, g_free);
       > #    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > /usr/include/glib-2.0/glib/gmem.h:124:9: note: expanded from macro 'g_clear_pointer'
       > #    if (_p)                                                                    \
       > #        ^~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:149:5: note: Taking false branch
       > /usr/include/glib-2.0/glib/gmem.h:124:5: note: expanded from macro 'g_clear_pointer'
       > #    if (_p)                                                                    \
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:149:5: note: Loop condition is false.  Exiting loop
       > /usr/include/glib-2.0/glib/gmem.h:114:3: note: expanded from macro 'g_clear_pointer'
       > #  G_STMT_START {                                                               \
       > #  ^
       > /usr/include/glib-2.0/glib/gmacros.h:346:23: note: expanded from macro 'G_STMT_START'
       > ##define G_STMT_START  do
       > #                      ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:469:9: note: Returning; memory was released
       > #        vdagent_virtio_port_destroy(vportp);
       > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:269:9: note: Returning; memory was released
       > #        vdagent_virtio_port_do_write(vportp);
       > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:268:12: note: Left side of '&&' is true
       > #    while (*vportp && (*vportp)->write_buf)
       > #           ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:268:5: note: Loop condition is true.  Entering loop body
       > #    while (*vportp && (*vportp)->write_buf)
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:269:9: note: Calling 'vdagent_virtio_port_do_write'
       > #        vdagent_virtio_port_do_write(vportp);
       > #        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:453:5: note: Taking false branch
       > #    if (!wbuf) {
       > #    ^
       > spice-vdagent-0.19.0/src/vdagentd/virtio-port.c:458:9: note: Use of memory after it is freed
       > #    if (wbuf->write_pos != wbuf->size) {
       > #        ^~~~~~~~~~~~~~~
       > #  456|       }
       > #  457|
       > #  458|->     if (wbuf->write_pos != wbuf->size) {
       > #  459|           syslog(LOG_ERR, "do_write: buffer is incomplete!!");
       > #  460|           return;
      
      Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
      Acked-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      83d2dbba
  11. Jul 24, 2019
    • Frediano Ziglio's avatar
      x11: Change check to make code scanners not giving warning · 0b94306d
      Frediano Ziglio authored
      
      Some code scanners (both Coverity and clang one) report that
      prev_sel/prev_cond could be unreferenced while NULL.
      Change condition to make clear a NULL pointer is not used.
      
      Signed-off-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      0b94306d
    • Victor Toso's avatar
      device-info: remove g_list_length() on compare_addresses() · 66935d13
      Victor Toso authored and Frediano Ziglio's avatar Frediano Ziglio committed
      
      The g_list_length() function does iterate over both lists to compare
      its length. Considering that we use this to check for true/false and
      we will iterate again on both lists, we can do so once.
      
      This also avoids covscan/clang warnings:
      
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:216:27: warning: Access to field 'data' results in a dereference of a null pointer (loaded from variable 'lb')
       | #        PciDevice *devb = lb->data;
       | #                          ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:397:5: note: Taking false branch
       | #    if (!user_pci_addr) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:407:22: note: Calling 'find_device_at_pci_address'
       | #    char *dev_path = find_device_at_pci_address(user_pci_addr, &vendor_id, &device_id);
       | #                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:329:5: note: Taking true branch
       | #    g_return_val_if_fail(pci_addr != NULL, NULL);
       | #    ^
       | /usr/include/glib-2.0/glib/gmessages.h:594:9: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #        ^
       | /usr/include/glib-2.0/glib/gmacros.h:385:43: note: expanded from macro 'G_LIKELY'
       | ##define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
       | #                                          ^
       | /usr/include/glib-2.0/glib/gmacros.h:379:4: note: expanded from macro '_G_BOOLEAN_EXPR'
       | #   if (expr)                                    \
       | #   ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:329:5: note: Taking true branch
       | /usr/include/glib-2.0/glib/gmessages.h:594:6: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #     ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:329:5: note: Loop condition is false.  Exiting loop
       | /usr/include/glib-2.0/glib/gmessages.h:593:40: note: expanded from macro 'g_return_val_if_fail'
       | ##define g_return_val_if_fail(expr,val)  G_STMT_START{                   \
       | #                                        ^
       | /usr/include/glib-2.0/glib/gmacros.h:346:23: note: expanded from macro 'G_STMT_START'
       | ##define G_STMT_START  do
       | #                      ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:330:5: note: Taking true branch
       | #    g_return_val_if_fail(device_id != NULL, NULL);
       | #    ^
       | /usr/include/glib-2.0/glib/gmessages.h:594:9: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #        ^
       | /usr/include/glib-2.0/glib/gmacros.h:385:43: note: expanded from macro 'G_LIKELY'
       | ##define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
       | #                                          ^
       | /usr/include/glib-2.0/glib/gmacros.h:379:4: note: expanded from macro '_G_BOOLEAN_EXPR'
       | #   if (expr)                                    \
       | #   ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:330:5: note: Taking true branch
       | /usr/include/glib-2.0/glib/gmessages.h:594:6: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #     ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:330:5: note: Loop condition is false.  Exiting loop
       | /usr/include/glib-2.0/glib/gmessages.h:593:40: note: expanded from macro 'g_return_val_if_fail'
       | ##define g_return_val_if_fail(expr,val)  G_STMT_START{                   \
       | #                                        ^
       | /usr/include/glib-2.0/glib/gmacros.h:346:23: note: expanded from macro 'G_STMT_START'
       | ##define G_STMT_START  do
       | #                      ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:331:5: note: Taking true branch
       | #    g_return_val_if_fail(vendor_id != NULL, NULL);
       | #    ^
       | /usr/include/glib-2.0/glib/gmessages.h:594:9: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #        ^
       | /usr/include/glib-2.0/glib/gmacros.h:385:43: note: expanded from macro 'G_LIKELY'
       | ##define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR((expr)), 1))
       | #                                          ^
       | /usr/include/glib-2.0/glib/gmacros.h:379:4: note: expanded from macro '_G_BOOLEAN_EXPR'
       | #   if (expr)                                    \
       | #   ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:331:5: note: Taking true branch
       | /usr/include/glib-2.0/glib/gmessages.h:594:6: note: expanded from macro 'g_return_val_if_fail'
       | #     if G_LIKELY(expr) { } else                                         \
       | #     ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:331:5: note: Loop condition is false.  Exiting loop
       | /usr/include/glib-2.0/glib/gmessages.h:593:40: note: expanded from macro 'g_return_val_if_fail'
       | ##define g_return_val_if_fail(expr,val)  G_STMT_START{                   \
       | #                                        ^
       | /usr/include/glib-2.0/glib/gmacros.h:346:23: note: expanded from macro 'G_STMT_START'
       | ##define G_STMT_START  do
       | #                      ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:334:5: note: Loop condition is true.  Entering loop body
       | #    for (int i = 0; i < 10; ++i) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:340:13: note: Assuming the condition is false
       | #        if (stat(dev_path, &buf) != 0) {
       | #            ^~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:340:9: note: Taking false branch
       | #        if (stat(dev_path, &buf) != 0) {
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:355:13: note: Assuming the condition is false
       | #        if (realpath(sys_path, device_link) == NULL) {
       | #            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:355:9: note: Taking false branch
       | #        if (realpath(sys_path, device_link) == NULL) {
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:361:36: note: Calling 'parse_pci_address_from_sysfs_path'
       | #        PciAddress *drm_pci_addr = parse_pci_address_from_sysfs_path(device_link);
       | #                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:129:9: note: Assuming 'pos' is non-null
       | #    if (!pos) {
       | #        ^~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:129:5: note: Taking false branch
       | #    if (!pos) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:136:9: note: Assuming 'pos' is non-null
       | #    if (!pos) {
       | #        ^~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:136:5: note: Taking false branch
       | #    if (!pos) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:142:9: note: Assuming 'pos' is non-null
       | #    if (!pos) {
       | #        ^~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:142:5: note: Taking false branch
       | #    if (!pos) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:146:27: note: Calling 'pci_address_new'
       | #    PciAddress *address = pci_address_new();
       | #                          ^~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:61:12: note: Taking false branch
       | #    return g_new0(PciAddress, 1);
       | #           ^
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^
       | /usr/include/glib-2.0/glib/gmem.h:211:4: note: expanded from macro '_G_NEW'
       | #          if (__s == 1)                                         \
       | #          ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:61:12: note: Left side of '&&' is false
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^
       | /usr/include/glib-2.0/glib/gmem.h:213:40: note: expanded from macro '_G_NEW'
       | #          else if (__builtin_constant_p (__n) &&                \
       | #                                              ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:61:12: note: Null pointer value stored to field 'devices'
       | #    return g_new0(PciAddress, 1);
       | #           ^~~~~~~~~~~~~~~~~~~~~
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | /usr/include/glib-2.0/glib/gmem.h:217:12: note: expanded from macro '_G_NEW'
       | #            __p = g_##func##_n (__n, __s);                      \
       | #                  ^~~~~~~~~~~~~~~~~~~~~~~
       | <scratch space>:76:1: note: expanded from here
       | #g_malloc0_n
       | #^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:146:27: note: Returning from 'pci_address_new'
       | #    PciAddress *address = pci_address_new();
       | #                          ^~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:149:5: note: Loop condition is true.  Entering loop body
       | #    while (pos) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:150:26: note: Taking false branch
       | #        PciDevice *dev = g_new0(PciDevice, 1);
       | #                         ^
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^
       | /usr/include/glib-2.0/glib/gmem.h:211:4: note: expanded from macro '_G_NEW'
       | #          if (__s == 1)                                         \
       | #          ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:150:26: note: Left side of '&&' is false
       | /usr/include/glib-2.0/glib/gmem.h:279:42: note: expanded from macro 'g_new0'
       | ##define g_new0(struct_type, n_structs)                  _G_NEW (struct_type, n_structs, malloc0)
       | #                                                        ^
       | /usr/include/glib-2.0/glib/gmem.h:213:40: note: expanded from macro '_G_NEW'
       | #          else if (__builtin_constant_p (__n) &&                \
       | #                                              ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:152:9: note: Taking true branch
       | #        if (!parse_pci_device(pos + 1, next, dev)) {
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:154:13: note:  Execution continues on line 159
       | #            break;
       | #            ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:361:36: note: Returning from 'parse_pci_address_from_sysfs_path'
       | #        PciAddress *drm_pci_addr = parse_pci_address_from_sysfs_path(device_link);
       | #                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:362:9: note: Taking false branch
       | #        if (!drm_pci_addr) {
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:367:14: note: Calling 'compare_addresses'
       | #        if (!compare_addresses(pci_addr, drm_pci_addr)) {
       | #             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:207:11: note: Assuming the condition is true
       | #    if (!(a->domain == b->domain
       | #          ^~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:207:11: note: Left side of '&&' is true
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:208:12: note: Assuming the condition is true
       | #        && g_list_length(a->devices) == g_list_length(b->devices))) {
       | #           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:207:5: note: Taking false branch
       | #    if (!(a->domain == b->domain
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:212:35: note: 'lb' initialized to a null pointer value
       | #    for (GList *la = a->devices, *lb = b->devices;
       | #                                  ^~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:213:10: note: Assuming 'la' is not equal to NULL
       | #         la != NULL;
       | #         ^~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:212:5: note: Loop condition is true.  Entering loop body
       | #    for (GList *la = a->devices, *lb = b->devices;
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/device-info.c:216:27: note: Access to field 'data' results in a dereference of a null pointer (loaded from variable 'lb')
       | #        PciDevice *devb = lb->data;
       | #                          ^~
       | #  214|            la = la->next, lb = lb->next) {
       | #  215|           PciDevice *deva = la->data;
       | #  216|->         PciDevice *devb = lb->data;
       | #  217|
       | #  218|           if (deva->slot != devb->slot
      
      Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
      Acked-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      66935d13
    • Frediano Ziglio's avatar
      x11: Constify XEvent argument · af8d1948
      Frediano Ziglio authored
      
      No reasons to have it mutable.
      
      Signed-off-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      af8d1948
    • Frediano Ziglio's avatar
      x11: Avoid passing XEvent as value · 3522667b
      Frediano Ziglio authored
      
      The structure is not that small and is not necessary to copy
      the value.
      This also removed a Coverity warning.
      
      Signed-off-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      3522667b
    • Frediano Ziglio's avatar
      x11-randr: Avoid passing XEvent as value · b6dfef73
      Frediano Ziglio authored
      
      The structure is not that small and is not necessary to copy
      the value.
      This also removed a Coverity warning.
      
      Signed-off-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      Acked-by: default avatarVictor Toso <victortoso@redhat.com>
      b6dfef73
  12. Jul 19, 2019
    • Victor Toso's avatar
      vdagent: simple fix for address-of-packed-member · 6bfbd03e
      Victor Toso authored and Frediano Ziglio's avatar Frediano Ziglio committed
      
      Seems to be a false positive but as this message only happens when user
      client connects, we can copy this array to make compiling warn free.
      
       > src/vdagent/vdagent.c: In function ‘daemon_read_complete’:
       > src/vdagent/vdagent.c:226:71: error: taking address of packed member of
       >     ‘struct VDAgentAudioVolumeSync’ may result in an unaligned pointer
       >     value [-Werror=address-of-packed-member]
       >   226 |             vdagent_audio_playback_sync(avs->mute, avs->nchannels, avs->volume);
       >       |                                                                    ~~~^~~~~~~~
       > src/vdagent/vdagent.c:228:69: error: taking address of packed member of
       >     ‘struct VDAgentAudioVolumeSync’ may result in an unaligned pointer
       >     value [-Werror=address-of-packed-member]
       >   228 |             vdagent_audio_record_sync(avs->mute, avs->nchannels, avs->volume);
       >       |                                                                  ~~~^~~~~~~~
      
      Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
      Acked-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      6bfbd03e
    • Victor Toso's avatar
      x11-randr: simplest fix for address-of-packed-member · 7976dc31
      Victor Toso authored and Frediano Ziglio's avatar Frediano Ziglio committed
      
      The struct type for width/height is uint32_t while we are trying to
      access and change it with int* - code can be improved a bit in following
      patches but this one fixes the warning by copying the value from the
      struct and copying back new value afterwards.
      
      Also:
      - Moved variables to internal scope;
      - Added braces to inner if;
      
       > src/vdagent/x11-randr.c: In function ‘zero_base_monitors’:
       >     src/vdagent/x11-randr.c:621:28: error: taking address of packed member of
       >     ‘struct VDAgentMonConfig’ may result in an unaligned pointer value
       > [-Werror=address-of-packed-member]
       >   621 |         mon_width = (int *)&mon_config->monitors[i].width;
       >       |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       > src/vdagent/x11-randr.c:622:29: error: taking address of packed member of
       >     ‘struct VDAgentMonConfig’ may result in an unaligned pointer value
       >     [-Werror=address-of-packed-member]
       >   622 |         mon_height = (int *)&mon_config->monitors[i].height;
       >       |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
      Acked-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      7976dc31
    • Victor Toso's avatar
      x11-randr: use glib's MAX and MIN · 70c5908f
      Victor Toso authored and Frediano Ziglio's avatar Frediano Ziglio committed
      
      Since 28618682 "randr: remove monitors.xml on auto-configuration" in
      2015-04-10 by Marc-Andre Lureau <marcandre.lureau@redhat.com> this
      file includes glib.h and can remove those helpers.
      
      Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
      Acked-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      70c5908f
    • Victor Toso's avatar
      vdagent: fix memory leak of g_memdup() · b6fde164
      Victor Toso authored and Frediano Ziglio's avatar Frediano Ziglio committed
      
      Found by covscan:
      
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:432:9: warning: Potential leak of memory pointed to by 'orig_argv'
       | #        g_printerr("Invalid arguments, %s\n", error->message);
       | #        ^
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:418:24: note: Memory is allocated
       | #    char **orig_argv = g_memdup(argv, sizeof(char*) * (argc+1));
       | #                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:431:9: note: Assuming 'error' is not equal to NULL
       | #    if (error != NULL) {
       | #        ^~~~~~~~~~~~~
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:431:5: note: Taking true branch
       | #    if (error != NULL) {
       | #    ^
       | spice-vdagent-0.19.0/src/vdagent/vdagent.c:432:9: note: Potential leak of memory pointed to by 'orig_argv'
       | #        g_printerr("Invalid arguments, %s\n", error->message);
       | #        ^
       | #  430|
       | #  431|       if (error != NULL) {
       | #  432|->         g_printerr("Invalid arguments, %s\n", error->message);
       | #  433|           g_clear_error(&error);
       | #  434|           return -1;
      
      Signed-off-by: default avatarVictor Toso <victortoso@redhat.com>
      Acked-by: default avatarFrediano Ziglio <fziglio@redhat.com>
      b6fde164
  13. Apr 12, 2019
Loading