Skip to content

Commit

Permalink
more cosmetic changes (thx vanhofen)
Browse files Browse the repository at this point in the history
  • Loading branch information
BPanther committed Mar 25, 2024
1 parent d6aa914 commit b2a22ba
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 60 deletions.
38 changes: 19 additions & 19 deletions lib/libtuxtxt/tuxtxt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/driver/pictureviewer/pictureviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/3dsetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/dboxinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion src/gui/followscreenings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/kerneloptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/movieplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/gui/nfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/streaminfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
56 changes: 26 additions & 30 deletions src/zapit/src/udpstreampes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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] );
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit b2a22ba

Please sign in to comment.