diff --git a/lib/libtuxtxt/tuxtxt.cpp b/lib/libtuxtxt/tuxtxt.cpp index e73d0dd89..fd17ba802 100644 --- a/lib/libtuxtxt/tuxtxt.cpp +++ b/lib/libtuxtxt/tuxtxt.cpp @@ -120,7 +120,7 @@ void gethotlist() if (!fgets(line, sizeof(line), hl)) break; - if (1 == sscanf(line, "%x", (unsigned int *)&hotlist[maxhotlist + 1])) + if (sscanf(line, "%x", (unsigned int *)&hotlist[maxhotlist + 1]) == 1) { if (hotlist[maxhotlist + 1] >= 0x100 && hotlist[maxhotlist + 1] <= 0x899) { @@ -1918,47 +1918,47 @@ int Init(int source) if (!fgets(line, sizeof(line), conf)) break; - if (1 == sscanf(line, "ScreenMode16x9Normal %i", &ival)) + if (sscanf(line, "ScreenMode16x9Normal %i", &ival) == 1) screen_mode1 = ival & 1; - else if (1 == sscanf(line, "Brightness %i", &ival)) + else if (sscanf(line, "Brightness %i", &ival) == 1) color_mode = ival; - else if (1 == sscanf(line, "AutoNational %i", &ival)) + else if (sscanf(line, "AutoNational %i", &ival) == 1) auto_national = ival & 1; - else if (1 == sscanf(line, "NationalSubset %i", &ival)) + else if (sscanf(line, "NationalSubset %i", &ival) == 1) { if (ival >= 0 && ival <= (int) MAX_NATIONAL_SUBSET) national_subset = ival; } - else if (1 == sscanf(line, "MenuLanguage %i", &ival)) + else if (sscanf(line, "MenuLanguage %i", &ival) == 1) { if (ival >= 0 && ival <= MAXMENULANGUAGE) menulanguage = ival; } - else if (1 == sscanf(line, "SwapUpDown %i", &ival)) + else if (sscanf(line, "SwapUpDown %i", &ival) == 1) swapupdown = ival & 1; - else if (1 == sscanf(line, "ShowHexPages %i", &ival)) + else if (sscanf(line, "ShowHexPages %i", &ival) == 1) showhex = ival & 1; - else if (1 == sscanf(line, "Transparency %i", &ival)) + else if (sscanf(line, "Transparency %i", &ival) == 1) trans_mode = ival; - else if (1 == sscanf(line, "TTFWidthFactor16 %i", &ival)) + else if (sscanf(line, "TTFWidthFactor16 %i", &ival) == 1) TTFWidthFactor16 = ival; - else if (1 == sscanf(line, "TTFHeightFactor16 %i", &ival)) + else if (sscanf(line, "TTFHeightFactor16 %i", &ival) == 1) TTFHeightFactor16 = ival; - else if (1 == sscanf(line, "TTFShiftX %i", &ival)) + else if (sscanf(line, "TTFShiftX %i", &ival) == 1) TTFShiftX = ival; - else if (1 == sscanf(line, "TTFShiftY %i", &ival)) + else if (sscanf(line, "TTFShiftY %i", &ival) == 1) TTFShiftY = ival; - else if (1 == sscanf(line, "Screenmode %i", &ival)) + else if (sscanf(line, "Screenmode %i", &ival) == 1) screenmode = ival; - else if (1 == sscanf(line, "ShowFLOF %i", &ival)) + else if (sscanf(line, "ShowFLOF %i", &ival) == 1) showflof = ival & 1; - else if (1 == sscanf(line, "Show39 %i", &ival)) + else if (sscanf(line, "Show39 %i", &ival) == 1) show39 = ival & 1; - else if (1 == sscanf(line, "ShowLevel2p5 %i", &ival)) + else if (sscanf(line, "ShowLevel2p5 %i", &ival) == 1) showl25 = ival & 1; - else if (1 == sscanf(line, "DumpLevel2p5 %i", &ival)) + else if (sscanf(line, "DumpLevel2p5 %i", &ival) == 1) dumpl25 = ival & 1; - else if (1 == sscanf(line, "UseTTF %i", &ival)) + else if (sscanf(line, "UseTTF %i", &ival) == 1) usettf = ival & 1; } fclose(conf); diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index c83a944e8..1609f170b 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -1192,8 +1192,8 @@ static size_t getCachedMemSize(void) { char unit[10]; *unit = 0; - if ((3 == sscanf(buf, "%[^:]: %zu %s", a, &v, unit)) - || (2 == sscanf(buf, "%[^:]: %zu", a, &v))) + if ((sscanf(buf, "%[^:]: %zu %s", a, &v, unit) == 3) + || (sscanf(buf, "%[^:]: %zu", a, &v) == 2)) { if (*unit == 'k') v <<= 10; diff --git a/src/gui/3dsetup.cpp b/src/gui/3dsetup.cpp index 482cadbf8..98f4518b0 100644 --- a/src/gui/3dsetup.cpp +++ b/src/gui/3dsetup.cpp @@ -151,7 +151,7 @@ void C3DSetup::load() t_channel_id chan; long long unsigned int _chan; int mode; - if (2 == sscanf(s, "%llx %d", &_chan, &mode)) { + if (sscanf(s, "%llx %d", &_chan, &mode) == 2) { chan = _chan; threeDMap[chan] = (CFrameBuffer::Mode3D) mode; } diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 5db0f8a6e..f20242668 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -297,8 +297,8 @@ void CDBoxInfoWidget::paint() while (fgets(buf, sizeof(buf), procmeminfo)) { char unit[10]; *unit = 0; - if ((3 == sscanf(buf, "%[^:]: %llu %s", a, &v, unit)) - || (2 == sscanf(buf, "%[^:]: %llu", a, &v))) { + if ((sscanf(buf, "%[^:]: %llu %s", a, &v, unit) == 3) + || (sscanf(buf, "%[^:]: %llu", a, &v) == 2)) { if (*unit == 'k') v <<= 10; if (!strcasecmp(a, "MemTotal")) diff --git a/src/gui/followscreenings.cpp b/src/gui/followscreenings.cpp index 2710f879f..c23f843c7 100644 --- a/src/gui/followscreenings.cpp +++ b/src/gui/followscreenings.cpp @@ -77,7 +77,7 @@ CChannelEventList *CFollowScreenings::getFollowScreenings(void) int CFollowScreenings::exec(CMenuTarget* /*parent*/, const std::string & actionKey) { unsigned long a; - if (1 == sscanf(actionKey.c_str(), "%lu", &a)) { + if (sscanf(actionKey.c_str(), "%lu", &a) == 1) { int ix = 0; CChannelEventList::iterator e; for (e = followlist.begin(); e != followlist.end(); e++, ix++) diff --git a/src/gui/kerneloptions.cpp b/src/gui/kerneloptions.cpp index 406e0baf5..e06969ad0 100644 --- a/src/gui/kerneloptions.cpp +++ b/src/gui/kerneloptions.cpp @@ -73,7 +73,7 @@ void CKernelOptions::updateStatus(void) char buf[200]; while (fgets(buf, sizeof(buf), f)) { char name[sizeof(buf)]; - if (1 == sscanf(buf, "%s", name)) + if (sscanf(buf, "%s", name) == 1) for (unsigned int i = 0; i < modules.size(); i++) { if (name == modules[i].moduleList.back().first) { modules[i].installed = true; @@ -240,7 +240,7 @@ void CKernelOptions::load() if (t) *t = 0; char name[200]; - if (1 == sscanf(buf, "%s", name)) { + if (sscanf(buf, "%s", name) == 1) { for (unsigned int i = 0; i < modules.size(); i++) if (modules[i].moduleList.back().first == name) { modules[i].active = modules[i].active_orig = 1; diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index 17301c61f..7fbfc8c42 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -1908,7 +1908,7 @@ void CMoviePlayerGui::PlayFileLoop(void) CTimeInput jumpTime (LOCALE_MPKEY_GOTO, &Value, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, NULL, &cancel); jumpTime.exec(NULL, ""); jumpTime.hide(); - if (!cancel && (3 == sscanf(Value.c_str(), "%d:%d:%d", &hh, &mm, &ss))) + if (!cancel && (sscanf(Value.c_str(), "%d:%d:%d", &hh, &mm, &ss) == 3)) SetPosition(1000 * (hh * 3600 + mm * 60 + ss), true); } else if (msg == CRCInput::RC_help) { diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 3b517242e..c3468158d 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -135,7 +135,7 @@ int CNFSMountGui::exec( CMenuTarget* parent, const std::string & actionKey ) if (arptable) { char line[120], ip[120], mac[120]; while (fgets(line, sizeof(line), arptable)) { - if (2 == sscanf(line, "%s %*s %*s %s %*[^\n]", ip, mac)) { + if (sscanf(line, "%s %*s %*s %s %*[^\n]", ip, mac) == 2) { if (!strcmp(ip, h.c_str())) { g_settings.network_nfs[nr].mac = std::string(mac); break; diff --git a/src/gui/streaminfo.cpp b/src/gui/streaminfo.cpp index 1045ac16a..d66f92505 100644 --- a/src/gui/streaminfo.cpp +++ b/src/gui/streaminfo.cpp @@ -1431,7 +1431,7 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos, bool fake) { col = COL_MENUCONTENTINACTIVE_TEXT; int id; - if (1 == sscanf(casys[ca_id].substr(last_pos, pos - last_pos).c_str(), "%X", &id) && acaid == id) + if (sscanf(casys[ca_id].substr(last_pos, pos - last_pos).c_str(), "%X", &id) == 1 && acaid == id) col = COL_MENUCONTENT_TEXT; } if (!fake) diff --git a/src/zapit/src/udpstreampes.cpp b/src/zapit/src/udpstreampes.cpp index 09a1049df..31924ae4e 100644 --- a/src/zapit/src/udpstreampes.cpp +++ b/src/zapit/src/udpstreampes.cpp @@ -95,8 +95,8 @@ void RestartUdpSender() pthread_attr_t ThreadAttr; struct sched_param SchedParam; - if ( Send.Socket != -1 ) { - if( -1 == close( Send.Socket ) ) { + if (Send.Socket != -1) { + if (close( Send.Socket) == -1) { perror("ERROR: RestartUdpSender() - close"); fflush(stderr); } @@ -108,8 +108,7 @@ void RestartUdpSender() fflush(stderr); exit(-1); } - if( -1 == connect( Send.Socket, (struct sockaddr*)&(Send.Addr), - Send.AddrLen ) ) { + if (connect( Send.Socket, (struct sockaddr*)&(Send.Addr), Send.AddrLen) == -1) { perror("ERROR: RestartUdpSender() - connect"); fprintf(stderr, "EXIT\n"); fflush(stderr); @@ -122,8 +121,8 @@ void RestartUdpSender() pthread_attr_setschedparam(&ThreadAttr, &SchedParam); // bei Polling fuehrt die hohe Proritaet zu DmxBufferOverflows - if ( -1 == pthread_create(&(Send.Thread), 0, // &ThreadAttr, - UdpSender, 0 ) ) { + if (pthread_create(&(Send.Thread), 0, // &ThreadAttr, + UdpSender, 0) == -1) { perror("ERROR: RestartUdpSender() - pthread_create"); fprintf(stderr, "EXIT\n"); fflush(stderr); @@ -159,22 +158,20 @@ void * UdpSender( void * Ptr ) Send.Packet = i; // MSG_DONTWAIT ist notwendig, weil bei blocking I/O send() // frueher oder spaeter haengen bleibt -> Watchdog - if ( -1 == write (Send.Socket, ReadPtr, - DATA_PER_PACKET ) ) { -// while ( -1 == send (Send.Socket, ReadPtr, -// DATA_PER_PACKET, MSG_DONTWAIT ) ) { -// if( errno != EAGAIN ) { - // pselect(1, NULL, &wfds, NULL, &ts, NULL); - // } else { + if (write (Send.Socket, ReadPtr, DATA_PER_PACKET) == -1) { +// while (send (Send.Socket, ReadPtr, DATA_PER_PACKET, MSG_DONTWAIT) == -1) { +// if (errno != EAGAIN) { +// pselect(1, NULL, &wfds, NULL, &ts, NULL); +// } else { Send.Watchdog = WATCHDOG_TRESHOLD; perror("ERROR: UdpSender() - send"); fflush(stderr); pthread_exit(0); - // } +// } } - if ( ((PacketHeaderType*)ReadPtr)->Status == 2 ) { - for ( u=0; u< StreamThreadNum; u++ ) free( SPkt.Buf[u] ); - close( Send.Socket ); + if (((PacketHeaderType*)ReadPtr)->Status == 2) { + for (u=0; u< StreamThreadNum; u++ ) free( SPkt.Buf[u]); + close(Send.Socket); StreamStop = 1; pthread_exit(0); } @@ -199,7 +196,7 @@ void * DmxTSReader( void * /*Ptr*/ ) unsigned u; fd_dvr = open("/dev/dvb/adapter0/dvr0", O_RDONLY); - if (-1 == fd_dvr) { + if (fd_dvr == -1) { perror("ERROR: main() - dvr0 open"); fprintf(stderr, "EXIT\n"); fflush(stderr); @@ -208,14 +205,14 @@ void * DmxTSReader( void * /*Ptr*/ ) for (u = 0; u < StreamNum; u++) { Stream[u].fd = open("/dev/dvb/adapter0/demux0", O_RDWR); - if (-1 == Stream[u].fd) { + if (Stream[u].fd == -1) { perror("ERROR: main() - demux0 open"); fprintf(stderr, "EXIT\n"); fflush(stderr); exit(-1); } - if ( -1 == ioctl(Stream[u].fd, DMX_SET_BUFFER_SIZE, //256*1024) ) { - Stream[u].BufPacketNum * NET_DATA_PER_PACKET * DMX_BUF_FACTOR) ) { + if (ioctl(Stream[u].fd, DMX_SET_BUFFER_SIZE, //256*1024) ) { + Stream[u].BufPacketNum * NET_DATA_PER_PACKET * DMX_BUF_FACTOR) == -1) { perror("ERROR: main() - dmx set buffer ioctl"); fprintf(stderr, "EXIT\n"); fflush(stderr); @@ -308,12 +305,12 @@ void * DmxTSReader( void * /*Ptr*/ ) } for (u = 0; u < StreamNum; u++) { - if ( -1 == ioctl(Stream[u].fd, DMX_STOP, 0) ) { + if (ioctl(Stream[u].fd, DMX_STOP, 0) == -1) { perror("ERROR: DmxReader() - dmx stop ioctl"); fprintf(stderr, "Pid %x\n", Stream[u].Filter.pid); fflush(stderr); } - close( Stream[u].fd ); + close(Stream[u].fd); } close( fd_dvr ); free( CurStream->Buf[0] ); @@ -331,15 +328,15 @@ void * DmxReader( void * Ptr ) BufSize = (CurStream->BufPacketNum) * NET_DATA_PER_PACKET; CurStream->fd = open("/dev/dvb/adapter0/demux0", O_RDWR); - if (-1 == CurStream->fd) { + if (CurStream->fd == -1) { perror("ERROR: main() - demux0 open"); fprintf(stderr, "EXIT\n"); fflush(stderr); exit(-1); } - if ( -1 == ioctl(CurStream->fd, DMX_SET_BUFFER_SIZE, // 1024*1024) ) { - CurStream->BufPacketNum * NET_DATA_PER_PACKET * DMX_BUF_FACTOR) ) { + if (ioctl(CurStream->fd, DMX_SET_BUFFER_SIZE, // 1024*1024) ) { + CurStream->BufPacketNum * NET_DATA_PER_PACKET * DMX_BUF_FACTOR) == -1) { perror("ERROR: main() - dmx set buffer ioctl"); fprintf(stderr, "EXIT\n"); fflush(stderr); @@ -404,7 +401,7 @@ void * DmxReader( void * Ptr ) BufLen = 0; } - if ( -1 == ioctl(CurStream->fd, DMX_STOP, 0) ) { + if (ioctl(CurStream->fd, DMX_STOP, 0) == -1) { perror("ERROR: DmxReader() - dmx stop ioctl"); fprintf(stderr, "Pid %x\n", CurStream->Filter.pid); fflush(stderr); @@ -422,7 +419,7 @@ void ReadLine( char String[] ) StrPtr = String; while (StrPtr-String < STRING_SIZE-1 ) { - if ( 1 == read(STDIN_FILENO, &c, 1) ) { + if (read(STDIN_FILENO, &c, 1) == 1) { if ((*StrPtr++=c)=='\n') break; } } @@ -652,8 +649,7 @@ int main () // Adresse fuer Send.Socket ermitteln Send.AddrLen = sizeof(struct sockaddr_in); - if ( -1 == getpeername(STDIN_FILENO, - (struct sockaddr *)&(Send.Addr), &(Send.AddrLen)) ) { + if (getpeername(STDIN_FILENO, (struct sockaddr *)&(Send.Addr), &(Send.AddrLen)) == -1) { perror("ERROR: main() - getpeername"); fprintf(stderr, "EXIT\n"); fflush(stderr);