Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1482e46 authored by Arman Uguray's avatar Arman Uguray
Browse files

build: Fix ptr <-> integer cast warnings

This CL removes the -Wno-pointer-to-integer-cast and
-Wno-integer-to-pointer-cast flags from GN build files. The resulting errors
were fixed using the following:

  1. All ptr <-> integer casts are now done by using the new
     PTR_TO_INT/INT_TO_PTR macros defined in osi.h

  2. The TIMER_PARAM_TYPE macro, defined in gki/common/gki.h and
     include/bt_target.h have been redefined as void* rather than UINT32. This
     is better, since "void*" can act as a simple container without any
     precision loss that would be caused by a type such as UINT32 on 64-bit
     systems. void* inherently is a safer container for all pointer types but
     UINT32 isn't.

BUG=21570302

Change-Id: I4a82c4a40c91caa31e372382c40d424be220cbe3
parent 647753d5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ static const char GKI_MODULE[] = "gki_module";
*/
typedef void (TIMER_CBACK)(void *p_tle);
#ifndef TIMER_PARAM_TYPE
#define TIMER_PARAM_TYPE    UINT32
#define TIMER_PARAM_TYPE void*
#endif
/* Define a timer list entry
*/
+0 −10
Original line number Diff line number Diff line
@@ -111,14 +111,4 @@ static_library("bta") {
    "//utils/include",
    "//vnd/include",
  ]

  # TODO(armansito): Remove all of the flags below, since we want to enable all
  # warnings.
  cflags = [
    "-Wno-int-to-pointer-cast",
  ]

  cflags_c = [
    "-Wno-pointer-to-int-cast",
  ]
}
+2 −2
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ static tBTA_AG_SCB *bta_ag_scb_alloc(void)
            p_scb->codec_updated = FALSE;
#endif
            /* set up timers */
            p_scb->act_timer.param = (UINT32) p_scb;
            p_scb->act_timer.param = p_scb;
            p_scb->act_timer.p_cback = bta_ag_timer_cback;
#if (BTM_WBS_INCLUDED == TRUE)
            /* set eSCO mSBC setting to T2 as the preferred */
@@ -650,7 +650,7 @@ void bta_ag_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id,

        /* Start timer to han */
        p_scb->colli_timer.p_cback = (TIMER_CBACK*)&bta_ag_colli_timer_cback;
        p_scb->colli_timer.param = (INT32)p_scb;
        p_scb->colli_timer.param = p_scb;
        bta_sys_start_timer(&p_scb->colli_timer, 0, BTA_AG_COLLISION_TIMER);
        p_scb->colli_tmr_on = TRUE;
    }
+1 −1
Original line number Diff line number Diff line
@@ -693,7 +693,7 @@ void bta_ag_codec_negotiate(tBTA_AG_SCB *p_scb)

        /* Start timer to handle timeout */
        p_scb->cn_timer.p_cback = (TIMER_CBACK*)&bta_ag_cn_timer_cback;
        p_scb->cn_timer.param = (INT32)p_scb;
        p_scb->cn_timer.param = p_scb;
        bta_sys_start_timer(&p_scb->cn_timer, 0, BTA_AG_CODEC_NEGO_TIMEOUT);
    }
    else
+9 −3
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
#include "utl.h"
#include "l2c_api.h"
#include "osi/include/list.h"
#include "osi/include/osi.h"
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
#include "bta_ar_api.h"
#endif
@@ -1467,7 +1468,12 @@ void bta_av_sig_chg(tBTA_AV_DATA *p_data)
                        /* Possible collision : need to avoid outgoing processing while the timer is running */
                        p_cb->p_scb[xx]->coll_mask = BTA_AV_COLL_INC_TMR;

                        p_cb->acp_sig_tmr.param = (UINT32)xx;

                        // TODO(armansito): Why is this variable called "xx" and
                        // why is it a signed integer? The callback reinterprets
                        // it as a UINT8 and then reassigns it as param that
                        // way, so should this be unsigned?
                        p_cb->acp_sig_tmr.param = INT_TO_PTR(xx);
                        p_cb->acp_sig_tmr.p_cback = (TIMER_CBACK*)&bta_av_acp_sig_timer_cback;
                        bta_sys_start_timer(&p_cb->acp_sig_tmr, 0, BTA_AV_ACP_SIG_TIME_VAL);
                    }
@@ -1564,7 +1570,7 @@ void bta_av_sig_timer(tBTA_AV_DATA *p_data)
*******************************************************************************/
static void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle)
{
    UINT8   inx = (UINT8)p_tle->param;
    UINT8   inx = PTR_TO_UINT(p_tle->param);
    tBTA_AV_CB  *p_cb = &bta_av_cb;
    tBTA_AV_SCB *p_scb = NULL;
    tBTA_AV_API_OPEN  *p_buf;
@@ -1587,7 +1593,7 @@ static void bta_av_acp_sig_timer_cback (TIMER_LIST_ENT *p_tle)
                    /* We are still doing SDP. Run the timer again. */
                    p_scb->coll_mask |= BTA_AV_COLL_INC_TMR;

                    p_cb->acp_sig_tmr.param = (UINT32)inx;
                    p_cb->acp_sig_tmr.param = UINT_TO_PTR(inx);
                    p_cb->acp_sig_tmr.p_cback = (TIMER_CBACK *)&bta_av_acp_sig_timer_cback;
                    bta_sys_start_timer(&p_cb->acp_sig_tmr, 0, BTA_AV_ACP_SIG_TIME_VAL);
                }
Loading