Hello!
The StartSearch function initializes only local stack copy of pHandle
variable. The patch fixes it.
Approved by valgrind-3.2.0 ;-)
--
Kirill
? for_mail.diff
Index: tools/ecostest/common/TestResource.cpp
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/ecostest/common/TestResource.cpp,v
retrieving revision 1.2
diff -u -r1.2 TestResource.cpp
--- tools/ecostest/common/TestResource.cpp 18 Apr 2000 21:51:58 -0000
1.2
+++ tools/ecostest/common/TestResource.cpp 21 Feb 2008 16:12:11 -0000
@@ -152,7 +152,7 @@
if(0==_tchdir(psz)){
String strFile;
void *pHandle;
- for(bool
b=CeCosTestUtils::StartSearch(pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){
+ for(bool
b=CeCosTestUtils::StartSearch(&pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){
if(CeCosTestUtils::IsFile(strFile)){
CTestResource *pResource=new CTestResource(_T(""),_T(""));
CTestResourceProperties prop(pResource);
@@ -180,7 +180,7 @@
_tgetcwd(szOrigDir,sizeof szOrigDir-1);
if(0==_tchdir(pszDir)){
String strFile;
- for(bool
b=CeCosTestUtils::StartSearch(pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){
+ for(bool
b=CeCosTestUtils::StartSearch(&pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){
if(CeCosTestUtils::IsFile(strFile)){
_tunlink(strFile);
}
Index: tools/ecostest/common/eCosTestPlatform.cpp
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/ecostest/common/eCosTestPlatform.cpp,v
retrieving revision 1.6
diff -u -r1.6 eCosTestPlatform.cpp
--- tools/ecostest/common/eCosTestPlatform.cpp 11 Apr 2003 12:12:26 -0000
1.6
+++ tools/ecostest/common/eCosTestPlatform.cpp 21 Feb 2008 16:12:11 -0000
@@ -67,7 +67,7 @@
if(0==_tchdir(pszDir)){
String strFile;
void *pHandle;
- for(bool
b=CeCosTestUtils::StartSearch(pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){
+ for(bool
b=CeCosTestUtils::StartSearch(&pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){
if(CeCosTestUtils::IsFile(strFile)){
CeCosTestPlatform t;
t.m_strName=strFile;
@@ -256,7 +256,7 @@
if(0==_tchdir(pszDir)){
// Delete all the files under directory "pszDir"
String strFile;
- for(bool
b=CeCosTestUtils::StartSearch(pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){
+ for(bool
b=CeCosTestUtils::StartSearch(&pHandle,strFile);b;b=CeCosTestUtils::NextFile(pHandle,strFile)){
if(CeCosTestUtils::IsFile(strFile)){
_tunlink(strFile);
}
Index: tools/ecostest/common/eCosTestUtils.cpp
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/ecostest/common/eCosTestUtils.cpp,v
retrieving revision 1.3
diff -u -r1.3 eCosTestUtils.cpp
--- tools/ecostest/common/eCosTestUtils.cpp 11 Jul 2006 09:56:15 -0000
1.3
+++ tools/ecostest/common/eCosTestUtils.cpp 21 Feb 2008 16:12:11 -0000
@@ -78,27 +78,27 @@
}
// Start file iteration and return first file.
-bool CeCosTestUtils::StartSearch (void *pHandle,String &str)
+bool CeCosTestUtils::StartSearch (void **pHandle,String &str)
{
#ifdef _WIN32
WIN32_FIND_DATA fd;
- pHandle=(void *)FindFirstFile (_T("*.*"), &fd);
+ *pHandle=(void *)FindFirstFile (_T("*.*"), &fd);
if(INVALID_HANDLE_VALUE==(HANDLE)pHandle){
ERROR(_T("Failed to open dir\n"));
return false;
} else if (fd.cFileName[0]=='.') {
- return NextFile(pHandle,str);
+ return NextFile(*pHandle,str);
} else {
str=String(fd.cFileName);
return true;
}
#else // UNIX
- pHandle=(void *)opendir(_T("."));
- if(0==pHandle){
+ *pHandle=(void *)opendir(_T("."));
+ if(0==*pHandle){
ERROR(_T("Failed to open dir\n"));
return false;
}
- return NextFile(pHandle,str);
+ return NextFile(*pHandle,str);
#endif
}
Index: tools/ecostest/common/eCosTestUtils.h
===================================================================
RCS file: /cvs/ecos/ecos/host/tools/ecostest/common/eCosTestUtils.h,v
retrieving revision 1.3
diff -u -r1.3 eCosTestUtils.h
--- tools/ecostest/common/eCosTestUtils.h 11 Jul 2006 09:56:15 -0000
1.3
+++ tools/ecostest/common/eCosTestUtils.h 21 Feb 2008 16:12:11 -0000
@@ -68,7 +68,7 @@
// File iterator. Gets next file in directory, avoiding "." and ".."
static bool NextFile (void *pHandle,String &str);
// Start file iteration and return first file.
- static bool StartSearch (void *pHandle,String &str);
+ static bool StartSearch (void **pHandle,String &str);
// End file iteration
static void EndSearch (void *pHandle);