Skip to content

Commit ea7cff0

Browse files
authored
Merge pull request #1197 from jphickey/fix-1189-fix-compiler-warnings
Fix #1189, correct compiler warnings
2 parents aded3e4 + 54adb9f commit ea7cff0

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

fsw/cfe-core/src/inc/private/cfe_sbr.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
#include "cfe_msg_typedefs.h"
3939
#include "cfe_platform_cfg.h"
4040

41+
/*
42+
* Macro Definitions
43+
*/
44+
45+
/** \brief Invalid route id */
46+
#define CFE_SBR_INVALID_ROUTE_ID ((CFE_SBR_RouteId_t) {.RouteId = 0})
47+
4148
/******************************************************************************
4249
* Type Definitions
4350
*/

fsw/cfe-core/src/sb/cfe_sb_api.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,7 @@ int32 CFE_SB_TransmitMsg(CFE_MSG_Message_t *MsgPtr, bool IncrementSequenceCount
13971397

13981398
PendingEventID = 0;
13991399
BufDscPtr = NULL;
1400+
RouteId = CFE_SBR_INVALID_ROUTE_ID;
14001401

14011402
Status = CFE_SB_TransmitMsgValidate(MsgPtr, &MsgId, &Size, &RouteId);
14021403

@@ -1886,6 +1887,7 @@ int32 CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr,
18861887
BufDscPtr = NULL;
18871888
DestPtr = NULL;
18881889
BufDscSize = 0;
1890+
RcvStatus = OS_SUCCESS;
18891891

18901892
/*
18911893
* Check input args and see if any are bad, which require

fsw/cfe-core/src/sb/cfe_sb_priv.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,7 @@ void CFE_SB_RemoveDestNode(CFE_SBR_RouteId_t RouteId, CFE_SB_DestinationD_t *Nod
536536
int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_AppId_t AppId)
537537
{
538538
CFE_SB_BufferLink_t *NextLink;
539-
540-
/* Using a union type permits promotion of CFE_SB_BufferLink_t* to CFE_SB_BufferD_t*
541-
* without violating aliasing rules or alignment rules. Note that the first element
542-
* of CFE_SB_BufferD_t is a CFE_SB_BufferLink_t, which makes this possible. */
543-
union LocalBufDesc
544-
{
545-
CFE_SB_BufferLink_t As_Link;
546-
CFE_SB_BufferD_t As_Dsc;
547-
} *BufPtr;
539+
CFE_SB_BufferD_t *DscPtr;
548540

549541
/*
550542
* First go through the "ZeroCopy" tracking list and find all nodes
@@ -560,16 +552,18 @@ int32 CFE_SB_ZeroCopyReleaseAppId(CFE_ES_AppId_t AppId)
560552
while(!CFE_SB_TrackingListIsEnd(&CFE_SB_Global.ZeroCopyList, NextLink))
561553
{
562554
/* Get buffer descriptor pointer */
563-
BufPtr = (union LocalBufDesc*)NextLink;
555+
/* NOTE: casting via void* here rather than CFE_SB_BufferD_t* avoids a false
556+
* alignment warning on platforms with strict alignment requirements */
557+
DscPtr = (void *)NextLink;
564558

565559
/* Read the next link now in case this node gets moved */
566560
NextLink = CFE_SB_TrackingListGetNext(NextLink);
567561

568562
/* Check if it is a zero-copy buffer owned by this app */
569-
if (CFE_RESOURCEID_TEST_EQUAL(BufPtr->As_Dsc.AppId, AppId))
563+
if (CFE_RESOURCEID_TEST_EQUAL(DscPtr->AppId, AppId))
570564
{
571565
/* If so, decrement the use count as the app has now gone away */
572-
CFE_SB_DecrBufUseCnt(&BufPtr->As_Dsc);
566+
CFE_SB_DecrBufUseCnt(DscPtr);
573567
}
574568
}
575569

modules/sbr/private_inc/cfe_sbr_priv.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
*/
3232
#include "private/cfe_sbr.h"
3333

34-
/*
35-
* Macro Definitions
36-
*/
37-
38-
/** \brief Invalid route id */
39-
#define CFE_SBR_INVALID_ROUTE_ID ((CFE_SBR_RouteId_t) {.RouteId = 0})
4034

4135
/******************************************************************************
4236
* Function prototypes

0 commit comments

Comments
 (0)