From 603430617b8983998433988b1108e979bece2019 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Fri, 29 Sep 2017 20:37:37 +0200 Subject: [PATCH 1/3] CMenuWidget: fix "left" key for menuchoosers where the "decrement menu function" got lost by the last "simplify code and add missing break" commit. The implicit fallthrough actually was used to execute the "left" function. Reorganize the code so that it works even without the implicit fallthrough. Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/0e144e67ada5449ff2e8fccac2eb1a213797f55a Author: Stefan Seyfried Date: 2017-09-29 (Fri, 29 Sep 2017) --- src/gui/widget/menue.cpp | 63 +++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 06722d2e8..ce70e8d8f 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -927,42 +927,39 @@ int CMenuWidget::exec(CMenuTarget* parent, const std::string &) break; } case (CRCInput::RC_left): - if (hasItem() && selected > -1 && (int)items.size() > selected) { - CMenuItem* itemX = items[selected]; - if (!itemX->isMenueOptionChooser() && g_settings.menu_left_exit) - msg = CRCInput::RC_timeout; - } - break; case (CRCInput::RC_right): case (CRCInput::RC_ok): - { - if(hasItem() && selected > -1 && (int)items.size() > selected) { - //exec this item... - CMenuItem* item = items[selected]; - if (!item->isSelectable()) - break; - item->msg = msg; - fader.StopFade(); - int rv = item->exec( this ); - switch ( rv ) { - case menu_return::RETURN_EXIT_ALL: - retval = menu_return::RETURN_EXIT_ALL; - /* fall through */ - case menu_return::RETURN_EXIT: - msg = CRCInput::RC_timeout; - break; - case menu_return::RETURN_REPAINT: - case menu_return::RETURN_EXIT_REPAINT: - if (fade && washidden) - fader.StartFadeIn(); - checkHints(); - pos = selected; - paint(); - break; - } - } else + if (hasItem() && selected > -1 && (int)items.size() > selected) { + //exec this item... + CMenuItem* item = items[selected]; + if (msg == CRCInput::RC_left && g_settings.menu_left_exit && + !item->isMenueOptionChooser()) { msg = CRCInput::RC_timeout; - } + break; + } + if (!item->isSelectable()) + break; + item->msg = msg; + fader.StopFade(); + int rv = item->exec( this ); + switch ( rv ) { + case menu_return::RETURN_EXIT_ALL: + retval = menu_return::RETURN_EXIT_ALL; + /* fall through */ + case menu_return::RETURN_EXIT: + msg = CRCInput::RC_timeout; + break; + case menu_return::RETURN_REPAINT: + case menu_return::RETURN_EXIT_REPAINT: + if (fade && washidden) + fader.StartFadeIn(); + checkHints(); + pos = selected; + paint(); + break; + } + } else + msg = CRCInput::RC_timeout; break; case (CRCInput::RC_home): From 73cfd63885133976a1a192afe6717a9cb2df2cd9 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 1 Oct 2017 14:12:55 +0200 Subject: [PATCH 2/3] remove "using namespace std" from header files "using namespace std" in headers is considered bad practice, so move it either into the respective cpp files or (for files which have lots of other std::xxx usage anyway) just write it out explicitly. Looking at the headers and the affected cpp files, one can actually see why it is bad practice, as it's spreading very far ;-) Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/aa240a94576479f6521511b524098e4028d89e28 Author: Stefan Seyfried Date: 2017-10-01 (Sun, 01 Oct 2017) --- src/driver/audiodec/basedec.cpp | 2 +- src/driver/movieinfo.cpp | 2 +- src/gui/audio_select.h | 2 -- src/gui/cam_menu.h | 2 -- src/gui/channellist.cpp | 4 ++-- src/gui/components/cc_draw.cpp | 2 +- src/gui/components/cc_item_progressbar.cpp | 2 +- src/gui/dboxinfo.cpp | 6 +++--- src/gui/epgview.cpp | 2 +- src/gui/eventlist.cpp | 2 +- src/gui/hdd_menu.cpp | 12 ++++++------ src/gui/hdd_menu.h | 4 +--- src/gui/infoviewer.cpp | 10 +++++----- src/gui/infoviewer_bb.cpp | 4 ++-- src/gui/lua/lua_cc_window.cpp | 2 +- src/gui/moviebrowser/mb.cpp | 8 ++++---- src/gui/movieplayer.cpp | 4 ++-- src/gui/osd_setup.cpp | 2 +- src/gui/screensaver.h | 2 +- src/gui/streaminfo2.cpp | 4 ++-- src/gui/timerlist.cpp | 6 +++--- src/gui/tmdb.cpp | 2 +- src/gui/update.cpp | 2 +- src/gui/upnpbrowser.cpp | 2 +- src/gui/widget/mountchooser.cpp | 4 ++-- src/gui/widget/msgbox.cpp | 2 ++ src/gui/widget/shellwindow.cpp | 4 ++-- src/gui/widget/stringinput.cpp | 2 +- src/nhttpd/tuxboxapi/controlapi.cpp | 2 +- src/nhttpd/tuxboxapi/neutrinoapi.cpp | 2 +- src/nhttpd/tuxboxapi/neutrinoyparser.cpp | 2 +- src/system/helpers-json.h | 6 ++---- src/system/ytparser.cpp | 4 ++-- src/zapit/include/zapit/bouquets.h | 10 ++++------ src/zapit/include/zapit/getservices.h | 2 +- src/zapit/src/bouquets.cpp | 2 +- src/zapit/src/getservices.cpp | 4 ++-- 37 files changed, 64 insertions(+), 72 deletions(-) diff --git a/src/driver/audiodec/basedec.cpp b/src/driver/audiodec/basedec.cpp index 34d8cbeb9..f5a35e0b1 100644 --- a/src/driver/audiodec/basedec.cpp +++ b/src/driver/audiodec/basedec.cpp @@ -72,7 +72,7 @@ CBaseDec::RetCode CBaseDec::DecoderBase(CAudiofile* const in, RetCode Status = OK; FILE* fp; - if(( in->FileType == CFile::STREAM_AUDIO ) && (in->Filename.find(".flv") != string::npos)) + if ((in->FileType == CFile::STREAM_AUDIO) && (in->Filename.find(".flv") != std::string::npos)) { fp = fopen( in->Filename.c_str(), "rc" ); } diff --git a/src/driver/movieinfo.cpp b/src/driver/movieinfo.cpp index c90423b4e..a2fa9eb51 100644 --- a/src/driver/movieinfo.cpp +++ b/src/driver/movieinfo.cpp @@ -55,7 +55,7 @@ CMovieInfo::~CMovieInfo() bool CMovieInfo::convertTs2XmlName(std::string& filename) { size_t lastdot = filename.find_last_of("."); - if (lastdot != string::npos) { + if (lastdot != std::string::npos) { filename.erase(lastdot + 1); filename.append("xml"); return true; diff --git a/src/gui/audio_select.h b/src/gui/audio_select.h index 0dc27572f..b1177ccbf 100644 --- a/src/gui/audio_select.h +++ b/src/gui/audio_select.h @@ -32,8 +32,6 @@ -using namespace std; - class CAudioSelectMenuHandler : public CMenuTarget { private: diff --git a/src/gui/cam_menu.h b/src/gui/cam_menu.h index 829aa3433..9797f5c4a 100644 --- a/src/gui/cam_menu.h +++ b/src/gui/cam_menu.h @@ -29,8 +29,6 @@ #include -using namespace std; - class CCAMMenuHandler : public CMenuTarget, public CChangeObserver { private: diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 22455a328..e62a25e9e 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -1697,7 +1697,7 @@ void CChannelList::showChannelLogo() header->getChannelLogoObject()->paint(); } else - header->setChannelLogo(0, string()); + header->setChannelLogo(0, std::string()); } #define NUM_LIST_BUTTONS_SORT 9 @@ -2135,7 +2135,7 @@ void CChannelList::paintHead() if (bouquet && bouquet->zapitBouquet && bouquet->zapitBouquet->bLocked != g_settings.parentallock_defaultlocked) header->setIcon(NEUTRINO_ICON_LOCK); - string header_txt = !edit_state ? name : string(g_Locale->getText(LOCALE_CHANNELLIST_EDIT)) + ": " + name; + std::string header_txt = !edit_state ? name : std::string(g_Locale->getText(LOCALE_CHANNELLIST_EDIT)) + ": " + name; fb_pixel_t header_txt_col = (edit_state ? COL_RED : COL_MENUHEAD_TEXT); header->setColorBody(COL_MENUHEAD_PLUS_0); diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index 0ac6128c0..e086ac503 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -45,7 +45,7 @@ CCDraw::CCDraw() : COSDFader(g_settings.theme.menu_Content_alpha) col_frame = col_frame_old = COL_FRAME_PLUS_0; col_shadow_clean = 0; - cc_body_image = cc_body_image_old = string(); + cc_body_image = cc_body_image_old = std::string(); fr_thickness = fr_thickness_old = 0; diff --git a/src/gui/components/cc_item_progressbar.cpp b/src/gui/components/cc_item_progressbar.cpp index 63c75d976..9ebb61744 100644 --- a/src/gui/components/cc_item_progressbar.cpp +++ b/src/gui/components/cc_item_progressbar.cpp @@ -107,7 +107,7 @@ void CProgressBar::initDimensions() pb_y = (cc_parent ? cc_yr : y) + fr_thickness; // width for active bar with current value - pb_active_width = max(0, pb_last_width); + pb_active_width = std::max(0, pb_last_width); if (pb_max_value) pb_active_width = (width - 2*fr_thickness) * pb_value / pb_max_value; diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 5f301b172..15dffb0dd 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -281,10 +281,10 @@ void CDBoxInfoWidget::paint() while (getline(in, line)) { size_t firstslash = line.find_first_of('/'); size_t firstspace = line.find_first_of(' '); - if ( (firstspace != string::npos && firstslash != string::npos && firstslash < firstspace) || (line.find("rootfs") == 0) ) { + if ( (firstspace != std::string::npos && firstslash != std::string::npos && firstslash < firstspace) || (line.find("rootfs") == 0) ) { firstspace++; size_t nextspace = line.find_first_of(' ', firstspace); - if (nextspace == string::npos || line.find("nodev", nextspace + 1) != string::npos) + if (nextspace == std::string::npos || line.find("nodev", nextspace + 1) != std::string::npos) continue; std::string mountpoint = line.substr(firstspace, nextspace - firstspace); struct stat st; @@ -358,7 +358,7 @@ void CDBoxInfoWidget::paint() title += g_info.hw_caps->boxvendor; title += " "; title += g_info.hw_caps->boxname; - width = max(width, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(title, true) + 50); + width = std::max(width, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(title, true) + 50); x = getScreenStartX(width); if (!header) diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 6df3eb6d7..1fcccbae2 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -300,7 +300,7 @@ void CEpgData::showText(int startPos, int ypos, bool has_cover, bool fullClear) if(epgText[i].second){ std::string::size_type pos1 = epgText[i].first.find_first_not_of(tok, 0); std::string::size_type pos2 = epgText[i].first.find_first_of(tok, pos1); - while( pos2 != string::npos || pos1 != string::npos ){ + while( pos2 != std::string::npos || pos1 != std::string::npos ){ switch(count){ case 1: offset += max_wday_w; diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 97d9a5bc4..e86c77288 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -363,7 +363,7 @@ int CEventList::exec(const t_channel_id channel_id, const std::string& channelna COSDFader fader(g_settings.theme.menu_Content_alpha); fader.StartFadeIn(); if(!followlist.empty()){ - insert_iterator >ii(evtlist,evtlist.begin()); + std::insert_iterator >ii(evtlist,evtlist.begin()); copy(followlist.begin(), followlist.end(), ii); showfollow = true; }else{ diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index 8a1feb8bd..2baa3a6d6 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -133,11 +133,11 @@ int CHDDMenuHandler::filterDevName(const char * name) return 0; } -static string readlink(const char *path) +static std::string readlink(const char *path) { char link[PATH_MAX + 1]; if (realpath(path, link)) - return string(link); + return std::string(link); return ""; } @@ -151,7 +151,7 @@ bool CHDDMenuHandler::is_mounted(const char *dev) snprintf(devpath, sizeof(devpath), "/dev/%s", dev); char buffer[255]; - string realdev = readlink(devpath); + std::string realdev = readlink(devpath); realdev = trim(realdev); FILE *f = fopen("/proc/mounts", "r"); if(f) { @@ -164,7 +164,7 @@ bool CHDDMenuHandler::is_mounted(const char *dev) if (!strcmp(buffer, devpath)) /* default '/dev/sda1' mount */ res = true; else { /* now the case of '/dev/disk/by-label/myharddrive' mounts */ - string realmount = readlink(buffer); + std::string realmount = readlink(buffer); if (realdev == trim(realmount)) res = true; } @@ -259,7 +259,7 @@ void CHDDMenuHandler::check_kernel_fs() if (! tab) /* should not happen in any kernel I have seen */ continue; tab++; - kernel_fs_list.insert(string(tab)); + kernel_fs_list.insert(std::string(tab)); } fclose(f); } @@ -418,7 +418,7 @@ void CHDDMenuHandler::setRecordPath(std::string &dev) return; } /* don't annoy if the recordingdir is a symlink pointing to the 'right' location */ - string readl = readlink(g_settings.network_nfs_recordingdir.c_str()); + std::string readl = readlink(g_settings.network_nfs_recordingdir.c_str()); readl = trim(readl); if (newpath.compare(readl) == 0) { printf("CHDDMenuHandler::%s: recordingdir is a symlink to %s\n", diff --git a/src/gui/hdd_menu.h b/src/gui/hdd_menu.h index 617a7cb11..1734be4da 100644 --- a/src/gui/hdd_menu.h +++ b/src/gui/hdd_menu.h @@ -28,8 +28,6 @@ #include "widget/menue.h" #include -using namespace std; - struct devtool_s { std::string fmt; std::string fsck; @@ -65,7 +63,7 @@ class CHDDMenuHandler : public CMenuTarget }; std::vector hdd_list; std::set kernel_fs_list; - struct cmp_hdd_by_name: public binary_function + struct cmp_hdd_by_name: public std::binary_function { bool operator() (const struct hdd_s &c1, const struct hdd_s &c2) { diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index 5d545260d..04ab15332 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -201,11 +201,11 @@ void CInfoViewer::start () 2 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]->getHeight() + 25; infoViewerBB->Init(); - ChanWidth = max(125, 4 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getMaxDigitWidth() + 10); + ChanWidth = std::max(125, 4 * g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getMaxDigitWidth() + 10); ChanHeight = g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_NUMBER]->getHeight()/* * 9/8*/; ChanHeight += g_SignalFont->getHeight()/2; - ChanHeight = max(75, ChanHeight); + ChanHeight = std::max(75, ChanHeight); numbox_offset = 3; BoxStartX = g_settings.screen_StartX + 10; @@ -217,7 +217,7 @@ void CInfoViewer::start () ChanInfoX = BoxStartX + (ChanWidth / 3); initClock(); - time_height = max(ChanHeight / 2, clock->getHeight()); + time_height = std::max(ChanHeight / 2, clock->getHeight()); time_width = clock->getWidth(); } @@ -2116,8 +2116,8 @@ void CInfoViewer::showInfoFile() } //get text from file and set it to info object, exit and delete object if failed - string old_txt = infobar_txt->getText(); - string new_txt = infobar_txt->getTextFromFile(infobar_file); + std::string old_txt = infobar_txt->getText(); + std::string new_txt = infobar_txt->getTextFromFile(infobar_file); bool has_text = infobar_txt->setText(new_txt, CTextBox::CENTER, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_INFO]); if (new_txt.empty()){ killInfobarText(); diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index 287378fef..8d7d9e3b2 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -738,7 +738,7 @@ void CInfoViewerBB::paint_ca_icons(int caid, const char *icon, int &icon_space_o int endx = g_InfoViewer->BoxEndX - (g_settings.infobar_casystem_frame ? 20 : 10); int py = g_InfoViewer->BoxEndY + (g_settings.infobar_casystem_frame ? 4 : 2); /* hand-crafted, should be automatic */ int px = 0; - static map > icon_map; + static std::map > icon_map; const int icon_space = 10, icon_number = 10; static int icon_offset[icon_number] = {0,0,0,0,0,0,0,0,0,0}; @@ -748,7 +748,7 @@ void CInfoViewerBB::paint_ca_icons(int caid, const char *icon, int &icon_space_o if (!init_flag) { init_flag = true; int icon_sizeH = 0, index = 0; - map >::const_iterator it; + std::map >::const_iterator it; icon_map[0x0E00] = std::make_pair(index++,"powervu"); icon_map[0x4A00] = std::make_pair(index++,"d"); diff --git a/src/gui/lua/lua_cc_window.cpp b/src/gui/lua/lua_cc_window.cpp index 0d4c9d412..bec918eef 100644 --- a/src/gui/lua/lua_cc_window.cpp +++ b/src/gui/lua/lua_cc_window.cpp @@ -140,7 +140,7 @@ int CLuaInstCCWindow::CCWindowNew(lua_State *L) else { CComponentsFooter* footer = (*udata)->w->getFooterObject(); if (footer) { - vector buttons; + std::vector buttons; if (!btnRed.empty()) { button_label_cc btnSred; btnSred.button = NEUTRINO_ICON_BUTTON_RED; diff --git a/src/gui/moviebrowser/mb.cpp b/src/gui/moviebrowser/mb.cpp index 0005f6b26..880d2ca63 100644 --- a/src/gui/moviebrowser/mb.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -1279,10 +1279,10 @@ std::string CMovieBrowser::getScreenshotName(std::string movie, bool is_dir) else found = movie.find_last_of("."); - if (found == string::npos) + if (found == std::string::npos) return ""; - vector::iterator it = PicExts.begin(); + std::vector::iterator it = PicExts.begin(); while (it < PicExts.end()) { ret = movie; ext = *it; @@ -1325,7 +1325,7 @@ void CMovieBrowser::refreshChannelLogo(void) if (m_channelLogo && m_channelLogo->hasLogo()) { // TODO: move into an own handler, eg. header, so channel logo should be paint in header object - m_channelLogo->setWidth(min(m_channelLogo->getWidth(), w_logo_max), true); + m_channelLogo->setWidth(std::min(m_channelLogo->getWidth(), w_logo_max), true); if (m_channelLogo->getHeight() > h_logo_max) m_channelLogo->setHeight(h_logo_max, true); @@ -2846,7 +2846,7 @@ bool CMovieBrowser::addFile(CFile &file, int dirItNr) movieInfo.file = file; if(!m_movieInfo.loadMovieInfo(&movieInfo)) { - movieInfo.channelName = string(g_Locale->getText(LOCALE_MOVIEPLAYER_HEAD)); + movieInfo.channelName = std::string(g_Locale->getText(LOCALE_MOVIEPLAYER_HEAD)); movieInfo.epgTitle = file.getFileName(); } movieInfo.dirItNr = dirItNr; diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index f8c2c4482..874df00af 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -843,7 +843,7 @@ bool CMoviePlayerGui::luaGetUrl(const std::string &script, const std::string &fi return false; } - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(result_string, &root, &errMsg); if (!ok) { @@ -2619,7 +2619,7 @@ void CMoviePlayerGui::showSubtitle(neutrino_msg_data_t data) size_t start = 0, end = 0; /* split string with \N as newline */ std::string delim("\\N"); - while ((end = str.find(delim, start)) != string::npos) { + while ((end = str.find(delim, start)) != std::string::npos) { subtext.push_back(str.substr(start, end - start)); start = end + 2; } diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index d92d86225..b14dbbac7 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -1323,7 +1323,7 @@ void COsdSetup::showOsdVolumeSetup(CMenuWidget *menu_volume) // volume size int vMin = CVolumeHelper::getInstance()->getVolIconHeight(); - g_settings.volume_size = max(g_settings.volume_size, vMin); + g_settings.volume_size = std::max(g_settings.volume_size, vMin); CMenuOptionNumberChooser * nc = new CMenuOptionNumberChooser(LOCALE_EXTRA_VOLUME_SIZE, &g_settings.volume_size, true, vMin, 50); nc->setHint("", LOCALE_MENU_HINT_VOLUME_SIZE); menu_volume->addItem(nc); diff --git a/src/gui/screensaver.h b/src/gui/screensaver.h index 0a9605561..9dff31919 100644 --- a/src/gui/screensaver.h +++ b/src/gui/screensaver.h @@ -39,7 +39,7 @@ class CScreenSaver : public sigc::trackable CComponentsFrmClock *scr_clock; pthread_t thrScreenSaver; static void* ScreenSaverPrg(void *arg); - vector v_bg_files; + std::vector v_bg_files; unsigned int index; t_channel_id pip_channel_id; bool status_mute; diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 858a56973..7f0ef4f7f 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -150,8 +150,8 @@ int CStreamInfo2::doSignalStrengthLoop () const int delay = 15; int sw = g_Font[font_info]->getRenderWidth("99999"); maxb = minb = lastb = tmp_rate = 0; - string br_str = string(g_Locale->getText(LOCALE_STREAMINFO_BITRATE)) + ":"; - string avg_str = "(" + string(g_Locale->getText(LOCALE_STREAMINFO_AVERAGE_BITRATE)) + ")"; + std::string br_str = std::string(g_Locale->getText(LOCALE_STREAMINFO_BITRATE)) + ":"; + std::string avg_str = "(" + std::string(g_Locale->getText(LOCALE_STREAMINFO_AVERAGE_BITRATE)) + ")"; int offset = g_Font[font_info]->getRenderWidth(avg_str); int dheight = g_Font[font_info]->getHeight (); int dx1 = x + 10; diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 66d825e65..ba05f88aa 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -740,7 +740,7 @@ bool CTimerList::RemoteBoxChanExists(t_channel_id channel_id) r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(r_url, &root, &errMsg); if (!ok) { @@ -797,7 +797,7 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); //printf("[remotetimer] timers:%s\n",r_url.c_str()); - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(r_url, &root, &errMsg); if (!ok) { @@ -1286,7 +1286,7 @@ void CTimerList::paintItem(int pos) r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer.channel_id); r_url = httpTool.downloadString(r_url, -1, httpConnectTimeout); - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(r_url, &root, &errMsg); if (!ok) { diff --git a/src/gui/tmdb.cpp b/src/gui/tmdb.cpp index 5a8208e27..b4aff486d 100644 --- a/src/gui/tmdb.cpp +++ b/src/gui/tmdb.cpp @@ -198,7 +198,7 @@ bool cTmdb::GetMovieDetails(std::string lang) if (!getUrl(url, answer)) return false; - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool ok = parseJsonFromString(answer, &root, &errMsg); if (!ok) { diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 7cd429bec..980f70ab2 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -411,7 +411,7 @@ bool CFlashUpdate::checkVersion4Update() if (allow_flash) UpdatesFilter.addFilter(FILEBROWSER_UPDATE_FILTER); - string filters[] = {"bin", "txt", "opk", "ipk"}; + std::string filters[] = {"bin", "txt", "opk", "ipk"}; for(size_t i=0; i>1) #define MIN_WINDOW_HEIGHT 40 +using namespace std; /* TODO: remove all std:: prefixes in this file */ + CMsgBox::CMsgBox( const char* Text, const char* Title, const char* Icon, diff --git a/src/gui/widget/shellwindow.cpp b/src/gui/widget/shellwindow.cpp index 60af07803..2e67e1e8d 100644 --- a/src/gui/widget/shellwindow.cpp +++ b/src/gui/widget/shellwindow.cpp @@ -83,7 +83,7 @@ static int read_line(int fd, struct pollfd *fds, char *b, size_t sz) return i; } -static std::string lines2txt(list &lines) +static std::string lines2txt(std::list &lines) { std::string txt = ""; for (std::list::const_iterator it = lines.begin(), end = lines.end(); it != end; ++it) { @@ -122,7 +122,7 @@ void CShellWindow::exec() int h_shell = frameBuffer->getScreenHeight(); int w_shell = frameBuffer->getScreenWidth(); unsigned int lines_max = h_shell / font->getHeight(); - list lines; + std::list lines; CBox textBoxPosition(frameBuffer->getScreenX(), frameBuffer->getScreenY(), w_shell, h_shell); if (textBox == NULL){ textBox = new CTextBox(cmd.c_str(), font, CTextBox::BOTTOM, &textBoxPosition); diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index b4b8a30c8..9ae14319e 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -490,7 +490,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { - string tmp_name = name == NONEXISTANT_LOCALE ? head : g_Locale->getText(name); + std::string tmp_name = name == NONEXISTANT_LOCALE ? head : g_Locale->getText(name); if ((trim (*valueString) != trim(oldval)) && (ShowMsg(tmp_name, LOCALE_MESSAGEBOX_DISCARD, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbCancel) == CMsgBox::mbrCancel)) { timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU]); diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index d747f5f26..aae45af24 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -1074,7 +1074,7 @@ void CControlAPI::LogolistCGI(CyhookHandler *hh) if (g_PicViewer->GetLogoName(channel->getChannelID(), NeutrinoAPI->GetServiceName(channel->getChannelID()), logo_used, NULL, NULL)) { realpath(logo_used.c_str(), _real); - logo_real = string(_real); + logo_real = std::string(_real); if (strcmp(logo_used.c_str(), logo_real.c_str()) == 0) logo_real.clear(); } diff --git a/src/nhttpd/tuxboxapi/neutrinoapi.cpp b/src/nhttpd/tuxboxapi/neutrinoapi.cpp index c47c06ac0..a4f3d8aea 100644 --- a/src/nhttpd/tuxboxapi/neutrinoapi.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoapi.cpp @@ -514,7 +514,7 @@ std::string CNeutrinoAPI::getCryptInfoAsString(void) for(casys_map_iterator_t it = channel->camap.begin(); it != channel->camap.end(); ++it) { int caid = (*it) & 0xFF00; if(caid == caids[i]) - out << casys[i] << hex << (*it) << "\n"; + out << casys[i] << std::hex << (*it) << "\n"; } } diff --git a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp index 31eb012c9..1acc8a655 100644 --- a/src/nhttpd/tuxboxapi/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/neutrinoyparser.cpp @@ -585,7 +585,7 @@ std::string CNeutrinoYParser::func_get_logo_name(CyhookHandler *hh, std::string std::string fileType[] = { ".png", ".jpg" , ".gif" }; std::string channelIdShort = channelId.substr(channelId.length() - 12); - channelIdShort = channelIdShort.erase(0, min(channelIdShort.find_first_not_of('0'), channelIdShort.size()-1)); + channelIdShort = channelIdShort.erase(0, std::min(channelIdShort.find_first_not_of('0'), channelIdShort.size()-1)); std::string channelName = ""; t_channel_id chId = 0; diff --git a/src/system/helpers-json.h b/src/system/helpers-json.h index 0e4923649..23582d431 100644 --- a/src/system/helpers-json.h +++ b/src/system/helpers-json.h @@ -23,9 +23,7 @@ #include -using namespace std; - -bool parseJsonFromFile(string& jFile, Json::Value *root, string *errMsg); -bool parseJsonFromString(string& jData, Json::Value *root, string *errMsg); +bool parseJsonFromFile(std::string& jFile, Json::Value *root, std::string *errMsg); +bool parseJsonFromString(std::string& jData, Json::Value *root, std::string *errMsg); #endif diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index a2762f279..e42f7e032 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -289,7 +289,7 @@ std::string cYTFeedParser::getXmlData(xmlNodePtr node) bool cYTFeedParser::parseFeedJSON(std::string &answer) { - string errMsg = ""; + std::string errMsg = ""; Json::Value root; std::ostringstream ss; @@ -384,7 +384,7 @@ bool cYTFeedParser::parseFeedDetailsJSON(cYTVideoInfo* vinfo) if (!getUrl(url, answer)) return false; - string errMsg = ""; + std::string errMsg = ""; Json::Value root; bool parsedSuccess = parseJsonFromString(answer, &root, &errMsg); if (!parsedSuccess) { diff --git a/src/zapit/include/zapit/bouquets.h b/src/zapit/include/zapit/bouquets.h index 6c885a562..2adc88f4b 100644 --- a/src/zapit/include/zapit/bouquets.h +++ b/src/zapit/include/zapit/bouquets.h @@ -18,12 +18,10 @@ #include "channel.h" -using namespace std; - -typedef map tallchans; +typedef std::map tallchans; typedef tallchans::iterator tallchans_iterator; -typedef vector ZapitChannelList; +typedef std::vector ZapitChannelList; typedef ZapitChannelList::iterator zapit_list_it_t; #define DEFAULT_BQ_ID 0 @@ -83,7 +81,7 @@ class CZapitBouquet bool getChannels(ZapitChannelList &list, bool tv, int flags = CZapitChannel::PRESENT); }; -typedef vector BouquetList; +typedef std::vector BouquetList; class CBouquetManager { @@ -168,7 +166,7 @@ class CBouquetManager * For instance all countless variants of the letter a have to be regarded as the same letter. */ -struct CmpBouquetByChName: public binary_function +struct CmpBouquetByChName: public std::binary_function { static bool comparetolower(const char a, const char b) { diff --git a/src/zapit/include/zapit/getservices.h b/src/zapit/include/zapit/getservices.h index 780b525c0..f82908e26 100644 --- a/src/zapit/include/zapit/getservices.h +++ b/src/zapit/include/zapit/getservices.h @@ -40,7 +40,7 @@ extern transponder_list_t transponders; typedef std::map sat_transponder_map_t; -typedef map channel_map_t; +typedef std::map channel_map_t; typedef channel_map_t::iterator channel_map_iterator_t; typedef std::pair channel_pair_t; typedef std::pair channel_insert_res_t; diff --git a/src/zapit/src/bouquets.cpp b/src/zapit/src/bouquets.cpp index c5cc7e0ec..81c85792f 100644 --- a/src/zapit/src/bouquets.cpp +++ b/src/zapit/src/bouquets.cpp @@ -542,7 +542,7 @@ void CBouquetManager::makeRemainingChannelsBouquet(void) int j = CServiceManager::getInstance()->GetMaxNumber(true); /* FIXME temp debug */ printf("############## CBouquetManager::makeRemainingChannelsBouquet: numbers start at: tv %d radio %d ############\n", i, j); - for (vector::const_iterator it = Bouquets.begin(); it != Bouquets.end(); ++it) { + for (std::vector::const_iterator it = Bouquets.begin(); it != Bouquets.end(); ++it) { renumChannels((*it)->tvChannels, i, (*it)->bUser ? NULL : (char *) (*it)->Name.c_str()); renumChannels((*it)->radioChannels, j, (*it)->bUser ? NULL : (char *) (*it)->Name.c_str()); } diff --git a/src/zapit/src/getservices.cpp b/src/zapit/src/getservices.cpp index ff9e3477a..3071d7145 100644 --- a/src/zapit/src/getservices.cpp +++ b/src/zapit/src/getservices.cpp @@ -418,7 +418,7 @@ void CServiceManager::ParseTransponders(xmlNodePtr node, t_satellite_position sa transponder_id_t tid = CREATE_TRANSPONDER_ID64(freq, satellitePosition,original_network_id,transport_stream_id); transponder t(tid, feparams); - pair::iterator,bool> ret; + std::pair::iterator,bool> ret; ret = transponders.insert(transponder_pair_t(tid, t)); if (ret.second == false) t.dump("[zapit] duplicate in all transponders:"); @@ -1385,7 +1385,7 @@ bool CServiceManager::GetTransponder(transponder_id_t tid, transponder &t) void CServiceManager::UpdateSatTransponders(t_satellite_position satellitePosition) { - pair::iterator,bool> ret; + std::pair::iterator,bool> ret; transponder_list_t & stransponders = satelliteTransponders[satellitePosition]; for (transponder_list_t::iterator tI = transponders.begin(); tI != transponders.end(); ++tI) { for (stiterator stI = stransponders.begin(); stI != stransponders.end(); ++stI) { From eff7a174b2c60a77f559de5b7aeef882e93f0199 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 1 Oct 2017 14:38:52 +0200 Subject: [PATCH 3/3] helpers/readFile: limit memory allocations Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/21f04057bd02821e05fc864732ac5dbe90934188 Author: Stefan Seyfried Date: 2017-10-01 (Sun, 01 Oct 2017) --- src/system/helpers.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 3a60720d0..57a6cd477 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -1416,8 +1416,16 @@ string readFile(string file) if (tmpData.is_open()) { tmpData.seekg(0, tmpData.end); int length = tmpData.tellg(); + if (length > 0xffff) { /* longer than 64k? better read in chunks! */ + cerr << __func__ << ": file " << file << " too big (" << length << " bytes)" << endl; + return ""; + } tmpData.seekg(0, tmpData.beg); char* buffer = new char[length+1]; + if (! buffer) { + cerr << __func__ << ": allocating " << (length + 1) << " bytes for buffer failed" << endl; + return ""; + } tmpData.read(buffer, length); tmpData.close(); buffer[length] = '\0';