P2P: Fix 32-bit compiler warnings on service discovery reference

Convert core wpa_supplicant code to use u64 instead of void * for the
P2P service discovery reference. Use uintptr_t in type casts in
p2p_supplicant.c to handle the conversion without warnings.

Note: This needs to be revisited for 128-bit CPU where sizeof(void *)
could be larger than sizeof(u64).

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2011-12-11 18:06:34 +02:00
parent 5aff6fc697
commit 7165c5dc1f
4 changed files with 26 additions and 26 deletions

View file

@ -2610,8 +2610,7 @@ static int p2p_ctrl_serv_disc_req(struct wpa_supplicant *wpa_s, char *cmd,
if (*pos != ' ')
return -1;
pos++;
ref = (unsigned long) wpas_p2p_sd_request_upnp(wpa_s, dst,
version, pos);
ref = wpas_p2p_sd_request_upnp(wpa_s, dst, version, pos);
} else {
len = os_strlen(pos);
if (len & 1)
@ -2625,9 +2624,11 @@ static int p2p_ctrl_serv_disc_req(struct wpa_supplicant *wpa_s, char *cmd,
return -1;
}
ref = (unsigned long) wpas_p2p_sd_request(wpa_s, dst, tlvs);
ref = wpas_p2p_sd_request(wpa_s, dst, tlvs);
wpabuf_free(tlvs);
}
if (ref == 0)
return -1;
res = os_snprintf(buf, buflen, "%llx", (long long unsigned) ref);
if (res < 0 || (unsigned) res >= buflen)
return -1;
@ -2643,7 +2644,7 @@ static int p2p_ctrl_serv_disc_cancel_req(struct wpa_supplicant *wpa_s,
if (sscanf(cmd, "%llx", &val) != 1)
return -1;
req = val;
return wpas_p2p_sd_cancel_request(wpa_s, (void *) (unsigned long) req);
return wpas_p2p_sd_cancel_request(wpa_s, req);
}

View file

@ -2020,13 +2020,11 @@ DBusMessage * wpas_dbus_handler_p2p_service_sd_req(
if (version <= 0 || service == NULL)
goto error;
ref = (unsigned long) wpas_p2p_sd_request_upnp(wpa_s, addr,
version,
service);
ref = wpas_p2p_sd_request_upnp(wpa_s, addr, version, service);
} else {
if (tlv == NULL)
goto error;
ref = (unsigned long)wpas_p2p_sd_request(wpa_s, addr, tlv);
ref = wpas_p2p_sd_request(wpa_s, addr, tlv);
wpabuf_free(tlv);
}
@ -2127,7 +2125,7 @@ DBusMessage * wpas_dbus_handler_p2p_service_sd_cancel_req(
if (req == 0)
goto error;
if (!wpas_p2p_sd_cancel_request(wpa_s, (void *)(unsigned long) req))
if (!wpas_p2p_sd_cancel_request(wpa_s, req))
goto error;
return NULL;

View file

@ -1490,26 +1490,26 @@ void wpas_sd_response(void *ctx, const u8 *sa, u16 update_indic,
}
void * wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
u64 wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
const struct wpabuf *tlvs)
{
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
return (void *) wpa_drv_p2p_sd_request(wpa_s, dst, tlvs);
return wpa_drv_p2p_sd_request(wpa_s, dst, tlvs);
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return NULL;
return p2p_sd_request(wpa_s->global->p2p, dst, tlvs);
return 0;
return (uintptr_t) p2p_sd_request(wpa_s->global->p2p, dst, tlvs);
}
void * wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
u64 wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
u8 version, const char *query)
{
struct wpabuf *tlvs;
void *ret;
u64 ret;
tlvs = wpabuf_alloc(2 + 1 + 1 + 1 + os_strlen(query));
if (tlvs == NULL)
return NULL;
return 0;
wpabuf_put_le16(tlvs, 1 + 1 + 1 + os_strlen(query));
wpabuf_put_u8(tlvs, P2P_SERV_UPNP); /* Service Protocol Type */
wpabuf_put_u8(tlvs, 1); /* Service Transaction ID */
@ -1521,13 +1521,14 @@ void * wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
}
int wpas_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s, void *req)
int wpas_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s, u64 req)
{
if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
return wpa_drv_p2p_sd_cancel_request(wpa_s, (u64) req);
return wpa_drv_p2p_sd_cancel_request(wpa_s, req);
if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
return -1;
return p2p_sd_cancel_request(wpa_s->global->p2p, req);
return p2p_sd_cancel_request(wpa_s->global->p2p,
(void *) (uintptr_t) req);
}

View file

@ -80,11 +80,11 @@ void wpas_sd_request(void *ctx, int freq, const u8 *sa, u8 dialog_token,
u16 update_indic, const u8 *tlvs, size_t tlvs_len);
void wpas_sd_response(void *ctx, const u8 *sa, u16 update_indic,
const u8 *tlvs, size_t tlvs_len);
void * wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
u64 wpas_p2p_sd_request(struct wpa_supplicant *wpa_s, const u8 *dst,
const struct wpabuf *tlvs);
void * wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
u64 wpas_p2p_sd_request_upnp(struct wpa_supplicant *wpa_s, const u8 *dst,
u8 version, const char *query);
int wpas_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s, void *req);
int wpas_p2p_sd_cancel_request(struct wpa_supplicant *wpa_s, u64 req);
void wpas_p2p_sd_response(struct wpa_supplicant *wpa_s, int freq,
const u8 *dst, u8 dialog_token,
const struct wpabuf *resp_tlvs);