replace readdir_r with readdir in guestSvrUtil.cpp

Reasons:
* readdir_r has been deprecated from glibc 2.24. Detailed reasons
  can be found at below link.
  http://man7.org/linux/man-pages/man3/readdir_r.3.html
* StarlingX devstack has switched to Ubuntu Bionic. By default,
  gcc version is 7.3.0, glibc version is 2.27. Using readdir_r in
  mtce-guest will cause compiling failure.

Passed tests:
* Fresh building
* Deployment test
* Function-level unit tests. Modfied guestUtil_load_channels and
  guestUtil_channel_search have same output as previous ones.
* System-level verification. guestServer&guestAgent can start
  successfully. By checking the log of guestServer, it has the same
  content as before.

Story: 2003163
Task: 29689

Change-Id: Ib77decf495f093651ac93ef1e0ce2be3807ce91b
Signed-off-by: Yi Wang <yi.c.wang@intel.com>
This commit is contained in:
Yi Wang 2019-03-04 17:01:26 +08:00
parent 116b10b7c6
commit b1db929bf7
1 changed files with 2 additions and 10 deletions

View File

@ -76,7 +76,6 @@ int guestUtil_close_channel ( instInfo * instInfo_ptr )
void guestUtil_load_channels ( void )
{
DIR *dirp;
struct dirent entry;
struct dirent *result;
dirp = opendir(QEMU_CHANNEL_DIR);
@ -87,11 +86,8 @@ void guestUtil_load_channels ( void )
else
{
dlog ("Searching %s directory\n", QEMU_CHANNEL_DIR);
while(0 == readdir_r(dirp, &entry, &result))
while ((result = readdir(dirp)) != NULL)
{
if (!result)
break;
if ( virtio_check_filename (result->d_name) )
{
string channel = result->d_name ;
@ -125,7 +121,6 @@ void guestUtil_load_channels ( void )
void guestUtil_channel_search ( void )
{
DIR *dirp;
struct dirent entry;
struct dirent *result;
dirp = opendir(QEMU_CHANNEL_DIR);
@ -136,11 +131,8 @@ void guestUtil_channel_search ( void )
else
{
dlog ("Searching %s directory\n", QEMU_CHANNEL_DIR);
while(0 == readdir_r(dirp, &entry, &result))
while ((result = readdir(dirp)) != NULL)
{
if (!result)
break;
if ( virtio_check_filename (result->d_name) )
{
if ( get_instInv_ptr()->get_inst ( virtio_instance_name (result->d_name).data()) == NULL )