@@ -1397,7 +1397,7 @@ uint32 CFE_ES_CalculateCRC(const void *DataPtr, uint32 DataLength, uint32 InputC
1397
1397
** Purpose: Allocate a data block for a Critical Data Store.
1398
1398
**
1399
1399
*/
1400
- int32 CFE_ES_RegisterCDS (CFE_ES_CDSHandle_t * CDSHandlePtr , int32 BlockSize , const char * Name )
1400
+ int32 CFE_ES_RegisterCDS (CFE_ES_CDSHandle_t * CDSHandlePtr , CFE_ES_CDS_Offset_t BlockSize , const char * Name )
1401
1401
{
1402
1402
int32 Status ;
1403
1403
size_t NameLen = 0 ;
@@ -1406,14 +1406,17 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, int32 BlockSize, cons
1406
1406
char AppName [OS_MAX_API_NAME ] = {"UNKNOWN" };
1407
1407
char CDSName [CFE_ES_CDS_MAX_FULL_NAME_LEN ] = {"" };
1408
1408
1409
+ /* Initialize output to safe value, in case this fails */
1410
+ * CDSHandlePtr = CFE_ES_RESOURCEID_UNDEFINED ;
1411
+
1409
1412
/* Check to make sure calling application is legit */
1410
1413
Status = CFE_ES_GetAppID (& ThisAppId );
1411
1414
1412
1415
if ( Status != CFE_SUCCESS ) /* Application ID was invalid */
1413
1416
{
1414
1417
CFE_ES_WriteToSysLog ("CFE_CDS:Register-Bad AppId context\n" );
1415
1418
}
1416
- else if (CFE_ES_Global .CDSVars . MemPoolSize == 0 )
1419
+ else if (! CFE_ES_Global .CDSIsAvailable )
1417
1420
{
1418
1421
CFE_ES_WriteToSysLog ("CFE_CDS:Register-CDS not available\n" );
1419
1422
Status = CFE_ES_NOT_IMPLEMENTED ;
@@ -1441,16 +1444,13 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, int32 BlockSize, cons
1441
1444
/* of the form "AppName.Name" */
1442
1445
CFE_ES_FormCDSName (CDSName , Name , ThisAppId );
1443
1446
1444
- /* Make sure the specified size is acceptable */
1445
- if (BlockSize == 0 )
1446
- {
1447
- Status = CFE_ES_CDS_INVALID_SIZE ;
1448
- CFE_ES_WriteToSysLog ("CFE_CDS:Register-CDS %s has size of zero\n" , Name );
1449
- }
1450
- else
1447
+ /* Create CDS and designate it as NOT being a Critical Table */
1448
+ Status = CFE_ES_RegisterCDSEx (CDSHandlePtr , BlockSize , CDSName , false);
1449
+
1450
+ /* If size is unacceptable, log it */
1451
+ if (Status == CFE_ES_CDS_INVALID_SIZE )
1451
1452
{
1452
- /* Create CDS and designate it as NOT being a Critical Table */
1453
- Status = CFE_ES_RegisterCDSEx (CDSHandlePtr , BlockSize , CDSName , false);
1453
+ CFE_ES_WriteToSysLog ("CFE_CDS:Register-CDS %s has invalid size (%lu)\n" , Name , (unsigned long )BlockSize );
1454
1454
}
1455
1455
}
1456
1456
}
@@ -1479,11 +1479,7 @@ int32 CFE_ES_RegisterCDS(CFE_ES_CDSHandle_t *CDSHandlePtr, int32 BlockSize, cons
1479
1479
*/
1480
1480
int32 CFE_ES_CopyToCDS (CFE_ES_CDSHandle_t Handle , void * DataToCopy )
1481
1481
{
1482
- int32 Status ;
1483
-
1484
- Status = CFE_ES_CDSBlockWrite (CFE_ES_Global .CDSVars .Registry [Handle ].MemHandle , DataToCopy );
1485
-
1486
- return Status ;
1482
+ return CFE_ES_CDSBlockWrite (Handle , DataToCopy );
1487
1483
} /* End of CFE_ES_CopyToCDS() */
1488
1484
1489
1485
/*
@@ -1494,11 +1490,7 @@ int32 CFE_ES_CopyToCDS(CFE_ES_CDSHandle_t Handle, void *DataToCopy)
1494
1490
*/
1495
1491
int32 CFE_ES_RestoreFromCDS (void * RestoreToMemory , CFE_ES_CDSHandle_t Handle )
1496
1492
{
1497
- int32 Status ;
1498
-
1499
- Status = CFE_ES_CDSBlockRead (RestoreToMemory , CFE_ES_Global .CDSVars .Registry [Handle ].MemHandle );
1500
-
1501
- return Status ;
1493
+ return CFE_ES_CDSBlockRead (RestoreToMemory , Handle );
1502
1494
} /* End of CFE_ES_RestoreFromCDS() */
1503
1495
1504
1496
/* end of file */
0 commit comments