Fixes for build & run under Ubuntu

Aleksander Morgado aleksander at lanedo.com
Fri Sep 13 09:55:29 PDT 2013


On 13/09/13 18:42, Heath Kehoe wrote:
> There are a couple of problems when I tried to build (using sources from
> Git) and run under Ubuntu 12.04.3.
> 

Thanks for these; can you provide patches generated with git
format-patch, with proper commit logs, so that I can import them directly?



> First, there are a couple of compiler errors that look like this:
> 
> qmi-device.c: In function 'input_ready_cb':
> qmi-device.c:1344:12: error: declaration of 'read' shadows a global
> declaration [-Werror=shadow]
> cc1: all warnings being treated as errors
> make[4]: *** [libqmi_glib_la-qmi-device.lo] Error 1
> 
> Second, the qmi-network script doesn't work properly because it uses a
> bash-specific "source" command. In Ubuntu, /bin/sh is dash. The solution
> is to just change "source" to a dot, which is the proper way to do a
> "source" in POSIX sh.
> 
> The patch below fixes these issues.
> 
> diff --git a/src/libqmi-glib/qmi-device.c b/src/libqmi-glib/qmi-device.c
> index 286f5d7..e8ae96f 100644
> --- a/src/libqmi-glib/qmi-device.c
> +++ b/src/libqmi-glib/qmi-device.c
> @@ -1341,14 +1341,14 @@ input_ready_cb (GInputStream *istream,
>  {
>      guint8 buffer[BUFFER_SIZE];
>      GError *error = NULL;
> -    gssize read;
> +    gssize r;
>  
> -    read = g_pollable_input_stream_read_nonblocking
> (G_POLLABLE_INPUT_STREAM (istream),
> +    r = g_pollable_input_stream_read_nonblocking
> (G_POLLABLE_INPUT_STREAM (istream),
>                                                       buffer,
>                                                       BUFFER_SIZE,
>                                                       NULL,
>                                                       &error);
> -    if (read < 0) {
> +    if (r < 0) {
>          g_warning ("Error reading from istream: %s", error ?
> error->message : "unknown");
>          if (error)
>              g_error_free (error);
> @@ -1357,16 +1357,16 @@ input_ready_cb (GInputStream *istream,
>          return FALSE;
>      }
>  
> -    if (read == 0) {
> +    if (r == 0) {
>          /* HUP! */
>          g_warning ("Cannot read from istream: connection broken");
>          return FALSE;
>      }
>  
> -    /* else, read > 0 */
> +    /* else, r > 0 */
>      if (!G_UNLIKELY (self->priv->buffer))
> -        self->priv->buffer = g_byte_array_sized_new (read);
> -    g_byte_array_append (self->priv->buffer, buffer, read);
> +        self->priv->buffer = g_byte_array_sized_new (r);
> +    g_byte_array_append (self->priv->buffer, buffer, r);
>  
>      /* Try to parse input messages */
>      parse_response (self);
> diff --git a/src/libqmi-glib/qmi-proxy.c b/src/libqmi-glib/qmi-proxy.c
> index f956746..1b0c1ba 100644
> --- a/src/libqmi-glib/qmi-proxy.c
> +++ b/src/libqmi-glib/qmi-proxy.c
> @@ -557,7 +557,7 @@ connection_readable_cb (GSocket *socket,
>  {
>      guint8 buffer[BUFFER_SIZE];
>      GError *error = NULL;
> -    gssize read;
> +    gssize r;
>  
>      if (condition & G_IO_HUP || condition & G_IO_ERR) {
>          g_debug ("client connection closed");
> @@ -568,12 +568,12 @@ connection_readable_cb (GSocket *socket,
>      if (!(condition & G_IO_IN || condition & G_IO_PRI))
>          return TRUE;
>  
> -    read = g_input_stream_read (g_io_stream_get_input_stream
> (G_IO_STREAM (client->connection)),
> +    r = g_input_stream_read (g_io_stream_get_input_stream (G_IO_STREAM
> (client->connection)),
>                                  buffer,
>                                  BUFFER_SIZE,
>                                  NULL,
>                                  &error);
> -    if (read < 0) {
> +    if (r < 0) {
>          g_warning ("Error reading from istream: %s", error ?
> error->message : "unknown");
>          if (error)
>              g_error_free (error);
> @@ -582,13 +582,13 @@ connection_readable_cb (GSocket *socket,
>          return FALSE;
>      }
>  
> -    if (read == 0)
> +    if (r == 0)
>          return TRUE;
>  
> -    /* else, read > 0 */
> +    /* else, r > 0 */
>      if (!G_UNLIKELY (client->buffer))
> -        client->buffer = g_byte_array_sized_new (read);
> -    g_byte_array_append (client->buffer, buffer, read);
> +        client->buffer = g_byte_array_sized_new (r);
> +    g_byte_array_append (client->buffer, buffer, r);
>  
>      /* Try to parse input messages */
>      parse_request (client);
> diff --git a/utils/qmi-network.in b/utils/qmi-network.in
> index 2bef24a..1470f38 100755
> --- a/utils/qmi-network.in
> +++ b/utils/qmi-network.in
> @@ -69,7 +69,7 @@ load_profile ()
>  {
>      if [ -f $PROFILE_FILE ]; then
>          echo "Loading profile..."
> -        source $PROFILE_FILE
> +        . $PROFILE_FILE
>  
>          if [ "x$APN" != "x" ]; then
>              echo "    APN: $APN"
> @@ -103,7 +103,7 @@ load_state ()
>  {
>      if [ -f $STATE_FILE ]; then
>          echo "Loading previous state..."
> -        source $STATE_FILE
> +        . $STATE_FILE
>  
>          if [ "x$CID" != "x" ]; then
>              echo "    Previous CID: $CID"
> 
> _______________________________________________
> libqmi-devel mailing list
> libqmi-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libqmi-devel


-- 
Aleksander


More information about the libqmi-devel mailing list