Skip to contentSkip to conversation

libcacard: Fix compilation for older versions of glib (bug #1258168)

PATCH In review Stefan Weil 3 participants 4 messages Dec 5, 2013 – Dec 8, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 libcacard: Fix compilation for older versions of glib (bug #1258168)

See https://bugs.launchpad.net/bugs/1258168

libcacard/vscclient.c: In function 'do_socket_read':
libcacard/vscclient.c:410: warning: implicit declaration of function 'g_warn_if_reached' libcacard/vscclient.c:410: warning: nested extern declaration of 'g_warn_if_reached' libcacard/vscclient.c: In function 'main':
libcacard/vscclient.c:763: warning: implicit declaration of function 'g_byte_array_unref' libcacard/vscclient.c:763: warning: nested extern declaration of 'g_byte_array_unref'
...
libcacard/vscclient.o: In function `do_socket_read':
libcacard/vscclient.c:410: undefined reference to g_warn_if_reached' libcacard/vscclient.o: In function main':
libcacard/vscclient.c:763: undefined reference to `g_byte_array_unref'

g_warn_if_reached was added in glib 2.16, and g_byte_array_unref is supported since glib 2.22. QEMU requires glib 2.12, so both names must not be used.

Instead of showing a warning for code which should not be reached, QEMU better stops running, so g_warn_if_reached is not useful for QEMU.

In libcacard/vsclient.c, g_byte_array_unref can be replaced by g_byte_array_free. This is not generally true, so adding a compatibility layer in include/glib-compat.h is no option here.

---

v2: Fix commit message and add missing parameter for g_byte_array_free.

 libcacard/vscclient.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libcacard/vscclient.c +2 -2
index a3cb776..f1d46d3 100644
@@ -407,7 +407,7 @@ do_socket_read(GIOChannel *source,
             }
             break;
         default:
-            g_warn_if_reached();
+            g_assert_not_reached();
             return FALSE;
         }
 
@@ -760,7 +760,7 @@ main(
 
     g_io_channel_unref(channel_stdin);
     g_io_channel_unref(channel_socket);
-    g_byte_array_unref(socket_to_send);
+    g_byte_array_free(socket_to_send, TRUE);
 
     closesocket(sock);
     return 0;
Signature · 1 line
1.7.10.4
Tested-by on v2 1/1
#1 lore raw
Quoted 1 line · Stefan Weil

See https://bugs.launchpad.net/bugs/1258168

This fixes the compile issue I have seen so

-Don Slutz

Quoted 55 lines

libcacard/vscclient.c: In function 'do_socket_read':
libcacard/vscclient.c:410: warning: implicit declaration of function 'g_warn_if_reached' libcacard/vscclient.c:410: warning: nested extern declaration of 'g_warn_if_reached' libcacard/vscclient.c: In function 'main':
libcacard/vscclient.c:763: warning: implicit declaration of function 'g_byte_array_unref' libcacard/vscclient.c:763: warning: nested extern declaration of 'g_byte_array_unref'
...
libcacard/vscclient.o: In function `do_socket_read':
libcacard/vscclient.c:410: undefined reference to g_warn_if_reached' libcacard/vscclient.o: In function main':
libcacard/vscclient.c:763: undefined reference to `g_byte_array_unref'

g_warn_if_reached was added in glib 2.16, and g_byte_array_unref is supported since glib 2.22. QEMU requires glib 2.12, so both names must not be used.

Instead of showing a warning for code which should not be reached, QEMU better stops running, so g_warn_if_reached is not useful for QEMU.

In libcacard/vsclient.c, g_byte_array_unref can be replaced by g_byte_array_free. This is not generally true, so adding a compatibility layer in include/glib-compat.h is no option here.

---

v2: Fix commit message and add missing parameter for g_byte_array_free.

  libcacard/vscclient.c |    4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
libcacard/vscclient.c +2 -2
index a3cb776..f1d46d3 100644
@@ -407,7 +407,7 @@ do_socket_read(GIOChannel *source,
              }
              break;
          default:
-            g_warn_if_reached();
+            g_assert_not_reached();
              return FALSE;
          }
 
@@ -760,7 +760,7 @@ main(
 
      g_io_channel_unref(channel_stdin);
      g_io_channel_unref(channel_socket);
-    g_byte_array_unref(socket_to_send);
+    g_byte_array_free(socket_to_send, TRUE);
 
      closesocket(sock);
      return 0;
#2 lore raw
In reply to Stefan Weil
Quoted 14 lines · Stefan Weil

See https://bugs.launchpad.net/bugs/1258168

libcacard/vscclient.c: In function 'do_socket_read':
libcacard/vscclient.c:410: warning: implicit declaration of function 'g_warn_if_reached' libcacard/vscclient.c:410: warning: nested extern declaration of 'g_warn_if_reached' libcacard/vscclient.c: In function 'main':
libcacard/vscclient.c:763: warning: implicit declaration of function 'g_byte_array_unref' libcacard/vscclient.c:763: warning: nested extern declaration of 'g_byte_array_unref'
...
libcacard/vscclient.o: In function `do_socket_read':
libcacard/vscclient.c:410: undefined reference to g_warn_if_reached' libcacard/vscclient.o: In function main':
libcacard/vscclient.c:763: undefined reference to `g_byte_array_unref'

Quoted 6 lines

g_warn_if_reached was added in glib 2.16, and g_byte_array_unref is supported since glib 2.22. QEMU requires glib 2.12, so both names must not be used.

Instead of showing a warning for code which should not be reached, QEMU better stops running, so g_warn_if_reached is not useful for QEMU.

Just note that this fix is in vscclient, so this code is not part of qemu executable. If you are using QEMU (all caps) as the whole project, the commit message is ok, but it should clarify this is about the separate vscclient executable.

Other then that ACK, I can send a pull request with the commit message fixed as I suggested.

Quoted 38 lines

In libcacard/vsclient.c, g_byte_array_unref can be replaced by g_byte_array_free. This is not generally true, so adding a compatibility layer in include/glib-compat.h is no option here.

---

v2: Fix commit message and add missing parameter for g_byte_array_free.

 libcacard/vscclient.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libcacard/vscclient.c +2 -2
index a3cb776..f1d46d3 100644
@@ -407,7 +407,7 @@ do_socket_read(GIOChannel *source,
             }
             break;
         default:
-            g_warn_if_reached();
+            g_assert_not_reached();
             return FALSE;
         }
 
@@ -760,7 +760,7 @@ main(
 
     g_io_channel_unref(channel_stdin);
     g_io_channel_unref(channel_socket);
-    g_byte_array_unref(socket_to_send);
+    g_byte_array_free(socket_to_send, TRUE);
 
     closesocket(sock);
     return 0;
#3 lore raw

Am 08.12.2013 10:13, schrieb Alon Levy:

Quoted 21 lines · Stefan Weil
Quoted 14 lines

See https://bugs.launchpad.net/bugs/1258168

libcacard/vscclient.c: In function 'do_socket_read':
libcacard/vscclient.c:410: warning: implicit declaration of function 'g_warn_if_reached' libcacard/vscclient.c:410: warning: nested extern declaration of 'g_warn_if_reached' libcacard/vscclient.c: In function 'main':
libcacard/vscclient.c:763: warning: implicit declaration of function 'g_byte_array_unref' libcacard/vscclient.c:763: warning: nested extern declaration of 'g_byte_array_unref'
...
libcacard/vscclient.o: In function `do_socket_read':
libcacard/vscclient.c:410: undefined reference to g_warn_if_reached' libcacard/vscclient.o: In function main':
libcacard/vscclient.c:763: undefined reference to `g_byte_array_unref'

Quoted 6 lines

g_warn_if_reached was added in glib 2.16, and g_byte_array_unref is supported since glib 2.22. QEMU requires glib 2.12, so both names must not be used.

Instead of showing a warning for code which should not be reached, QEMU better stops running, so g_warn_if_reached is not useful for QEMU.

Quoted 7 lines

Just note that this fix is in vscclient, so this code is not part of qemu executable. If you are using QEMU (all caps) as the whole project, the commit message is ok, but it should clarify this is about the separate vscclient executable.

Other then that ACK, I can send a pull request with the commit message fixed as I suggested.

Thanks for this hint. Please fix the commit message as you suggested.

Regards,
Stefan