D-Bus: Clean up parse_peer_object_path() uses

This helper function does not modify peer_path, so mark it const. In
addition, there is no point in callers to check separately whether
peer_path is NULL since that is taken care of by this helper function.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2015-01-01 15:24:08 +02:00
parent 509618d35b
commit b76ea413b1

View file

@ -35,9 +35,9 @@
* @addr - out param must be of ETH_ALEN size * @addr - out param must be of ETH_ALEN size
* Returns 0 if valid (including MAC), -1 otherwise * Returns 0 if valid (including MAC), -1 otherwise
*/ */
static int parse_peer_object_path(char *peer_path, u8 addr[ETH_ALEN]) static int parse_peer_object_path(const char *peer_path, u8 addr[ETH_ALEN])
{ {
char *p; const char *p;
if (!peer_path) if (!peer_path)
return -1; return -1;
@ -518,8 +518,8 @@ DBusMessage * wpas_dbus_handler_p2p_connect(DBusMessage *message,
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
} }
if (!peer_object_path || (wps_method == WPS_NOT_READY) || if (wps_method == WPS_NOT_READY ||
(parse_peer_object_path(peer_object_path, addr) < 0) || parse_peer_object_path(peer_object_path, addr) < 0 ||
!p2p_peer_known(wpa_s->global->p2p, addr)) !p2p_peer_known(wpa_s->global->p2p, addr))
goto inv_args; goto inv_args;
@ -627,11 +627,9 @@ DBusMessage * wpas_dbus_handler_p2p_invite(DBusMessage *message,
} }
} }
if (!peer_object_path || if (parse_peer_object_path(peer_object_path, peer_addr) < 0 ||
(parse_peer_object_path(peer_object_path, peer_addr) < 0) || !p2p_peer_known(wpa_s->global->p2p, peer_addr))
!p2p_peer_known(wpa_s->global->p2p, peer_addr)) {
goto err; goto err;
}
if (wpa_s->p2p_dev) if (wpa_s->p2p_dev)
wpa_s = wpa_s->p2p_dev; wpa_s = wpa_s->p2p_dev;
@ -2643,12 +2641,9 @@ DBusMessage * wpas_dbus_handler_p2p_service_sd_res(
wpa_dbus_dict_entry_clear(&entry); wpa_dbus_dict_entry_clear(&entry);
} }
if (!peer_object_path || if (parse_peer_object_path(peer_object_path, addr) < 0 ||
(parse_peer_object_path(peer_object_path, addr) < 0) || !p2p_peer_known(wpa_s->global->p2p, addr) ||
!p2p_peer_known(wpa_s->global->p2p, addr)) tlv == NULL)
goto error;
if (tlv == NULL)
goto error; goto error;
wpas_p2p_sd_response(wpa_s, freq, addr, (u8) dlg_tok, tlv); wpas_p2p_sd_response(wpa_s, freq, addr, (u8) dlg_tok, tlv);