Skip to content

Commit cbbea35

Browse files
committed
Some local fixes to RL: nullptr and formatting.
1 parent 0520235 commit cbbea35

File tree

1 file changed

+79
-76
lines changed

1 file changed

+79
-76
lines changed

bin/rl/rl.cpp

Lines changed: 79 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,27 +3514,30 @@ FindTest(
35143514
}
35153515

35163516
BOOL
3517-
IsTimeoutStringValid(const char *strTimeout) {
3518-
char *end;
3519-
_set_errno(0);
3517+
IsTimeoutStringValid(const char *strTimeout)
3518+
{
3519+
char *end;
3520+
_set_errno(0);
35203521

3521-
uint32 secTimeout = strtoul(strTimeout, &end, 10);
3522+
uint32 secTimeout = strtoul(strTimeout, &end, 10);
35223523

3523-
if (errno != 0 || *end != 0) {
3524-
return FALSE;
3525-
}
3524+
if (errno != 0 || *end != 0)
3525+
{
3526+
return FALSE;
3527+
}
35263528

3527-
// Check to see if the value is too large and would cause overflow
3529+
// Check to see if the value is too large and would cause overflow
35283530

3529-
// Do the multiplication using 64-bit unsigned math.
3530-
unsigned __int64 millisecTimeout = 1000ui64 * static_cast<unsigned __int64>(secTimeout);
3531+
// Do the multiplication using 64-bit unsigned math.
3532+
unsigned __int64 millisecTimeout = 1000ui64 * static_cast<unsigned __int64>(secTimeout);
35313533

3532-
// Does the result fit in 32-bits?
3533-
if (millisecTimeout >= (1ui64 << 32)) {
3534-
return FALSE;
3535-
}
3534+
// Does the result fit in 32-bits?
3535+
if (millisecTimeout >= (1ui64 << 32))
3536+
{
3537+
return FALSE;
3538+
}
35363539

3537-
return TRUE;
3540+
return TRUE;
35383541
}
35393542

35403543
uint32 GetTimeoutValue(const char *strTimeout)
@@ -3553,79 +3556,79 @@ uint32 GetTimeoutValue(const char *strTimeout)
35533556
BOOL
35543557
GetTestInfoFromNode
35553558
(
3556-
const char * fileName,
3557-
Xml::Node * node,
3558-
TestInfo * testInfo
3559+
const char * fileName,
3560+
Xml::Node * node,
3561+
TestInfo * testInfo
35593562
)
35603563
{
3561-
if (node == NULL)
3562-
{
3563-
return TRUE;
3564-
}
3565-
3566-
for (int i = 0; i < _TIK_COUNT; i++)
3567-
{
3568-
Xml::Node * childNode = node->GetChild(TestInfoKindName[i]);
3569-
if (childNode != NULL)
3570-
{
3571-
testInfo->hasData[i] = TRUE;
3572-
if (i == TIK_ENV)
3573-
{
3574-
ASSERT(childNode->ChildList != NULL);
3575-
testInfo->data[i] = (char*)childNode;
3576-
}
3577-
else
3578-
{
3579-
if (childNode->ChildList != NULL)
3580-
{
3581-
CFG_ERROR_EX(fileName, node->LineNumber,
3582-
"Expected data, not child list\n", NULL);
3583-
childNode->Dump();
3584-
return FALSE;
3585-
}
3564+
if (node == nullptr)
3565+
{
3566+
return TRUE;
3567+
}
35863568

3587-
if (childNode->Data != NULL && childNode->Data[0] != '\0')
3569+
for (int i = 0; i < _TIK_COUNT; i++)
3570+
{
3571+
Xml::Node * childNode = node->GetChild(TestInfoKindName[i]);
3572+
if (childNode != nullptr)
3573+
{
3574+
testInfo->hasData[i] = TRUE;
3575+
if (i == TIK_ENV)
35883576
{
3589-
char * data = childNode->Data;
3590-
if (i == TIK_SOURCE_PATH && IsRelativePath(childNode->Data))
3591-
{
3592-
// Make sure sourcepath is not relative, if relative make it full path
3593-
data = MakeFullPath(fileName, data);
3594-
ASSERT(data != NULL);
3595-
}
3596-
testInfo->data[i] = data;
3577+
ASSERT(childNode->ChildList != nullptr);
3578+
testInfo->data[i] = (char*)childNode;
35973579
}
35983580
else
35993581
{
3600-
testInfo->data[i] = NULL;
3582+
if (childNode->ChildList != nullptr)
3583+
{
3584+
CFG_ERROR_EX(fileName, node->LineNumber,
3585+
"Expected data, not child list\n", nullptr);
3586+
childNode->Dump();
3587+
return FALSE;
3588+
}
3589+
3590+
if (childNode->Data != nullptr && childNode->Data[0] != '\0')
3591+
{
3592+
char * data = childNode->Data;
3593+
if (i == TIK_SOURCE_PATH && IsRelativePath(childNode->Data))
3594+
{
3595+
// Make sure sourcepath is not relative, if relative make it full path
3596+
data = MakeFullPath(fileName, data);
3597+
ASSERT(data != nullptr);
3598+
}
3599+
testInfo->data[i] = data;
3600+
}
3601+
else
3602+
{
3603+
testInfo->data[i] = nullptr;
3604+
}
3605+
3606+
if (i == TIK_TIMEOUT)
3607+
{
3608+
// Validate the timeout string now to fail early so we don't run any tests when there is an error.
3609+
if (!IsTimeoutStringValid(testInfo->data[i])) {
3610+
CFG_ERROR_EX(fileName, node->LineNumber,
3611+
"Invalid timeout specified. Cannot parse or too large.\n", nullptr);
3612+
childNode->Dump();
3613+
return FALSE;
3614+
}
3615+
}
36013616
}
3617+
}
36023618

3603-
if (i == TIK_TIMEOUT)
3619+
if (i == TIK_TIMEOUT && TestTimeout != nullptr)
3620+
{
3621+
// Overriding the timeout value with the command line value (if the command line value is larger)
3622+
uint32 xmlTimeoutValue = GetTimeoutValue(testInfo->data[i]);
3623+
uint32 testTimeoutValue = GetTimeoutValue(TestTimeout);
3624+
if (xmlTimeoutValue < testTimeoutValue)
36043625
{
3605-
// Validate the timeout string now to fail early so we don't run any tests when there is an error.
3606-
if (!IsTimeoutStringValid(testInfo->data[i])) {
3607-
CFG_ERROR_EX(fileName, node->LineNumber,
3608-
"Invalid timeout specified. Cannot parse or too large.\n", NULL);
3609-
childNode->Dump();
3610-
return FALSE;
3611-
}
3626+
testInfo->data[i] = TestTimeout;
36123627
}
3613-
}
3614-
}
3615-
3616-
if (i == TIK_TIMEOUT && TestTimeout != nullptr)
3617-
{
3618-
// Overriding the timeout value with the command line value (if the command line value is larger)
3619-
uint32 xmlTimeoutValue = GetTimeoutValue(testInfo->data[i]);
3620-
uint32 testTimeoutValue = GetTimeoutValue(TestTimeout);
3621-
if (xmlTimeoutValue < testTimeoutValue)
3622-
{
3623-
testInfo->data[i] = TestTimeout;
3624-
}
3625-
}
3626-
}
3628+
}
3629+
}
36273630

3628-
return TRUE;
3631+
return TRUE;
36293632
}
36303633

36313634
BOOL

0 commit comments

Comments
 (0)