From bbf0a72f88d0dcf5a5ce5aeda07707c391e43798 Mon Sep 17 00:00:00 2001 From: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:43:58 +0200 Subject: [PATCH] correct CodeQL problems --- .github/workflows/dnf.yml | 34 +++++++++++++--------- cmake/desktop/hyperion.metainfo.xml | 11 ------- include/grabber/EncoderThread.h | 12 ++++---- libsrc/grabber/audio/AudioGrabberLinux.cpp | 5 ---- libsrc/grabber/video/v4l2/V4L2Grabber.cpp | 8 ++--- 5 files changed, 30 insertions(+), 40 deletions(-) diff --git a/.github/workflows/dnf.yml b/.github/workflows/dnf.yml index 42676f54..be5df5f0 100644 --- a/.github/workflows/dnf.yml +++ b/.github/workflows/dnf.yml @@ -81,17 +81,22 @@ jobs: - name: 👷 Build shell: bash run: | - DISTRIBUTION=$(echo '${{ matrix.os.distribution }}' | tr '[:upper:]' '[:lower:]') - mkdir -p "${GITHUB_WORKSPACE}/deploy" - docker run --rm --platform=${{ matrix.architecture[1] }} \ - -w "/root" \ - -v "${GITHUB_WORKSPACE}/deploy:/deploy" \ - -v "${GITHUB_WORKSPACE}:/root/hyperion.ng:rw" \ - 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 '::group::Set distribution name to lower case' + DISTRIBUTION=$(echo '${{ matrix.os.distribution }}' | tr '[:upper:]' '[:lower:]') + echo '::endgroup::' + + echo '::group::Building Hyperion' + mkdir -p "${GITHUB_WORKSPACE}/deploy" + docker run --rm --platform=${{ matrix.architecture[1] }} \ + -w "/root" \ + -v "${GITHUB_WORKSPACE}/deploy:/deploy" \ + -v "${GITHUB_WORKSPACE}:/root/hyperion.ng:rw" \ + 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: ACTOR: "Hyperion Project " COMMIT_MESSAGE: ${{ github.event.commits[0].message }} @@ -143,17 +148,18 @@ jobs: declare -A distArray=([fc]=fedora [el]=rhel) for file in artifact/hyperion-*.rpm; do if [ -f "$file" ]; then - dist_ver_arch=${file##*0.} + dist_ver_arch=$(basename -- "$file") dist_ver_arch=${dist_ver_arch%.*} dist_ver=${dist_ver_arch%.*} + dist_ver=${dist_ver##*.} [ -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/ rpm --define "_gpg_name ${{ steps.import_gpg.outputs.keyid }}" --addsign $rpm/*.rpm rpm --checksig $rpm/*.rpm createrepo $rpm/ 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 done echo '::endgroup::' diff --git a/cmake/desktop/hyperion.metainfo.xml b/cmake/desktop/hyperion.metainfo.xml index f0f286e1..bc1ac7e6 100644 --- a/cmake/desktop/hyperion.metainfo.xml +++ b/cmake/desktop/hyperion.metainfo.xml @@ -26,17 +26,6 @@ - - - - - - - - - - - diff --git a/include/grabber/EncoderThread.h b/include/grabber/EncoderThread.h index 93a3ed88..51008d3e 100644 --- a/include/grabber/EncoderThread.h +++ b/include/grabber/EncoderThread.h @@ -136,11 +136,11 @@ class EncoderThreadManager : public QObject public: explicit EncoderThreadManager(QObject *parent = nullptr) : QObject(parent) - , _threadCount(static_cast(qMax(QThread::idealThreadCount(), DEFAULT_THREAD_COUNT))) + , _threadCount(qMax(QThread::idealThreadCount(), DEFAULT_THREAD_COUNT)) , _threads(nullptr) { _threads = new Thread*[_threadCount]; - for (unsigned long i = 0; i < _threadCount; i++) + for (int i = 0; i < _threadCount; i++) { _threads[i] = new Thread(new EncoderThread, this); _threads[i]->setObjectName("Encoder " + QString::number(i)); @@ -151,7 +151,7 @@ public: { if (_threads != nullptr) { - for(unsigned long i = 0; i < _threadCount; i++) + for(int i = 0; i < _threadCount; i++) { _threads[i]->deleteLater(); _threads[i] = nullptr; @@ -165,18 +165,18 @@ public: void start() { 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); } void stop() { 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); } - unsigned long _threadCount; + int _threadCount; Thread** _threads; signals: diff --git a/libsrc/grabber/audio/AudioGrabberLinux.cpp b/libsrc/grabber/audio/AudioGrabberLinux.cpp index 84898601..7429135e 100644 --- a/libsrc/grabber/audio/AudioGrabberLinux.cpp +++ b/libsrc/grabber/audio/AudioGrabberLinux.cpp @@ -209,11 +209,6 @@ bool AudioGrabberLinux::start() _isRunning.store(true, std::memory_order_release); pthread_attr_t threadAttributes; - // int threadPriority = 1; - - // sched_param schedulerParameter; - // schedulerParameter.sched_priority = threadPriority; - if (pthread_attr_init(&threadAttributes) != 0) { Debug(_log, "Failed to create thread attributes"); diff --git a/libsrc/grabber/video/v4l2/V4L2Grabber.cpp b/libsrc/grabber/video/v4l2/V4L2Grabber.cpp index f37c5f1b..8f504464 100644 --- a/libsrc/grabber/video/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/video/v4l2/V4L2Grabber.cpp @@ -1018,7 +1018,7 @@ bool V4L2Grabber::process_image(const void *p, int size) } 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()) { @@ -1290,11 +1290,11 @@ QJsonArray V4L2Grabber::discover(const QJsonObject& params) format["format"] = pixelFormatToString(encodingFormat); QMap, QSet> combined = QMap, QSet>(); - for (auto enc : input.value().encodingFormats.values(encodingFormat)) + for (const auto &enc : input.value().encodingFormats.values(encodingFormat)) { std::pair width_height{enc.width, enc.height}; auto &com = combined[width_height]; - for (auto framerate : qAsConst(enc.framerates)) + for (auto framerate : enc.framerates) { com.insert(framerate); } @@ -1326,7 +1326,7 @@ QJsonArray V4L2Grabber::discover(const QJsonObject& params) device["video_inputs"] = video_inputs; 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; property["minValue"] = control.minValue;