Fixed Codacy errors.

This commit is contained in:
Gonzalo Exequiel Pedone 2021-05-25 16:53:30 -03:00
parent 0957eb4be6
commit 84e639fd49
No known key found for this signature in database
GPG key ID: B8B09E63E9B85BAF
15 changed files with 43 additions and 39 deletions

View file

@ -69,7 +69,7 @@ namespace AkVCam {
const std::string &arguments,
const std::string &helpString,
const ProgramOptionsFunc &func,
const std::vector<CmdParserFlags> flags,
const std::vector<CmdParserFlags> &flags,
bool advanced);
};
@ -360,7 +360,7 @@ int AkVCam::CmdParser::parse(int argc, char **argv)
char *p = nullptr;
strtod(arg.c_str(), &p);
if (arg[0] == '-' && strlen(p) != 0) {
if (arg[0] == '-' && p && strnlen(p, 1024) != 0) {
auto flag = this->d->parserFlag(command->flags, arg);
if (!flag) {
@ -2361,7 +2361,7 @@ AkVCam::CmdParserCommand::CmdParserCommand(const std::string &command,
const std::string &arguments,
const std::string &helpString,
const AkVCam::ProgramOptionsFunc &func,
const std::vector<AkVCam::CmdParserFlags> flags,
const std::vector<AkVCam::CmdParserFlags> &flags,
bool advanced):
command(command),
arguments(arguments),

View file

@ -2,22 +2,22 @@
akvirtualcamera is virtual camera implemented as a DirectShow filter in Windows, and as a CoreMediaIO plugin in Mac.
## Features ##
## Features
* Supports emulated camera controls in capture devices (brightness, contrast, saturation, etc.).
* Configurable default picture in case no input signal available.
## Build and Install ##
## Build and Install
Visit the [wiki](https://github.com/webcamoid/akvirtualcamera/wiki) for a comprehensive compile and install instructions.
## Status ##
## Status
[![Build Status](https://travis-ci.com/webcamoid/akvirtualcamera.svg?branch=master)](https://travis-ci.com/webcamoid/akvirtualcamera)
[![Build status](https://ci.appveyor.com/api/projects/status/rwd4of9casmfmmys?svg=true)](https://ci.appveyor.com/project/hipersayanX/akvirtualcamera)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/1cee2645a3604633a506a203fb8c3161)](https://www.codacy.com/gh/webcamoid/akvirtualcamera/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=webcamoid/akvirtualcamera&amp;utm_campaign=Badge_Grade)
[![Daily Build](https://api.bintray.com/packages/webcamoid/webcamoid/akvirtualcamera/images/download.svg?version=daily)](https://bintray.com/webcamoid/webcamoid/akvirtualcamera/daily)
## Reporting Bugs ##
## Reporting Bugs
Report all issues in the [issues tracker](http://github.com/webcamoid/akvirtualcamera/issues).

View file

@ -92,7 +92,9 @@ void AkVCam::Logger::setLogLevel(int logLevel)
loggerPrivate()->logLevel = logLevel;
}
std::string AkVCam::Logger::header(int logLevel, const std::string file, int line)
std::string AkVCam::Logger::header(int logLevel,
const std::string &file,
int line)
{
auto now = std::chrono::system_clock::now();
auto nowMSecs =

View file

@ -60,7 +60,7 @@ namespace AkVCam
void setLogFile(const std::string &fileName);
int logLevel();
void setLogLevel(int logLevel);
std::string header(int logLevel, const std::string file, int line);
std::string header(int logLevel, const std::string &file, int line);
std::ostream &log(int logLevel);
int levelFromString(const std::string &level);
std::string levelToString(int level);

View file

@ -436,7 +436,7 @@ std::string AkVCam::SettingsPrivate::parseString(const std::string &str)
memset(hex, 0, 3);
for (size_t i = start; i < end; i++) {
if (str[i] == '\\' && i < str.size() - 2) {
if (i < str.size() - 2 && str[i] == '\\') {
auto key = strchr(escape_k, str[i + 1]);
if (key) {

View file

@ -263,7 +263,7 @@ size_t AkVCam::VideoFormat::planeSize(size_t plane) const
bool AkVCam::VideoFormat::isValid() const
{
if (this->size() <= 0)
if (this->size() < 1)
return false;
if (this->d->m_frameRates.empty())

View file

@ -553,7 +553,7 @@ void AkVCam::AssistantPrivate::controlsUpdated(xpc_connection_t client,
AkLogFunction();
std::string deviceId = xpc_dictionary_get_string(event, "device");
if (this->m_deviceConfigs.count(deviceId) <= 0) {
if (this->m_deviceConfigs.count(deviceId) < 1) {
AkLogError() << "'"
<< deviceId
<< "' device in not in the devices list."

View file

@ -187,7 +187,7 @@ std::string AkVCam::realPath(const std::string &path)
memset(realPath, 0, PATH_MAX);
readlink(resolvedPath, realPath, PATH_MAX);
if (strlen(realPath) < 1)
if (strnlen(realPath, PATH_MAX) < 1)
return {resolvedPath};
return {realPath};

View file

@ -69,7 +69,7 @@ std::string AkVCam::locatePluginPath()
GetModuleFileNameA(hmodule, path, MAX_PATH);
}
if (strlen(path) < 1)
if (strnlen(path, MAX_PATH) < 1)
return {};
return dirname(path);

View file

@ -311,7 +311,8 @@ HRESULT AkVCam::BaseFilter::QueryFilterInfo(FILTER_INFO *pInfo)
auto filterName = stringToWSTR(this->d->m_filterName);
memcpy(pInfo->achName,
filterName,
(std::min<size_t>)(wcslen(filterName) * sizeof(WCHAR),
(std::min<size_t>)(wcsnlen(filterName, MAX_FILTER_NAME)
* sizeof(WCHAR),
MAX_FILTER_NAME));
CoTaskMemFree(filterName);
}

View file

@ -702,7 +702,8 @@ HRESULT AkVCam::Pin::QueryPinInfo(PIN_INFO *pInfo)
auto pinName = stringToWSTR(this->d->m_pinName);
memcpy(pInfo->achName,
pinName,
(std::min<size_t>)(wcslen(pinName) * sizeof(WCHAR),
(std::min<size_t>)(wcsnlen(pinName, MAX_PIN_NAME)
* sizeof(WCHAR),
MAX_PIN_NAME));
CoTaskMemFree(pinName);
}

View file

@ -23,7 +23,7 @@ INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/webcamoid-data
if [ "${TRAVIS_OS_NAME}" = linux ]; then
sudo mount --bind root.x86_64 root.x86_64
sudo mount --bind $HOME root.x86_64/$HOME
sudo mount --bind "$HOME" "root.x86_64/$HOME"
cat << EOF > ${BUILDSCRIPT}
#!/bin/sh
@ -53,12 +53,12 @@ i686-w64-mingw32-cmake \
cmake --build .
EOF
chmod +x ${BUILDSCRIPT}
sudo cp -vf ${BUILDSCRIPT} root.x86_64/$HOME/
sudo cp -vf ${BUILDSCRIPT} "root.x86_64/$HOME/"
EXEC='sudo ./root.x86_64/bin/arch-chroot root.x86_64'
${EXEC} bash $HOME/${BUILDSCRIPT}
${EXEC} bash "$HOME/${BUILDSCRIPT}"
sudo umount root.x86_64/$HOME
sudo umount "root.x86_64/$HOME"
sudo umount root.x86_64
elif [ "${TRAVIS_OS_NAME}" = osx ]; then
mkdir build

View file

@ -28,7 +28,7 @@ DEPLOYSCRIPT=deployscript.sh
if [ "${TRAVIS_OS_NAME}" = linux ]; then
sudo mount --bind root.x86_64 root.x86_64
sudo mount --bind $HOME root.x86_64/$HOME
sudo mount --bind "$HOME" "root.x86_64/$HOME"
cat << EOF > package_info_strip.conf
[System]
@ -73,10 +73,10 @@ python ./DeployTools/deploy.py \
-o "\${PACKAGES_DIR}"
EOF
chmod +x ${DEPLOYSCRIPT}
sudo cp -vf ${DEPLOYSCRIPT} root.x86_64/$HOME/
sudo cp -vf ${DEPLOYSCRIPT} "root.x86_64/$HOME/"
${EXEC} bash $HOME/${DEPLOYSCRIPT}
sudo umount root.x86_64/$HOME
${EXEC} bash "$HOME/${DEPLOYSCRIPT}"
sudo umount "root.x86_64/$HOME"
sudo umount root.x86_64
elif [ "${TRAVIS_OS_NAME}" = osx ]; then
cd build

View file

@ -34,7 +34,7 @@ if [ "${TRAVIS_OS_NAME}" = linux ]; then
# Download chroot image
archImage=archlinux-bootstrap-${ARCH_ROOT_DATE}-x86_64.tar.gz
${DOWNLOAD_CMD} ${ARCH_ROOT_URL}/iso/${ARCH_ROOT_DATE}/$archImage
sudo tar xzf $archImage
sudo tar xzf "$archImage"
# Configure mirrors
cp -vf root.x86_64/etc/pacman.conf .
@ -59,9 +59,9 @@ EOF
sudo cp -vf mirrorlist root.x86_64/etc/pacman.d/mirrorlist
# Install packages
sudo mkdir -pv root.x86_64/$HOME
sudo mkdir -pv "root.x86_64/$HOME"
sudo mount --bind root.x86_64 root.x86_64
sudo mount --bind $HOME root.x86_64/$HOME
sudo mount --bind "$HOME" "root.x86_64/$HOME"
${EXEC} pacman-key --init
${EXEC} pacman-key --populate archlinux
@ -89,7 +89,7 @@ EOF
nsis=nsis-${NSIS_VERSION}-setup.exe
${DOWNLOAD_CMD} "https://sourceforge.net/projects/nsis/files/NSIS%20${NSIS_VERSION:0:1}/${NSIS_VERSION}/${nsis}"
if [ -e ${nsis} ]; then
if [ -e "${nsis}" ]; then
INSTALLSCRIPT=installscript.sh
cat << EOF > ${INSTALLSCRIPT}
@ -104,12 +104,12 @@ wine ./${nsis} /S
EOF
chmod +x ${INSTALLSCRIPT}
sudo cp -vf ${INSTALLSCRIPT} root.x86_64/$HOME/
${EXEC} bash $HOME/${INSTALLSCRIPT}
sudo cp -vf ${INSTALLSCRIPT} "root.x86_64/$HOME/"
${EXEC} bash "$HOME/${INSTALLSCRIPT}"
fi
# Finish
sudo umount root.x86_64/$HOME
sudo umount "root.x86_64/$HOME"
sudo umount root.x86_64
elif [ "${TRAVIS_OS_NAME}" = osx ]; then
brew update
@ -126,7 +126,7 @@ elif [ "${TRAVIS_OS_NAME}" = osx ]; then
# Install Qt Installer Framework
qtIFW=QtInstallerFramework-macOS-x86_64-${QTIFWVER}.dmg
${DOWNLOAD_CMD} http://download.qt.io/official_releases/qt-installer-framework/${QTIFWVER}/${qtIFW} || true
${DOWNLOAD_CMD} "http://download.qt.io/official_releases/qt-installer-framework/${QTIFWVER}/${qtIFW}" || true
if [ -e "${qtIFW}" ]; then
hdiutil convert ${qtIFW} -format UDZO -o qtifw

View file

@ -45,23 +45,23 @@ if [[ ! -z "$DAILY_BUILD" || ! -z "$RELEASE_BUILD" ]]; then
./jfrog bt config \
--user=hipersayanx \
--key=$BT_KEY \
--key="$BT_KEY" \
--licenses=GPL-3.0-or-later
path=webcamoid-packages
for f in $(find $path -type f); do
packagePath=${f#$path/}
folder=$(dirname $packagePath)
folder=$(dirname "$packagePath")
./jfrog bt upload \
--user=hipersayanx \
--key=$BT_KEY \
--override=true \
--publish=$publish \
$f \
"$f" \
webcamoid/webcamoid/akvirtualcamera/$version \
$folder/
"$folder/"
done
# Upload to Github Releases
@ -76,11 +76,11 @@ if [[ ! -z "$DAILY_BUILD" || ! -z "$RELEASE_BUILD" ]]; then
hub=hub-darwin-amd64-${GITHUB_HUBVER}
fi
cd ${TRAVIS_BUILD_DIR}
${DOWNLOAD_CMD} https://github.com/github/hub/releases/download/v${GITHUB_HUBVER}/${hub}.tgz || true
cd "${TRAVIS_BUILD_DIR}"
${DOWNLOAD_CMD} "https://github.com/github/hub/releases/download/v${GITHUB_HUBVER}/${hub}.tgz" || true
tar xzf ${hub}.tgz
mkdir -p .local
cp -rf ${hub}/* .local/
cp -rf "${hub}"/* .local/
export PATH="${PWD}/.local/bin:${PATH}"