From 4159e6925beb9b2f2732b2ac7dce7eae9d75de0b Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Sat, 25 Apr 2015 15:41:58 +0200 Subject: [PATCH] Declare "dirp" and "dptr" pointers just before they're needed --- src/menu.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/menu.cpp b/src/menu.cpp index facbaa5..e8306d8 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -81,9 +81,9 @@ Menu::Menu(GMenu2X& gmenu2x) #ifdef HAVE_LIBOPK { - struct dirent *dptr; DIR *dirp = opendir(CARD_ROOT); if (dirp) { + struct dirent *dptr; while ((dptr = readdir(dirp))) { if (dptr->d_type != DT_DIR) continue; @@ -108,12 +108,10 @@ Menu::~Menu() void Menu::readSections(std::string const& parentDir) { - DIR *dirp; - struct dirent *dptr; - - dirp = opendir(parentDir.c_str()); + DIR *dirp = opendir(parentDir.c_str()); if (!dirp) return; + struct dirent *dptr; while ((dptr = readdir(dirp))) { if (dptr->d_name[0] != '.' && dptr->d_type == DT_DIR) { // Create section if it doesn't exist yet.