Skip to content

Commit 4aad3be

Browse files
committed
fix some findings from static code analysis
1 parent 8479336 commit 4aad3be

17 files changed

+30
-59
lines changed

ffmpeghandler.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ std::vector<std::string> FFmpegHandler::prepareStreamCmdVideo(const m3u_stream &
8181

8282
// add optional audio input
8383
std::vector<std::string> audioMetadata;
84-
for (auto a : stream.audio) {
84+
for (const auto& a : stream.audio) {
8585
callStr.emplace_back("-thread_queue_size");
8686
callStr.emplace_back(std::to_string(IptvConfig.GetThreadQueueSize()));
8787
callStr.emplace_back("-i");
@@ -188,7 +188,7 @@ std::vector<std::string> FFmpegHandler::prepareStreamCmdAudio(const m3u_stream &
188188

189189
// add optional audio input
190190
std::vector<std::string> audioMetadata;
191-
for (auto a : stream.audio) {
191+
for (const auto& a : stream.audio) {
192192
callStr.emplace_back("-i");
193193
callStr.emplace_back(a.uri);
194194
}

iptv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ cString cPluginIptv::SVDRPCommand(const char *commandP, const char *optionP, int
224224
return device->GetInformation(page);
225225
} else {
226226
replyCodeP = 550; // Requested action not taken
227-
return cString("IPTV information not available!");
227+
return {"IPTV information not available!"};
228228
}
229229
} else if (strcasecmp(commandP, "MODE")==0) {
230230
unsigned int mode = !IptvConfig.GetUseBytes();

iptvservice.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
*
66
*/
77

8-
#ifndef __IPTVSERVICE_H
9-
#define __IPTVSERVICE_H
10-
8+
#pragma once
119
#include <vdr/tools.h>
1210

1311
#define stIptv ('I' << 24)
@@ -18,5 +16,3 @@ struct IptvService_v1_0 {
1816
cString bitrate;
1917
};
2018

21-
#endif //__IPTVSERVICE_H
22-

m3u8handler.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
#include "config.h"
44
#include "process.hpp"
55

6-
std::pair<std::string, std::string> splitUri(std::string uri) {
6+
std::pair<std::string, std::string> splitUri(const std::string& uri) {
77
auto yturi = uri::parse_uri(uri);
88
std::string host = yturi.scheme + "://" + yturi.authority.host
99
+ (yturi.authority.port > 0 ? std::to_string(yturi.authority.port) : "");
1010

1111
std::string query;
12-
for (auto a : yturi.query) {
12+
for (const auto& a : yturi.query) {
1313
query.append(a.first).append("=").append(a.second).append("&");
1414
}
1515

@@ -222,12 +222,12 @@ m3u_stream M3u8Handler::parseM3u(const std::string &webUri, int useYtdlp) {
222222
return result;
223223
}
224224

225-
void M3u8Handler::printStream(m3u_stream stream) {
225+
void M3u8Handler::printStream(const m3u_stream& stream) {
226226
debug2("Url: %s\n", stream.url.c_str());
227227
debug2(" Width: %d, Height: %d\n", stream.width, stream.height);
228228
if (! stream.audio.empty()) {
229229
debug2(" Audio:\n");
230-
for (auto s : stream.audio) {
230+
for (const auto& s : stream.audio) {
231231
debug2(" Type: %s\n", s.type.c_str());
232232
debug2(" Lang: %s\n", s.language.c_str());
233233
debug2(" Name: %s\n", s.name.c_str());

m3u8handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class M3u8Handler {
3737
explicit M3u8Handler();
3838
static m3u_stream parseM3u(const std::string &uri, int useYtdlp);
3939

40-
static void printStream(m3u_stream stream);
40+
static void printStream(const m3u_stream& stream);
4141

4242
private:
4343
static bool startsWith(const std::string &str, const std::string &prefix);

protocolcurl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ size_t cIptvProtocolCurl::DescribeCallback(void *ptrP, size_t sizeP, size_t nmem
161161
found = true;
162162
}
163163

164-
// ... and find out its' attribute
164+
// ... and find out its attribute
165165
if (found && strstr(r, "a=control")) {
166166
char *s = nullptr;
167167
if (sscanf(r, "a=control:%255ms", &s)==1)

protocolext.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@
66
*/
77

88
#include <sys/wait.h>
9-
#include <sys/types.h>
10-
#include <sys/socket.h>
11-
#include <netdb.h>
129
#include <fcntl.h>
1310
#include <unistd.h>
1411

1512
#include <vdr/device.h>
16-
#include <vdr/plugin.h>
1713

1814
#include "common.h"
1915
#include "config.h"
@@ -187,7 +183,7 @@ cIptvProtocolExt::SetSource(const char *locationP,
187183
// Update script file and parameter
188184
scriptFileM = cString::sprintf("%s/%s", IptvConfig.GetResourceDirectory(), locationP);
189185

190-
if ((stat(*scriptFileM, &stbuf) != 0) || (strstr(*scriptFileM, "..") != 0)) {
186+
if ((stat(*scriptFileM, &stbuf) != 0) || (strstr(*scriptFileM, "..") != nullptr)) {
191187
error("Non-existent or relative path script '%s'", *scriptFileM);
192188

193189
return false;

protocolfile.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
*
66
*/
77

8-
#include <fcntl.h>
9-
#include <unistd.h>
10-
118
#include <vdr/device.h>
129

1310
#include "common.h"

protocolhttp.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
*
66
*/
77

8-
#include <sys/types.h>
9-
#include <sys/socket.h>
10-
#include <netdb.h>
11-
#include <fcntl.h>
12-
#include <unistd.h>
13-
#include <string.h>
8+
#include <cstring>
149

1510
#include <vdr/device.h>
1611

protocolm3u.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ cIptvProtocolM3U::SetSource(const char *locationP,
8686

8787
struct stat stbuf;
8888
cString configFileM = cString::sprintf("%s/%s", IptvConfig.GetResourceDirectory(), locationP);
89-
if ((stat(*configFileM, &stbuf)!=0) || (strstr(*configFileM, "..")!=0)) {
89+
if ((stat(*configFileM, &stbuf)!=0) || (strstr(*configFileM, "..") != nullptr)) {
9090
error("Non-existent or relative configuration file '%s'", *configFileM);
9191

9292
return false;

protocolradio.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include <fstream>
2-
31
#include "protocolradio.h"
42
#include "common.h"
53
#include "config.h"

protocolstream.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include <fstream>
2-
31
#include "protocolstream.h"
42
#include "common.h"
53
#include "config.h"

protocoludp.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@
55
*
66
*/
77

8-
#include <sys/types.h>
9-
#include <sys/socket.h>
10-
#include <netdb.h>
11-
#include <fcntl.h>
12-
#include <unistd.h>
13-
148
#include <vdr/device.h>
159

16-
#include "common.h"
1710
#include "config.h"
1811
#include "log.h"
1912
#include "socket.h"

sectionfilter.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ cIptvSectionFilter::cIptvSectionFilter(int deviceIndexP, uint16_t pidP, uint8_t
1313
: pusiSeenM(0),
1414
feedCcM(0),
1515
doneqM(0),
16-
secBufM(NULL),
16+
secBufM(nullptr),
1717
secBufpM(0),
1818
secLenM(0),
1919
tsFeedpM(0),
2020
pidM(pidP),
2121
ringBufferM(new cRingBufferFrame(eDmxMaxSectionCount*eDmxMaxSectionSize)),
2222
deviceIndexM(deviceIndexP) {
2323
debug16("%s (%d, %d)", __PRETTY_FUNCTION__, deviceIndexM, pidM);
24+
2425
int i;
2526

2627
memset(secBufBaseM, 0, sizeof(secBufBaseM));
@@ -74,20 +75,20 @@ cIptvSectionFilter::~cIptvSectionFilter() {
7475
socketM[0] = -1;
7576
if (tmp >= 0)
7677
close(tmp);
77-
secBufM = NULL;
78+
secBufM = nullptr;
7879
DELETENULL(ringBufferM);
7980
}
8081

8182
inline uint16_t cIptvSectionFilter::GetLength(const uint8_t *dataP) {
8283
return (uint16_t) (3 + ((dataP[1] & 0x0f) << 8) + dataP[2]);
8384
}
8485

85-
void cIptvSectionFilter::New(void) {
86+
void cIptvSectionFilter::New() {
8687
tsFeedpM = secBufpM = secLenM = 0;
8788
secBufM = secBufBaseM;
8889
}
8990

90-
int cIptvSectionFilter::Filter(void) {
91+
int cIptvSectionFilter::Filter() {
9192
if (secBufM) {
9293
int i;
9394
uint8_t neq = 0;
@@ -108,7 +109,7 @@ int cIptvSectionFilter::Filter(void) {
108109
return 0;
109110
}
110111

111-
inline int cIptvSectionFilter::Feed(void) {
112+
inline int cIptvSectionFilter::Feed() {
112113
if (Filter() < 0)
113114
return -1;
114115
secLenM = 0;
@@ -205,7 +206,7 @@ void cIptvSectionFilter::Process(const uint8_t *dataP) {
205206
}
206207
}
207208

208-
bool cIptvSectionFilter::Send(void) {
209+
bool cIptvSectionFilter::Send() {
209210
bool result = false;
210211
cFrame *section = ringBufferM->Get();
211212
if (section) {
@@ -261,7 +262,7 @@ cIptvSectionFilterHandler::~cIptvSectionFilterHandler() {
261262
Delete(i);
262263
}
263264

264-
void cIptvSectionFilterHandler::Action(void) {
265+
void cIptvSectionFilterHandler::Action() {
265266
debug1("%s Entering [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
266267
bool processed = false;
267268
// Do the thread loop
@@ -315,7 +316,7 @@ void cIptvSectionFilterHandler::Action(void) {
315316
debug1("%s Exiting [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
316317
}
317318

318-
cString cIptvSectionFilterHandler::GetInformation(void) {
319+
cString cIptvSectionFilterHandler::GetInformation() {
319320
debug16("%s [device %d]", __PRETTY_FUNCTION__, deviceIndexM);
320321
// loop through active section filters
321322
cMutexLock MutexLock(&mutexM);
@@ -338,7 +339,7 @@ bool cIptvSectionFilterHandler::Delete(unsigned int indexP) {
338339
if ((indexP < eMaxSecFilterCount) && filtersM[indexP]) {
339340
debug16("%s (%d) Found [device %d]", __PRETTY_FUNCTION__, indexP, deviceIndexM);
340341
cIptvSectionFilter *tmp = filtersM[indexP];
341-
filtersM[indexP] = NULL;
342+
filtersM[indexP] = nullptr;
342343
delete tmp;
343344
return true;
344345
}

socket.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
*
66
*/
77

8-
#include <sys/types.h>
98
#include <sys/socket.h>
10-
#include <net/if.h>
119
#include <netdb.h>
1210
#include <fcntl.h>
1311
#include <unistd.h>
@@ -41,7 +39,7 @@ cIptvSocket::~cIptvSocket() {
4139
bool cIptvSocket::OpenSocket(const int portP, const bool isUdpP) {
4240
debug1("%s (%d, %d)", __PRETTY_FUNCTION__, portP, isUdpP);
4341

44-
// If socket is there already and it is bound to a different port, it must
42+
// If socket is there already, and it is bound to a different port, it must
4543
// be closed first
4644
if (portP != socketPortM) {
4745
debug1("%s (%d, %d) Socket tear-down", __PRETTY_FUNCTION__, portP, isUdpP);
@@ -102,7 +100,7 @@ void cIptvSocket::CloseSocket() {
102100
if (packetErrorsM) {
103101
info("Detected %d RTP packet errors", packetErrorsM);
104102
packetErrorsM = 0;
105-
lastErrorReportM = time(NULL);
103+
lastErrorReportM = time(nullptr);
106104
}
107105
}
108106

@@ -286,10 +284,10 @@ int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) {
286284
if (len > 0) {
287285
#ifndef __FreeBSD__
288286
// Process auxiliary received data and validate source address
289-
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg!=NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
290-
if ((cmsg->cmsg_level==SOL_IP) && (cmsg->cmsg_type==IP_PKTINFO)) {
287+
for (struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msgh); cmsg !=nullptr; cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
288+
if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
291289
struct in_pktinfo *i = (struct in_pktinfo *) CMSG_DATA(cmsg);
292-
if ((i->ipi_addr.s_addr==streamAddrM) || (htonl(INADDR_ANY)==streamAddrM)) {
290+
if ((i->ipi_addr.s_addr == streamAddrM) || (htonl(INADDR_ANY) == streamAddrM)) {
293291
#endif // __FreeBSD__
294292
if (bufferAddrP[0] == TS_SYNC_BYTE) {
295293
return len;
@@ -310,7 +308,7 @@ int cIptvUdpSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) {
310308
sequenceNumberM = -1;
311309
} else if ((sequenceNumberM >= 0) && (((sequenceNumberM + 1)%0xFFFF)!=seq)) {
312310
packetErrorsM++;
313-
if (time(NULL) - lastErrorReportM > eReportIntervalS) {
311+
if (time(nullptr) - lastErrorReportM > eReportIntervalS) {
314312
info("Detected %d RTP packet errors", packetErrorsM);
315313
packetErrorsM = 0;
316314
lastErrorReportM = time(nullptr);

tool/convm3u.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include <regex>
22
#include <sstream>
3-
#include <iostream>
4-
#include <set>
53
#include "m3upipe.h"
64
#include "convm3u.h"
75

tool/m3upipe.h

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Created by paul on 12/27/23.
33
//
44

5+
#include <string>
56
#include <stdlib.h>
67
#include <stdio.h>
78
#include <fcntl.h>

0 commit comments

Comments
 (0)