aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/dbus/dbus_new_handlers_wps.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2014-12-31 11:57:48 (GMT)
committerJouni Malinen <j@w1.fi>2015-01-02 20:50:26 (GMT)
commite3c4f0b5d5f34d919a5add944d319533a04cbdb2 (patch)
treebfebf1131c4c6b10985a52ba34f6053cc91be337 /wpa_supplicant/dbus/dbus_new_handlers_wps.c
parentbba40b65b048530d32fcad366e2c3685dfd9f4de (diff)
downloadhostap-e3c4f0b5d5f34d919a5add944d319533a04cbdb2.zip
hostap-e3c4f0b5d5f34d919a5add944d319533a04cbdb2.tar.gz
hostap-e3c4f0b5d5f34d919a5add944d319533a04cbdb2.tar.bz2
D-Bus: Simplify message building error paths
There is no need to have multiple separate return statements for error cases in a sequence of operations. In addition, there is not much point in "converting" boolean return values with "if (!res) return FALSE; return TRUE;" style constructions. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/dbus/dbus_new_handlers_wps.c')
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_wps.c20
1 files changed, 4 insertions, 16 deletions
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_wps.c b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
index 4226f2f..04d9489 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_wps.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_wps.c
@@ -311,22 +311,10 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
}
dbus_message_iter_init_append(reply, &iter);
- if (!wpa_dbus_dict_open_write(&iter, &dict_iter)) {
- dbus_message_unref(reply);
- return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
- NULL);
- }
-
- if (os_strlen(npin) > 0) {
- if (!wpa_dbus_dict_append_string(&dict_iter, "Pin", npin)) {
- dbus_message_unref(reply);
- return dbus_message_new_error(message,
- DBUS_ERROR_NO_MEMORY,
- NULL);
- }
- }
-
- if (!wpa_dbus_dict_close_write(&iter, &dict_iter)) {
+ if (!wpa_dbus_dict_open_write(&iter, &dict_iter) ||
+ (os_strlen(npin) > 0 &&
+ !wpa_dbus_dict_append_string(&dict_iter, "Pin", npin)) ||
+ !wpa_dbus_dict_close_write(&iter, &dict_iter)) {
dbus_message_unref(reply);
return dbus_message_new_error(message, DBUS_ERROR_NO_MEMORY,
NULL);