[patch] libqcdm: use NULL instead of 0 for empty pointer

2014-02-06 Thread Yunlian Jiang
When I use clang 3.5 to build it, I got

commands.c:1444:16: error: expression which evaluates to zero treated as a
null
  pointer constant of type 'QcdmResult *' (aka 'struct QcdmResult *')
  [-Werror,-Wnon-literal-null-conversion]
return FALSE;
   ^
./utils.h:29:15: note: expanded from macro 'FALSE'
#define FALSE ((u_int8_t) 0)
  ^~
commands.c:1464:20: error: expression which evaluates to zero treated as a
null
  pointer constant of type 'QcdmResult *' (aka 'struct QcdmResult *')
  [-Werror,-Wnon-literal-null-conversion]
return FALSE;
   ^
./utils.h:29:15: note: expanded from macro 'FALSE'
#define FALSE ((u_int8_t) 0)
  ^~
2 errors generated.
make[3]: *** [libqcdm_la-commands.lo] Error 1
make[3]: *** Waiting for unfinished jobs

Below is the patch that fixes it

diff --git a/libqcdm/src/commands.c b/libqcdm/src/commands.c
index ff7d232..fe436e9 100644
--- a/libqcdm/src/commands.c
+++ b/libqcdm/src/commands.c
@@ -1441,7 +1441,7 @@ qcdm_cmd_ext_logmask_result (const char *buf, size_t
len, int *out_error)
 if (len  1) {
 qcdm_err (0, DM command %d response not long enough (got %zu,
expected 
   at least %d)., DIAG_CMD_EXT_LOGMASK, len, 3);
-return FALSE;
+return NULL;
 }

 /* Result of a 'set' operation will be only 1 byte in size; result of
@@ -1461,7 +1461,7 @@ qcdm_cmd_ext_logmask_result (const char *buf, size_t
len, int *out_error)
 if (len  (masklen + 3)) {
 qcdm_err (0, DM command %d response not long enough (got %zu,
expected 
   at least %d)., DIAG_CMD_EXT_LOGMASK, len, masklen
+ 3);
-return FALSE;
+return NULL;
 }
 minlen = masklen + 3;
 }
___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [patch] libqcdm: use NULL instead of 0 for empty pointer

2014-02-06 Thread Dan Williams
On Wed, 2014-02-05 at 16:08 -0800, Yunlian Jiang wrote:
 When I use clang 3.5 to build it, I got

Applied  pushed, thanks!

Dan

 commands.c:1444:16: error: expression which evaluates to zero treated as a
 null
   pointer constant of type 'QcdmResult *' (aka 'struct QcdmResult *')
   [-Werror,-Wnon-literal-null-conversion]
 return FALSE;
^
 ./utils.h:29:15: note: expanded from macro 'FALSE'
 #define FALSE ((u_int8_t) 0)
   ^~
 commands.c:1464:20: error: expression which evaluates to zero treated as a
 null
   pointer constant of type 'QcdmResult *' (aka 'struct QcdmResult *')
   [-Werror,-Wnon-literal-null-conversion]
 return FALSE;
^
 ./utils.h:29:15: note: expanded from macro 'FALSE'
 #define FALSE ((u_int8_t) 0)
   ^~
 2 errors generated.
 make[3]: *** [libqcdm_la-commands.lo] Error 1
 make[3]: *** Waiting for unfinished jobs
 
 Below is the patch that fixes it
 
 diff --git a/libqcdm/src/commands.c b/libqcdm/src/commands.c
 index ff7d232..fe436e9 100644
 --- a/libqcdm/src/commands.c
 +++ b/libqcdm/src/commands.c
 @@ -1441,7 +1441,7 @@ qcdm_cmd_ext_logmask_result (const char *buf, size_t
 len, int *out_error)
  if (len  1) {
  qcdm_err (0, DM command %d response not long enough (got %zu,
 expected 
at least %d)., DIAG_CMD_EXT_LOGMASK, len, 3);
 -return FALSE;
 +return NULL;
  }
 
  /* Result of a 'set' operation will be only 1 byte in size; result of
 @@ -1461,7 +1461,7 @@ qcdm_cmd_ext_logmask_result (const char *buf, size_t
 len, int *out_error)
  if (len  (masklen + 3)) {
  qcdm_err (0, DM command %d response not long enough (got %zu,
 expected 
at least %d)., DIAG_CMD_EXT_LOGMASK, len, masklen
 + 3);
 -return FALSE;
 +return NULL;
  }
  minlen = masklen + 3;
  }
 ___
 networkmanager-list mailing list
 networkmanager-list@gnome.org
 https://mail.gnome.org/mailman/listinfo/networkmanager-list


___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


[PATCH] libnm-glib: suppress warnings unless LIBNM_GLIB_DEBUG is set

2014-02-06 Thread Dan Williams
Most of these warnings are things libnm-glib can't do anything
about, and they are pretty annoying when running nmcli or nmtui,
and libraries usually shouldn't print random warnings anyway.
Downgrade them to debug messages that can be enabled if we need
to see them.
---
 libnm-glib/nm-object.c | 77 +++---
 1 file changed, 36 insertions(+), 41 deletions(-)

diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c
index 497f6c3..2fbc4f1 100644
--- a/libnm-glib/nm-object.c
+++ b/libnm-glib/nm-object.c
@@ -150,15 +150,15 @@ constructor (GType type,
object = G_OBJECT_CLASS (nm_object_parent_class)-constructor (type,
   
n_construct_params,
   
construct_params);
 
priv = NM_OBJECT_GET_PRIVATE (object);
 
if (priv-connection == NULL || priv-path == NULL) {
-   g_warning (%s: bus connection and path required., __func__);
+   g_warn_if_reached ();
g_object_unref (object);
return NULL;
}
 
_nm_object_cache_add (NM_OBJECT (object));
 
return object;
@@ -566,27 +566,26 @@ _nm_object_create (GType type, DBusGConnection 
*connection, const char *path)
GError *error = NULL;
 
type_func = g_hash_table_lookup (type_funcs, GSIZE_TO_POINTER (type));
if (type_func)
type = type_func (connection, path);
 
if (type == G_TYPE_INVALID) {
-   g_warning (Could not create object for %s: unknown object 
type, path);
+   dbgmsg (Could not create object for %s: unknown object type, 
path);
return NULL;
}
 
object = g_object_new (type,
   NM_OBJECT_DBUS_CONNECTION, connection,
   NM_OBJECT_DBUS_PATH, path,
   NULL);
if (!g_initable_init (G_INITABLE (object), NULL, error)) {
-   g_object_unref (object);
-   object = NULL;
-   g_warning (Could not create object for %s: %s, path, 
error-message);
+   dbgmsg (Could not create object for %s: %s, path, 
error-message);
g_error_free (error);
+   g_clear_object (object);
}
 
return object;
 }
 
 typedef void (*NMObjectCreateCallbackFunc) (GObject *, const char *, gpointer);
 typedef struct {
@@ -620,21 +619,19 @@ static void
 async_inited (GObject *source, GAsyncResult *result, gpointer user_data)
 {
NMObjectTypeAsyncData *async_data = user_data;
GObject *object = G_OBJECT (source);
GError *error = NULL;
 
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, 
error)) {
-   if (!g_error_matches (error, DBUS_GERROR, 
DBUS_GERROR_UNKNOWN_METHOD)) {
-   g_warning (Could not create object for %s: %s,
-  nm_object_or_connection_get_path (object), 
error-message);
-   }
+   dbgmsg (Could not create object for %s: %s,
+   nm_object_or_connection_get_path (object),
+   error-message);
g_error_free (error);
-   g_object_unref (object);
-   object = NULL;
+   g_clear_object (object);
}
 
create_async_complete (object, async_data);
 }
 
 static void
 async_got_type (GType type, gpointer user_data)
@@ -1024,18 +1021,18 @@ handle_property_changed (NMObject *self, const char 
*dbus_name, GValue *value, g
if (!found) {
dbgmsg (Property '%s' unhandled., prop_name);
goto out;
}
 
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT 
(self)), prop_name);
if (!pspec) {
-   g_warning (%s: property '%s' changed but wasn't defined by 
object type %s.,
-  __func__,
-  prop_name,
-  G_OBJECT_TYPE_NAME (self));
+   dbgmsg (%s: property '%s' changed but wasn't defined by object 
type %s.,
+   __func__,
+   prop_name,
+   G_OBJECT_TYPE_NAME (self));
goto out;
}
 
if (G_UNLIKELY (debug)) {
char *s;
s = g_strdup_value_contents (value);
dbgmsg (PC: (%p) %s::%s = '%s' (%s%s%s),
@@ -1057,18 +1054,18 @@ handle_property_changed (NMObject *self, const char 
*dbus_name, GValue *value, g
g_warn_if_reached ();
goto out;
}
} else
success = (*(pi-func)) (self, pspec, value, pi-field);
 
if (!success) {
-   g_warning (%s: failed to update property '%s' of object type 
%s.,
-  __func__,
-