dbus: Use common code for checking key parameter

No need to duplicate the check into many functions.
This commit is contained in:
Jouni Malinen 2010-01-02 10:39:19 +02:00
parent dc5a08c053
commit c221499782

View file

@ -140,6 +140,9 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_basic(DBusMessageIter *iter_dict,
DBusMessageIter iter_dict_entry, iter_dict_val; DBusMessageIter iter_dict_entry, iter_dict_val;
const char *type_as_string = NULL; const char *type_as_string = NULL;
if (key == NULL)
return FALSE;
type_as_string = _wpa_get_type_as_string_from_type(value_type); type_as_string = _wpa_get_type_as_string_from_type(value_type);
if (!type_as_string) if (!type_as_string)
return FALSE; return FALSE;
@ -218,7 +221,7 @@ static dbus_bool_t _wpa_dbus_add_dict_entry_byte_array(
dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict, dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict,
const char *key, const char *value) const char *key, const char *value)
{ {
if (!key || !value) if (!value)
return FALSE; return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_STRING, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_STRING,
&value); &value);
@ -238,8 +241,6 @@ dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict,
dbus_bool_t wpa_dbus_dict_append_byte(DBusMessageIter *iter_dict, dbus_bool_t wpa_dbus_dict_append_byte(DBusMessageIter *iter_dict,
const char *key, const char value) const char *key, const char value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_BYTE, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_BYTE,
&value); &value);
} }
@ -258,8 +259,6 @@ dbus_bool_t wpa_dbus_dict_append_byte(DBusMessageIter *iter_dict,
dbus_bool_t wpa_dbus_dict_append_bool(DBusMessageIter *iter_dict, dbus_bool_t wpa_dbus_dict_append_bool(DBusMessageIter *iter_dict,
const char *key, const dbus_bool_t value) const char *key, const dbus_bool_t value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, return _wpa_dbus_add_dict_entry_basic(iter_dict, key,
DBUS_TYPE_BOOLEAN, &value); DBUS_TYPE_BOOLEAN, &value);
} }
@ -279,8 +278,6 @@ dbus_bool_t wpa_dbus_dict_append_int16(DBusMessageIter *iter_dict,
const char *key, const char *key,
const dbus_int16_t value) const dbus_int16_t value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT16, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT16,
&value); &value);
} }
@ -300,8 +297,6 @@ dbus_bool_t wpa_dbus_dict_append_uint16(DBusMessageIter *iter_dict,
const char *key, const char *key,
const dbus_uint16_t value) const dbus_uint16_t value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT16, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT16,
&value); &value);
} }
@ -321,8 +316,6 @@ dbus_bool_t wpa_dbus_dict_append_int32(DBusMessageIter *iter_dict,
const char *key, const char *key,
const dbus_int32_t value) const dbus_int32_t value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT32, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT32,
&value); &value);
} }
@ -342,8 +335,6 @@ dbus_bool_t wpa_dbus_dict_append_uint32(DBusMessageIter *iter_dict,
const char *key, const char *key,
const dbus_uint32_t value) const dbus_uint32_t value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT32, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT32,
&value); &value);
} }
@ -363,8 +354,6 @@ dbus_bool_t wpa_dbus_dict_append_int64(DBusMessageIter *iter_dict,
const char *key, const char *key,
const dbus_int64_t value) const dbus_int64_t value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT64, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT64,
&value); &value);
} }
@ -384,8 +373,6 @@ dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict,
const char *key, const char *key,
const dbus_uint64_t value) const dbus_uint64_t value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT64, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT64,
&value); &value);
} }
@ -402,11 +389,8 @@ dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict,
* *
*/ */
dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict, dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict,
const char * key, const char *key, const double value)
const double value)
{ {
if (!key)
return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_DOUBLE, return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_DOUBLE,
&value); &value);
} }
@ -426,7 +410,7 @@ dbus_bool_t wpa_dbus_dict_append_object_path(DBusMessageIter *iter_dict,
const char *key, const char *key,
const char *value) const char *value)
{ {
if (!key || !value) if (!value)
return FALSE; return FALSE;
return _wpa_dbus_add_dict_entry_basic(iter_dict, key, return _wpa_dbus_add_dict_entry_basic(iter_dict, key,
DBUS_TYPE_OBJECT_PATH, &value); DBUS_TYPE_OBJECT_PATH, &value);