correct CodeQL problems

This commit is contained in:
Paulchen-Panther 2023-10-16 13:43:58 +02:00
parent f117a769b5
commit bbf0a72f88
5 changed files with 30 additions and 40 deletions

View File

@ -81,17 +81,22 @@ jobs:
- name: 👷 Build - name: 👷 Build
shell: bash shell: bash
run: | run: |
DISTRIBUTION=$(echo '${{ matrix.os.distribution }}' | tr '[:upper:]' '[:lower:]') echo '::group::Set distribution name to lower case'
mkdir -p "${GITHUB_WORKSPACE}/deploy" DISTRIBUTION=$(echo '${{ matrix.os.distribution }}' | tr '[:upper:]' '[:lower:]')
docker run --rm --platform=${{ matrix.architecture[1] }} \ echo '::endgroup::'
-w "/root" \
-v "${GITHUB_WORKSPACE}/deploy:/deploy" \ echo '::group::Building Hyperion'
-v "${GITHUB_WORKSPACE}:/root/hyperion.ng:rw" \ mkdir -p "${GITHUB_WORKSPACE}/deploy"
ghcr.io/${{ env.ghcr }}/${DISTRIBUTION}:${{ matrix.os.version }} \ docker run --rm --platform=${{ matrix.architecture[1] }} \
/bin/bash -c "tar -czf rpmbuild/SOURCES/hyperion.ng.tar.gz hyperion.ng/ && \ -w "/root" \
cp -f hyperion.ng/rpmbuild/hyperion.spec.in rpmbuild/SPECS/hyperion.spec && \ -v "${GITHUB_WORKSPACE}/deploy:/deploy" \
rpmbuild -ba --define '_version ${{ env.VERSION }}' rpmbuild/SPECS/hyperion.spec --clean && \ -v "${GITHUB_WORKSPACE}:/root/hyperion.ng:rw" \
cp -fv rpmbuild/RPMS/$(uname -m)/hyperion* /deploy" ghcr.io/${{ env.ghcr }}/${DISTRIBUTION}:${{ matrix.os.version }} \
/bin/bash -c "tar -czf rpmbuild/SOURCES/hyperion.ng.tar.gz hyperion.ng/ && \
cp -f hyperion.ng/rpmbuild/hyperion.spec.in rpmbuild/SPECS/hyperion.spec && \
rpmbuild -ba --define '_version ${{ env.VERSION }}' rpmbuild/SPECS/hyperion.spec --clean && \
cp -fv rpmbuild/RPMS/$(uname -m)/hyperion* /deploy"
echo '::endgroup::'
env: env:
ACTOR: "Hyperion Project <admin@hyperion-project.org>" ACTOR: "Hyperion Project <admin@hyperion-project.org>"
COMMIT_MESSAGE: ${{ github.event.commits[0].message }} COMMIT_MESSAGE: ${{ github.event.commits[0].message }}
@ -143,17 +148,18 @@ jobs:
declare -A distArray=([fc]=fedora [el]=rhel) declare -A distArray=([fc]=fedora [el]=rhel)
for file in artifact/hyperion-*.rpm; do for file in artifact/hyperion-*.rpm; do
if [ -f "$file" ]; then if [ -f "$file" ]; then
dist_ver_arch=${file##*0.} dist_ver_arch=$(basename -- "$file")
dist_ver_arch=${dist_ver_arch%.*} dist_ver_arch=${dist_ver_arch%.*}
dist_ver=${dist_ver_arch%.*} dist_ver=${dist_ver_arch%.*}
dist_ver=${dist_ver##*.}
[ -z "${dist_ver:0:2}" ] && continue [ -z "${dist_ver:0:2}" ] && continue
rpm=rpm/${distArray[${dist_ver:0:2}]}/${dist_ver:2}/${dist_ver_arch#*.} rpm=rpm/${distArray[${dist_ver:0:2}]}/${dist_ver:2}/${dist_ver_arch##*.}
mkdir -p $rpm/ && cp $file $rpm/ mkdir -p $rpm/ && cp $file $rpm/
rpm --define "_gpg_name ${{ steps.import_gpg.outputs.keyid }}" --addsign $rpm/*.rpm rpm --define "_gpg_name ${{ steps.import_gpg.outputs.keyid }}" --addsign $rpm/*.rpm
rpm --checksig $rpm/*.rpm rpm --checksig $rpm/*.rpm
createrepo $rpm/ createrepo $rpm/
gpg --yes --detach-sign --armor $rpm/repodata/repomd.xml gpg --yes --detach-sign --armor $rpm/repodata/repomd.xml
sed -r "s/@CHANNEL@/${channel}/g; s/@DIST@/${distArray[${dist_ver:0:2}]}/g; s/@ARCH@/${dist_ver_arch#*.}/g" ${GITHUB_WORKSPACE}/rpmbuild/hyperion.repo.in > rpm/${distArray[${dist_ver:0:2}]}/hyperion.repo sed -r "s/@CHANNEL@/${channel}/g; s/@DIST@/${distArray[${dist_ver:0:2}]}/g; s/@ARCH@/${dist_ver_arch##*.}/g" ${GITHUB_WORKSPACE}/rpmbuild/hyperion.repo.in > rpm/${distArray[${dist_ver:0:2}]}/hyperion.repo
fi fi
done done
echo '::endgroup::' echo '::endgroup::'

View File

@ -26,17 +26,6 @@
<release version="2.0.14" date="2022-11-27" /> <release version="2.0.14" date="2022-11-27" />
<release version="2.0.13" date="2022-05-22" /> <release version="2.0.13" date="2022-05-22" />
<release version="2.0.12" date="2021-11-21" /> <release version="2.0.12" date="2021-11-21" />
<release version="2.0.0-alpha.11" date="2021-10-06" />
<release version="2.0.0-alpha.10" date="2021-07-18" />
<release version="2.0.0-alpha.9" date="2020-11-19" />
<release version="2.0.0-alpha.8" date="2020-09-15" />
<release version="2.0.0-alpha.7" date="2020-07-24" />
<release version="2.0.0-alpha.6" date="2020-05-28" />
<release version="2.0.0-alpha.5" date="2020-04-17" />
<release version="2.0.0-alpha.4" date="2020-03-27" />
<release version="2.0.0-alpha.3" date="2020-03-01" />
<release version="2.0.0-alpha.2" date="2020-02-20" />
<release version="2.0.0-alpha.1" date="2020-02-16" />
</releases> </releases>
<screenshots> <screenshots>

View File

@ -136,11 +136,11 @@ class EncoderThreadManager : public QObject
public: public:
explicit EncoderThreadManager(QObject *parent = nullptr) explicit EncoderThreadManager(QObject *parent = nullptr)
: QObject(parent) : QObject(parent)
, _threadCount(static_cast<unsigned long>(qMax(QThread::idealThreadCount(), DEFAULT_THREAD_COUNT))) , _threadCount(qMax(QThread::idealThreadCount(), DEFAULT_THREAD_COUNT))
, _threads(nullptr) , _threads(nullptr)
{ {
_threads = new Thread<EncoderThread>*[_threadCount]; _threads = new Thread<EncoderThread>*[_threadCount];
for (unsigned long i = 0; i < _threadCount; i++) for (int i = 0; i < _threadCount; i++)
{ {
_threads[i] = new Thread<EncoderThread>(new EncoderThread, this); _threads[i] = new Thread<EncoderThread>(new EncoderThread, this);
_threads[i]->setObjectName("Encoder " + QString::number(i)); _threads[i]->setObjectName("Encoder " + QString::number(i));
@ -151,7 +151,7 @@ public:
{ {
if (_threads != nullptr) if (_threads != nullptr)
{ {
for(unsigned long i = 0; i < _threadCount; i++) for(int i = 0; i < _threadCount; i++)
{ {
_threads[i]->deleteLater(); _threads[i]->deleteLater();
_threads[i] = nullptr; _threads[i] = nullptr;
@ -165,18 +165,18 @@ public:
void start() void start()
{ {
if (_threads != nullptr) if (_threads != nullptr)
for (unsigned long i = 0; i < _threadCount; i++) for (int i = 0; i < _threadCount; i++)
connect(_threads[i]->thread(), &EncoderThread::newFrame, this, &EncoderThreadManager::newFrame); connect(_threads[i]->thread(), &EncoderThread::newFrame, this, &EncoderThreadManager::newFrame);
} }
void stop() void stop()
{ {
if (_threads != nullptr) if (_threads != nullptr)
for(unsigned long i = 0; i < _threadCount; i++) for(int i = 0; i < _threadCount; i++)
disconnect(_threads[i]->thread(), nullptr, nullptr, nullptr); disconnect(_threads[i]->thread(), nullptr, nullptr, nullptr);
} }
unsigned long _threadCount; int _threadCount;
Thread<EncoderThread>** _threads; Thread<EncoderThread>** _threads;
signals: signals:

View File

@ -209,11 +209,6 @@ bool AudioGrabberLinux::start()
_isRunning.store(true, std::memory_order_release); _isRunning.store(true, std::memory_order_release);
pthread_attr_t threadAttributes; pthread_attr_t threadAttributes;
// int threadPriority = 1;
// sched_param schedulerParameter;
// schedulerParameter.sched_priority = threadPriority;
if (pthread_attr_init(&threadAttributes) != 0) if (pthread_attr_init(&threadAttributes) != 0)
{ {
Debug(_log, "Failed to create thread attributes"); Debug(_log, "Failed to create thread attributes");

View File

@ -1018,7 +1018,7 @@ bool V4L2Grabber::process_image(const void *p, int size)
} }
else if (_threadManager != nullptr) else if (_threadManager != nullptr)
{ {
for (unsigned long i = 0; i < _threadManager->_threadCount; i++) for (int i = 0; i < _threadManager->_threadCount; i++)
{ {
if (!_threadManager->_threads[i]->isBusy()) if (!_threadManager->_threads[i]->isBusy())
{ {
@ -1290,11 +1290,11 @@ QJsonArray V4L2Grabber::discover(const QJsonObject& params)
format["format"] = pixelFormatToString(encodingFormat); format["format"] = pixelFormatToString(encodingFormat);
QMap<std::pair<int, int>, QSet<int>> combined = QMap<std::pair<int, int>, QSet<int>>(); QMap<std::pair<int, int>, QSet<int>> combined = QMap<std::pair<int, int>, QSet<int>>();
for (auto enc : input.value().encodingFormats.values(encodingFormat)) for (const auto &enc : input.value().encodingFormats.values(encodingFormat))
{ {
std::pair<int, int> width_height{enc.width, enc.height}; std::pair<int, int> width_height{enc.width, enc.height};
auto &com = combined[width_height]; auto &com = combined[width_height];
for (auto framerate : qAsConst(enc.framerates)) for (auto framerate : enc.framerates)
{ {
com.insert(framerate); com.insert(framerate);
} }
@ -1326,7 +1326,7 @@ QJsonArray V4L2Grabber::discover(const QJsonObject& params)
device["video_inputs"] = video_inputs; device["video_inputs"] = video_inputs;
QJsonObject controls, controls_default; QJsonObject controls, controls_default;
for (const auto &control : qAsConst(_deviceControls[device_property.key()])) for (const auto &control : std::as_const(_deviceControls[device_property.key()]))
{ {
QJsonObject property; QJsonObject property;
property["minValue"] = control.minValue; property["minValue"] = control.minValue;