From b1db929bf74ffcf2f98765cf1467334d719ba3f4 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Mon, 4 Mar 2019 17:01:26 +0800 Subject: [PATCH] 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 --- mtce-guest/src/guestSvrUtil.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/mtce-guest/src/guestSvrUtil.cpp b/mtce-guest/src/guestSvrUtil.cpp index 4ab15676..214c62b2 100644 --- a/mtce-guest/src/guestSvrUtil.cpp +++ b/mtce-guest/src/guestSvrUtil.cpp @@ -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 )