Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC CI Build Fixes #1861

Draft
wants to merge 31 commits into
base: develop-pre-1.11.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6a90f4c
Update ci.yml
stefankiesz Nov 29, 2023
5091419
Remove pedantic errors from compile options
stefankiesz Nov 29, 2023
09eddd1
Add -Wpedantic
stefankiesz Nov 29, 2023
d62fdd6
add -Wno-error=pedantic
stefankiesz Nov 29, 2023
7db983f
remove pedantic
stefankiesz Nov 29, 2023
ca1025f
Add SYSTEM to suppress dependency gcc warnings
stefankiesz Dec 6, 2023
0ed7f1e
Check wBioDataLen negative as a long instead of uint
stefankiesz Dec 6, 2023
cc75751
Fix explicit fall-through comment to be caught by gcc
stefankiesz Dec 6, 2023
de912e0
Trying new fall-through comment
stefankiesz Dec 6, 2023
ae0a3b0
Isolating mac builds for testing
stefankiesz Dec 6, 2023
95da6ad
Remove unused retStatus declaration
stefankiesz Dec 6, 2023
d2e2853
Reverted removing retstatus, changed to return successful retstatus
stefankiesz Dec 6, 2023
9c3a3f6
Add default case for NatBehaviorStr
stefankiesz Dec 7, 2023
caa436d
Switch to signed int for >=0 evaluation
stefankiesz Dec 7, 2023
d2fb602
Switch to INT32
stefankiesz Dec 7, 2023
018df56
Remove unused variable "sendStatus"
stefankiesz Dec 7, 2023
d37d1fa
Cast variables to void to avoid "set but not used" errors
stefankiesz Dec 7, 2023
aa993ca
Change SPRINTF to SNPRINTF
stefankiesz Dec 7, 2023
d8c3b35
Add buffer length to SessionDescription.c
stefankiesz Dec 7, 2023
bd680a3
Add back accidentally removed code block
stefankiesz Dec 7, 2023
547e1ea
Comment out most of cmakelists to speedup testing
stefankiesz Dec 7, 2023
d5d3b15
Revert "Comment out most of cmakelists to speedup testing"
stefankiesz Dec 7, 2023
eed8ba5
Cast numeric macro to uint
stefankiesz Dec 7, 2023
7bf70f4
Change what is casted in prev commit
stefankiesz Dec 7, 2023
88eeb56
Cast to uint in Stun.c
stefankiesz Dec 7, 2023
ed381da
Fix comment "\", >=0 uint checks, cast to uint, remove retstatus
stefankiesz Dec 7, 2023
61dc9cd
Add back retStatus
stefankiesz Dec 8, 2023
ebfb11f
Change from (void) to UNUSED_PARAM()
stefankiesz Dec 8, 2023
b315e66
Cast resStatus to void in cleanup
stefankiesz Dec 8, 2023
1013018
Update Tls_openssl.c
stefankiesz Dec 8, 2023
254f5a3
CLANG format
stefankiesz Dec 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
375 changes: 363 additions & 12 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

39 changes: 31 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ elseif(USE_MBEDTLS)
message(STATUS "Detected gcc")
set(CMAKE_C_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_CXX_FLAGS}")
# set(CMAKE_C_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_C_FLAGS}")
# set(CMAKE_CXX_FLAGS "-Wno-error=stringop-overflow -I${CMAKE_CURRENT_SOURCE_DIR}/configs -DMBEDTLS_USER_CONFIG_FILE=\"<config_mbedtls.h>\" ${CMAKE_CXX_FLAGS}")
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER "7.0")
set(CMAKE_C_FLAGS "-Wno-error=stringop-overflow ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wno-error=stringop-overflow ${CMAKE_CXX_FLAGS}")
Expand All @@ -141,11 +143,31 @@ elseif(USE_MBEDTLS)
endif()
endif()


if(BUILD_DEPENDENCIES)
if(NOT EXISTS ${OPEN_SRC_INSTALL_PREFIX})
file(MAKE_DIRECTORY ${OPEN_SRC_INSTALL_PREFIX})
if(WIN32)
set(OPENSSL_INCLUDE_DIRS "${OPEN_SRC_INSTALL_PREFIX}/include/")
set(OPENSSL_CRYPTO_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libcrypto.lib")
set(OPENSSL_SSL_LIBRARY "${OPEN_SRC_INSTALL_PREFIX}/lib/libssl.lib")
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
string(REPLACE ";" "|" OPENSSL_LIBRARIES_ALT_SEP "${OPENSSL_LIBRARIES}")
set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DUSE_OPENSSL=${USE_OPENSSL}
-DUSE_MBEDTLS=${USE_MBEDTLS}
-DLWS_EXT_PTHREAD_INCLUDE_DIR=${EXT_PTHREAD_INCLUDE_DIR}
-DLWS_EXT_PTHREAD_LIBRARIES=${EXT_PTHREAD_LIBRARIES}
-DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIRS}
-DLWS_OPENSSL_LIBRARIES=${OPENSSL_LIBRARIES_ALT_SEP}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
else()
set(BUILD_ARGS -DBUILD_STATIC_LIBS=${BUILD_STATIC_LIBS}
-DOPENSSL_DIR=${OPEN_SRC_INSTALL_PREFIX}
-DUSE_OPENSSL=${USE_OPENSSL}
-DUSE_MBEDTLS=${USE_MBEDTLS}
-DLWS_OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
-DLWS_OPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY}
-DLWS_OPENSSL_INCLUDE_DIRS=${OPENSSL_INCLUDE_DIR}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS})
endif()
build_dependency(websockets ${BUILD_ARGS})

set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${OPEN_SRC_INSTALL_PREFIX}/lib/pkgconfig")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${OPEN_SRC_INSTALL_PREFIX})
Expand Down Expand Up @@ -385,8 +407,9 @@ endif()

file(GLOB WEBRTC_SIGNALING_CLIENT_SOURCE_FILES "src/source/Signaling/*.c")

include_directories(${OPEN_SRC_INCLUDE_DIRS})
include_directories(${OPEN_SRC_INSTALL_PREFIX}/include)

include_directories(SYSTEM ${OPEN_SRC_INCLUDE_DIRS})
include_directories(SYSTEM ${OPEN_SRC_INSTALL_PREFIX}/include)
include_directories(${KINESIS_VIDEO_WEBRTC_CLIENT_SRC}/src/include)
# include sdp_config.h
include_directories(src/source/Sdp/kvssdp)
Expand Down Expand Up @@ -446,8 +469,8 @@ if (WIN32)
endif()

if(COMPILER_WARNINGS)
target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option)
target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -pedantic -Wextra -Wno-unknown-warning-option)
target_compile_options(kvsWebrtcClient PUBLIC -Wall -Werror -Wextra -Wno-unknown-warning-option)
target_compile_options(kvsWebrtcSignalingClient PUBLIC -Wall -Werror -Wextra -Wno-unknown-warning-option)
endif()

install(TARGETS kvsWebrtcClient kvsWebrtcSignalingClient
Expand Down
8 changes: 6 additions & 2 deletions src/source/Crypto/Tls_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ STATUS tlsSessionPutApplicationData(PTlsSession pTlsSession, PBYTE pData, UINT32

SIZE_T wBioDataLen = 0;
PCHAR wBioBuffer = NULL;
LONG wBioGetMemDataRet = 0;

CHK(pTlsSession != NULL, STATUS_NULL_ARG);

Expand All @@ -212,8 +213,11 @@ STATUS tlsSessionPutApplicationData(PTlsSession pTlsSession, PBYTE pData, UINT32
}
}

wBioDataLen = (SIZE_T) BIO_get_mem_data(SSL_get_wbio(pTlsSession->pSsl), &wBioBuffer);
CHK_ERR(wBioDataLen >= 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed");
wBioGetMemDataRet = BIO_get_mem_data(SSL_get_wbio(pTlsSession->pSsl), &wBioBuffer);
CHK_ERR(wBioGetMemDataRet != 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed with: no BIO was connected to the SSL object.");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: "0" is an error, was being treated as a non-error prior to these changes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BIO_get_mem_data() returns the total number of bytes available on success, 0 if b is NULL, or a negative value in case of other errors.

CHK_ERR(wBioGetMemDataRet > 0, STATUS_SEND_DATA_FAILED, "BIO_get_mem_data failed");

wBioDataLen = (SIZE_T) wBioGetMemDataRet;

if (wBioDataLen > 0) {
retStatus =
Expand Down
2 changes: 1 addition & 1 deletion src/source/Ice/IceAgent.c
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,7 @@ STATUS iceAgentCheckCandidatePairConnection(PIceAgent pIceAgent)
switch (pIceCandidatePair->state) {
case ICE_CANDIDATE_PAIR_STATE_WAITING:
pIceCandidatePair->state = ICE_CANDIDATE_PAIR_STATE_IN_PROGRESS;
// NOTE: Explicit fall-through
/* FALLTHRU */
case ICE_CANDIDATE_PAIR_STATE_IN_PROGRESS:
CHK_STATUS(iceCandidatePairCheckConnection(pIceAgent->pBindingRequest, pIceAgent, pIceCandidatePair));
break;
Expand Down
3 changes: 3 additions & 0 deletions src/source/Ice/NatBehaviorDiscovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,5 +380,8 @@ PCHAR getNatBehaviorStr(NAT_BEHAVIOR natBehavior)
return NAT_BEHAVIOR_ADDRESS_DEPENDENT_STR;
case NAT_BEHAVIOR_PORT_DEPENDENT:
return NAT_BEHAVIOR_PORT_DEPENDENT_STR;
default:
// NOTE: This should be properly handled with something like "NAT_BEHAVIOR_UNDEFINED"
return NAT_BEHAVIOR_NONE_STR;
}
}
2 changes: 1 addition & 1 deletion src/source/Ice/Network.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ STATUS socketWrite(INT32 sockfd, const void* pBuffer, SIZE_T length)
BOOL isIpAddr(PCHAR hostname, UINT16 length)
{
BOOL status = TRUE;
UINT32 ip_1, ip_2, ip_3, ip_4, ip_5, ip_6, ip_7, ip_8;
INT32 ip_1, ip_2, ip_3, ip_4, ip_5, ip_6, ip_7, ip_8;
if (hostname == NULL || length > MAX_ICE_CONFIG_URI_LEN) {
DLOGW("Provided NULL hostname");
status = FALSE;
Expand Down
13 changes: 6 additions & 7 deletions src/source/Ice/TurnConnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ BOOL turnConnectionGetRelayAddress(PTurnConnection pTurnConnection, PKvsIpAddres

STATUS checkTurnPeerConnections(PTurnConnection pTurnConnection)
{
STATUS retStatus = STATUS_SUCCESS, sendStatus = STATUS_SUCCESS;
STATUS retStatus = STATUS_SUCCESS;
PTurnPeer pTurnPeer = NULL;
PStunAttributeAddress pStunAttributeAddress = NULL;
PStunAttributeChannelNumber pStunAttributeChannelNumber = NULL;
Expand All @@ -1054,9 +1054,9 @@ STATUS checkTurnPeerConnections(PTurnConnection pTurnConnection)

CHK(pTurnPeer->pTransactionIdStore != NULL, STATUS_INVALID_OPERATION);
transactionIdStoreInsert(pTurnPeer->pTransactionIdStore, pTurnConnection->pTurnCreatePermissionPacket->header.transactionId);
sendStatus = iceUtilsSendStunPacket(pTurnConnection->pTurnCreatePermissionPacket, pTurnConnection->longTermKey,
ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress,
pTurnConnection->pControlChannel, NULL, FALSE);
iceUtilsSendStunPacket(pTurnConnection->pTurnCreatePermissionPacket, pTurnConnection->longTermKey,
ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress, pTurnConnection->pControlChannel,
NULL, FALSE);

} else if (pTurnPeer->connectionState == TURN_PEER_CONN_STATE_BIND_CHANNEL) {
if (pTurnPeer->firstTimeBindChannelReq) {
Expand All @@ -1080,9 +1080,8 @@ STATUS checkTurnPeerConnections(PTurnConnection pTurnConnection)

CHK(pTurnPeer->pTransactionIdStore != NULL, STATUS_INVALID_OPERATION);
transactionIdStoreInsert(pTurnPeer->pTransactionIdStore, pTurnConnection->pTurnChannelBindPacket->header.transactionId);
sendStatus = iceUtilsSendStunPacket(pTurnConnection->pTurnChannelBindPacket, pTurnConnection->longTermKey,
ARRAY_SIZE(pTurnConnection->longTermKey), &pTurnConnection->turnServer.ipAddress,
pTurnConnection->pControlChannel, NULL, FALSE);
iceUtilsSendStunPacket(pTurnConnection->pTurnChannelBindPacket, pTurnConnection->longTermKey, ARRAY_SIZE(pTurnConnection->longTermKey),
&pTurnConnection->turnServer.ipAddress, pTurnConnection->pControlChannel, NULL, FALSE);
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/source/PeerConnection/Rtcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ static STATUS onRtcpReceiverReport(PRtcpPacket pRtcpPacket, PKvsPeerConnection p
pTransceiver->remoteInboundStats.roundTripTime = rttPropDelayMsec;
MUTEX_UNLOCK(pTransceiver->statsLock);

// Cast to void to avoid "set but not used" warning
UNUSED_PARAM(senderSSRC);
UNUSED_PARAM(cumulativeLost);
UNUSED_PARAM(extHiSeqNumReceived);
UNUSED_PARAM(interarrivalJitter);

CleanUp:

return retStatus;
Expand Down
3 changes: 2 additions & 1 deletion src/source/PeerConnection/SessionDescription.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
UINT64 payloadType, rtxPayloadType;
BOOL containRtx = FALSE;
BOOL directionFound = FALSE;
UINT32 i, remoteAttributeCount, attributeCount = 0;
UINT32 i, remoteAttributeCount, attributeCount, attributeNameBuffLen, amountWritten = 0;
PRtcMediaStreamTrack pRtcMediaStreamTrack = &(pKvsRtpTransceiver->sender.track);
PSdpMediaDescription pSdpMediaDescriptionRemote;
PCHAR currentFmtp = NULL, rtpMapValue = NULL;
Expand Down Expand Up @@ -450,6 +450,7 @@ STATUS populateSingleMediaSection(PKvsPeerConnection pKvsPeerConnection, PKvsRtp
CHK_STATUS(iceAgentPopulateSdpMediaDescriptionCandidates(pKvsPeerConnection->pIceAgent, pSdpMediaDescription, MAX_SDP_ATTRIBUTE_VALUE_LENGTH,
&attributeCount));

attributeNameBuffLen = SIZEOF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName);
if (containRtx) {
STRCPY(pSdpMediaDescription->sdpAttributes[attributeCount].attributeName, "msid");
amountWritten = SNPRINTF(pSdpMediaDescription->sdpAttributes[attributeCount].attributeValue,
Expand Down
2 changes: 1 addition & 1 deletion src/source/Rtcp/RtcpPacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ STATUS setRtcpPacketFromBytes(PBYTE pRawPacket, UINT32 pRawPacketsLen, PRtcpPack
// We don't assert exact length since this may be a compound packet, it
// is the callers responsibility to parse subsequent entries
packetLen = getInt16(*(PUINT16) (pRawPacket + RTCP_PACKET_LEN_OFFSET));
CHK((packetLen + 1) * RTCP_PACKET_LEN_WORD_SIZE <= pRawPacketsLen, STATUS_RTCP_INPUT_PARTIAL_PACKET);
CHK((UINT16) ((packetLen + 1) * RTCP_PACKET_LEN_WORD_SIZE) <= pRawPacketsLen, STATUS_RTCP_INPUT_PARTIAL_PACKET);

pRtcpPacket->header.version = (pRawPacket[0] >> VERSION_SHIFT) & VERSION_MASK;
CHK(pRtcpPacket->header.version == RTCP_PACKET_VERSION_VAL, STATUS_RTCP_INPUT_PACKET_INVALID_VERSION);
Expand Down
16 changes: 9 additions & 7 deletions src/source/Sctp/Sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ STATUS sctpSessionWriteMessage(PSctpSession pSctpSession, UINT32 streamId, BOOL
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | Label Length | Protocol Length |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// \ /
// | |
// | Label |
// / \
// | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// \ /
// | |
// | Protocol |
// / \
// | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
STATUS sctpSessionWriteDcep(PSctpSession pSctpSession, UINT32 streamId, PCHAR pChannelName, UINT32 pChannelNameLen,
PRtcDataChannelInit pRtcDataChannelInit)
Expand Down Expand Up @@ -246,10 +246,10 @@ STATUS sctpSessionWriteDcep(PSctpSession pSctpSession, UINT32 streamId, PCHAR pC
if (!pRtcDataChannelInit->ordered) {
pSctpSession->packet[1] |= DCEP_DATA_CHANNEL_RELIABLE_UNORDERED;
}
if (pRtcDataChannelInit->maxRetransmits.value >= 0 && pRtcDataChannelInit->maxRetransmits.isNull == FALSE) {
if (pRtcDataChannelInit->maxRetransmits.isNull == FALSE) {
pSctpSession->packet[1] |= DCEP_DATA_CHANNEL_REXMIT;
putUnalignedInt32BigEndian(pSctpSession->packet + SIZEOF(UINT32), pRtcDataChannelInit->maxRetransmits.value);
} else if (pRtcDataChannelInit->maxPacketLifeTime.value >= 0 && pRtcDataChannelInit->maxPacketLifeTime.isNull == FALSE) {
} else if (pRtcDataChannelInit->maxPacketLifeTime.isNull == FALSE) {
pSctpSession->packet[1] |= DCEP_DATA_CHANNEL_TIMED;
putUnalignedInt32BigEndian(pSctpSession->packet + SIZEOF(UINT32), pRtcDataChannelInit->maxPacketLifeTime.value);
}
Expand Down Expand Up @@ -315,7 +315,7 @@ STATUS handleDcepPacket(PSctpSession pSctpSession, UINT32 streamId, PBYTE data,
putInt16((PINT16) &labelLength, labelLength);
putInt16((PINT16) &protocolLength, protocolLength);

CHK((labelLength + protocolLength + SCTP_DCEP_HEADER_LENGTH) >= length, STATUS_SCTP_INVALID_DCEP_PACKET);
CHK((UINT16) (labelLength + protocolLength + SCTP_DCEP_HEADER_LENGTH) >= length, STATUS_SCTP_INVALID_DCEP_PACKET);

CHK(SCTP_MAX_ALLOWABLE_PACKET_LENGTH >= length, STATUS_SCTP_INVALID_DCEP_PACKET);

Expand Down Expand Up @@ -358,6 +358,8 @@ INT32 onSctpInboundPacket(struct socket* sock, union sctp_sockstore addr, PVOID

CleanUp:

UNUSED_PARAM(retStatus);

/*
* IMPORTANT!!! The allocation is done in the sctp library using default allocator
* so we need to use the default free API.
Expand Down
2 changes: 1 addition & 1 deletion src/source/Stun/Stun.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ STATUS deserializeStunPacket(PBYTE pStunBuffer, UINT32 bufferSize, PBYTE passwor
magicCookie = (UINT32) getInt32(*(PUINT32) ((PBYTE) pStunHeader + STUN_HEADER_TYPE_LEN + STUN_HEADER_DATA_LEN));

// Validate the specified size
CHK(bufferSize >= messageLength + STUN_HEADER_LEN, STATUS_INVALID_ARG);
CHK(bufferSize >= (UINT16) (messageLength + STUN_HEADER_LEN), STATUS_INVALID_ARG);

// Validate the magic cookie
CHK(magicCookie == STUN_HEADER_MAGIC_COOKIE, STATUS_STUN_MAGIC_COOKIE_MISMATCH);
Expand Down
Loading