Skip to content

Commit

Permalink
Getting things to compile warning free in Linux: To the usual the wro…
Browse files Browse the repository at this point in the history
…ng type of thread functions, potential buffer overruns, the lost(?) cstinfo unit ...
  • Loading branch information
T12z committed Mar 7, 2022
1 parent 9fb5de8 commit 6a30c10
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 21 deletions.
5 changes: 3 additions & 2 deletions trdp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ TRDP_OPT_OBJS += trdp_xml.o \
tau_marshall.o \
tau_dnr.o \
tau_tti.o \
tau_cstinfo.o \
tau_ctrl.o \
tau_xsession.o \
tau_xmarshall.o
Expand Down Expand Up @@ -585,15 +586,15 @@ $(OUTDIR)/pdMcRouting: $(OUTDIR)/libtrdp.a pdMcRoutingTest.c
@$(ECHO) ' ### Building PD MC routing test receiver application $(@F)'
$(CC) test/diverse/pdMcRoutingTest.c \
-ltrdp \
$(LDFLAGS) $(CFLAGS) $(INCLUDES) \
$(LDFLAGS) $(CFLAGS) $(INCLUDES) $(LDLIBS) \
-o $@
@$(STRIP) $@

$(OUTDIR)/mdDataLength: $(OUTDIR)/libtrdp.a mdDataLengthTest.c
@$(ECHO) ' ### Building PD MC routing test receiver application $(@F)'
$(CC) test/diverse/mdDataLengthTest.c \
-ltrdp \
$(LDFLAGS) $(CFLAGS) $(INCLUDES) \
$(LDFLAGS) $(CFLAGS) $(INCLUDES) $(LDLIBS) \
-o $@
@$(STRIP) $@

Expand Down
4 changes: 4 additions & 0 deletions trdp/debian/libtrdp2.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ libtau-hp.so.2 libtrdp2 #MINVER#
tau_readXmlMappedInterfaceConfig@Base 2.0
tau_readXmlServiceConfig@Base 2.0
tau_requestEcspConfirm@Base 2.0
tau_requestEcspConfirmReply@Base 2.0-111
tau_setEcspCtrl@Base 2.0
tau_terminateEcspCtrl@Base 2.0
tau_unmarshall@Base 2.0
Expand Down Expand Up @@ -143,6 +144,7 @@ libtau.so.2 libtrdp2 #MINVER#
tau_readXmlMappedInterfaceConfig@Base 2.0
tau_readXmlServiceConfig@Base 2.0
tau_requestEcspConfirm@Base 2.0
tau_requestEcspConfirmReply@Base 2.0-111
tau_setEcspCtrl@Base 2.0
tau_terminateEcspCtrl@Base 2.0
tau_unmarshall@Base 2.0
Expand Down Expand Up @@ -328,6 +330,7 @@ libtrdp-hp.so.2 libtrdp2 #MINVER#
vos_divTime@Base 2.0
vos_dottedIP@Base 2.0
vos_getErrorString@Base 2.0
vos_getInterfaceIP@Base 2.0-111
vos_getInterfaces@Base 2.0
vos_getMacAddress@Base 2.0
vos_getNanoTime@Base 2.0
Expand Down Expand Up @@ -542,6 +545,7 @@ libtrdp.so.2 libtrdp2 #MINVER#
vos_divTime@Base 2.0
vos_dottedIP@Base 2.0
vos_getErrorString@Base 2.0
vos_getInterfaceIP@Base 2.0-111
vos_getInterfaces@Base 2.0
vos_getMacAddress@Base 2.0
vos_getNanoTime@Base 2.0
Expand Down
14 changes: 7 additions & 7 deletions trdp/src/common/tau_cstinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,20 @@
*/
UINT16 cstInfoGetPropSize (TRDP_CONSIST_INFO_T *pCstInfo)
{
return vos_ntohs(pCstInfo->cstProp.len);
return vos_ntohs(pCstInfo->pCstProp->len);
}

void cstInfoGetProperty (TRDP_CONSIST_INFO_T *pCstInfo,
UINT8 *pValue)
{
memcpy(pValue, pCstInfo->cstProp.prop, vos_ntohs(pCstInfo->cstProp.len));
memcpy(pValue, pCstInfo->pCstProp->prop, vos_ntohs(pCstInfo->pCstProp->len));
}

void cstInfoGetETBInfo (TRDP_CONSIST_INFO_T *pCstInfo,
UINT32 l_index,
TRDP_ETB_INFO_T *pValue)
{
UINT8 *pSrc = (UINT8 *)&pCstInfo->cstProp + vos_ntohs(pCstInfo->cstProp.len) + 4 + 2; /* pCstInfo->etbCnt */
UINT8 *pSrc = (UINT8 *)&pCstInfo->pCstProp + vos_ntohs(pCstInfo->pCstProp->len) + 4 + 2; /* pCstInfo->etbCnt */
UINT16 etbCnt = vos_ntohs(*pSrc);
TRDP_ETB_INFO_T *pCurInfo;
if (l_index> etbCnt)
Expand All @@ -89,15 +89,15 @@ UINT32 cstInfoGetVehInfoSize (UINT8 *pVehList)
plus size of properties
minus 4 bytes of static array element [0] */
return sizeof(TRDP_VEHICLE_INFO_T) +
(vos_ntohs(((TRDP_VEHICLE_INFO_T *)pVehList)->vehProp.len) * sizeof(TRDP_PROP_T) - 4);
(vos_ntohs(((TRDP_VEHICLE_INFO_T *)pVehList)->pVehProp->len) * sizeof(TRDP_PROP_T) - 4);
}

void cstInfoGetVehInfo (TRDP_CONSIST_INFO_T *pCstInfo,
UINT32 l_index,
TRDP_VEHICLE_INFO_T *pValue,
UINT32 *pSize)
{
UINT8 *pSrc = (UINT8 *)&pCstInfo->cstProp + vos_ntohs(pCstInfo->cstProp.len) + 4 + 2; /* pCstInfo->etbCnt */
UINT8 *pSrc = (UINT8 *)&pCstInfo->pCstProp + vos_ntohs(pCstInfo->pCstProp->len) + 4 + 2; /* pCstInfo->etbCnt */
UINT16 etbCnt = vos_ntohs(*pSrc);
UINT16 vehCnt;
UINT32 i;
Expand Down Expand Up @@ -125,7 +125,7 @@ void cstInfoGetFctInfo (TRDP_CONSIST_INFO_T *pCstInfo,
TRDP_FUNCTION_INFO_T *pValue,
UINT32 *pSize)
{
UINT8 *pSrc = (UINT8 *)&pCstInfo->cstProp + vos_ntohs(pCstInfo->cstProp.len) + 4 + 2; /* pCstInfo->etbCnt */
UINT8 *pSrc = (UINT8 *)&pCstInfo->pCstProp + vos_ntohs(pCstInfo->pCstProp->len) + 4 + 2; /* pCstInfo->etbCnt */
UINT16 etbCnt = vos_ntohs(*pSrc);
UINT16 vehCnt;
UINT16 fctCnt;
Expand Down Expand Up @@ -170,7 +170,7 @@ void cstInfoGetCltrCstInfo (
TRDP_FUNCTION_INFO_T *pValue,
UINT32 *pSize)
{
UINT8 *pSrc = (UINT8 *)&pCstInfo->cstProp + vos_ntohs(pCstInfo->cstProp.len) + 4 + 2; /* pCstInfo->etbCnt */
UINT8 *pSrc = (UINT8 *)&pCstInfo->pCstProp + vos_ntohs(pCstInfo->pCstProp->len) + 4 + 2; /* pCstInfo->etbCnt */
UINT16 etbCnt = vos_ntohs(*pSrc);
UINT16 vehCnt;
UINT16 fctCnt;
Expand Down
2 changes: 1 addition & 1 deletion trdp/src/common/tau_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ EXT_DECL TRDP_ERR_T tau_getEcspStat ( TRDP_APP_SESSION_T appHandle,
*
*/
EXT_DECL TRDP_ERR_T tau_requestEcspConfirm ( TRDP_APP_SESSION_T appHandle,
const void *pUserRef,
void *pUserRef,
TRDP_MD_CALLBACK_T pfCbFunction,
TRDP_ECSP_CONF_REQUEST_T *pEcspConfRequest)
{
Expand Down
2 changes: 1 addition & 1 deletion trdp/src/vos/posix/vos_sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#endif

#ifdef __linux
# include <linux/if.h>
# include <net/if.h>
# include <byteswap.h>
# include <linux/if_vlan.h>
# include <linux/sockios.h>
Expand Down
5 changes: 3 additions & 2 deletions trdp/test/diverse/mdDataLengthTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static TRDP_APP_SESSION_T test_init(
TRDP_TEST_SESSION_T *pSession,
const char * name,
TRDP_MEM_CONFIG_T *pMemConfig);
static void trdp_loop(void *pArg);
static void *trdp_loop(void *pArg);
static void test_deinit(
TRDP_TEST_SESSION_T *pSession1,
TRDP_TEST_SESSION_T *pSession2);
Expand All @@ -93,7 +93,7 @@ void mdTestCallback(
*
* @retval none
*/
static void trdp_loop(void *pArg)
static void *trdp_loop(void *pArg)
{
TRDP_TEST_SESSION_T *pSession = (TRDP_TEST_SESSION_T *)pArg;
/*
Expand Down Expand Up @@ -160,6 +160,7 @@ static void trdp_loop(void *pArg)

(void)tlc_closeSession(pSession->appHandle);
pSession->appHandle = NULL;
return NULL;
}

/**********************************************************************************************************************/
Expand Down
5 changes: 3 additions & 2 deletions trdp/test/diverse/pdMcRoutingTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static TRDP_APP_SESSION_T test_init(
TRDP_PRINT_DBG_T dbgout,
TRDP_TEST_SESSION_T *pSession,
const char * name);
static void trdp_loop(void *pArg);
static void *trdp_loop(void *pArg);
static void test_deinit(
TRDP_TEST_SESSION_T *pSession1,
TRDP_TEST_SESSION_T *pSession2);
Expand All @@ -99,7 +99,7 @@ static int receiveAndCheckData(TRDP_TEST_SESSION_T *pSession, UINT32 id);
*
* @retval none
*/
static void trdp_loop(void *pArg)
static void *trdp_loop(void *pArg)
{
TRDP_TEST_SESSION_T *pSession = (TRDP_TEST_SESSION_T *)pArg;
/*
Expand Down Expand Up @@ -166,6 +166,7 @@ static void trdp_loop(void *pArg)

(void)tlc_closeSession(pSession->appHandle);
pSession->appHandle = NULL;
return NULL;
}

/**********************************************************************************************************************/
Expand Down
8 changes: 5 additions & 3 deletions trdp/test/localtest/api_test_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ static void test_deinit (
*/


static int test1 ()
static __unused int test1 ()
{
PREPARE1("SRM offer ### obsolete! ###"); /* allocates appHandle1, failed = 0, err */

Expand Down Expand Up @@ -880,7 +880,9 @@ static int test3 ()
pdInfo.seqCount,
pdInfo.msgType >> 8,
pdInfo.msgType & 0xFF);
vos_printLog(VOS_LOG_USR, "Data: %*s\n", dataSize, buffer);
UINT8 logbuffer[248]; /* GCC is a bit bitchy about buffer checks and vos_printLog is limited. Be nice */
memcpy(logbuffer, buffer, dataSize>sizeof(logbuffer) ? sizeof(logbuffer) : dataSize);
vos_printLog(VOS_LOG_USR, "Data: %*s\n", dataSize>sizeof(logbuffer) ? (UINT32)sizeof(logbuffer) : dataSize, logbuffer);
//break;
}
else
Expand Down Expand Up @@ -968,7 +970,7 @@ static void test5CBFunction (
fprintf(gFp, "->> Unsolicited Message received (type = %c%c)\n", pMsg->msgType >> 8, pMsg->msgType & 0xFF);
gFailed = 1;
}
end:

return;
}

Expand Down
8 changes: 5 additions & 3 deletions trdp/test/localtest/api_test_4.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ TRDP_THREAD_SESSION_T gSession2 = {NULL, 0x0A000365u, 0, 0};
{ \
0x00, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF, 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF \
}
#define CST_1_ID "SBahn 150"
/* this is used as TRDP_LABEL_T, so it must be filled up to the full expected length */
#define CST_1_ID "SBahn 150\0\0\0\0\0\0\0"

#define CST_2_UUID \
{ \
Expand Down Expand Up @@ -641,7 +642,7 @@ static void dbgOut(
*
* @retval none
*/
static void trdp_loop(void *pArg)
static void *trdp_loop(void *pArg)
{
TRDP_THREAD_SESSION_T *pSession = (TRDP_THREAD_SESSION_T *)pArg;
/*
Expand Down Expand Up @@ -708,6 +709,7 @@ static void trdp_loop(void *pArg)

(void)tlc_closeSession(pSession->appHandle);
pSession->appHandle = NULL;
return NULL;
}

/**********************************************************************************************************************/
Expand Down Expand Up @@ -1442,7 +1444,7 @@ static int test3()
memset(&expectedVehInfo, 0, sizeof(expectedVehInfo));
memcpy(&expectedVehInfo, &gCstInfo.test_ar_VehInfoList[counter], sizeof(gCstInfo.test_ar_VehInfoList[counter]));

expectedVehInfo.vehProp.len = SWAP_16(expectedVehInfo.vehProp.len);
expectedVehInfo.pVehProp->len = SWAP_16(expectedVehInfo.pVehProp->len);

/** @TODO: check, if Padding needs to be considered */
if (memcmp(&expectedVehInfo, &consistInfo.pVehInfoList[counter], sizeof(TRDP_VEHICLE_INFO_T)) != 0)
Expand Down

0 comments on commit 6a30c10

Please sign in to comment.