From 3a53676253e253055cff3d2ba4f643a071d4dac8 Mon Sep 17 00:00:00 2001 From: John McQuah Date: Thu, 8 Jun 2023 07:04:48 -0400 Subject: [PATCH] fix several compile warnings (-Wreorder, unused parameter) --- src/argparser.h | 2 +- src/installtransaction.cpp | 5 +---- src/installtransaction.h | 9 ++++----- src/package.cpp | 14 ++++++-------- src/package.h | 6 +++--- src/process.cpp | 8 ++++---- src/process.h | 4 ++-- src/prtget.cpp | 23 ++++++++--------------- src/prtget.h | 2 +- src/signaldispatcher.cpp | 2 +- src/signaldispatcher.h | 2 +- 11 files changed, 32 insertions(+), 45 deletions(-) diff --git a/src/argparser.h b/src/argparser.h index 0c02792..050fdcd 100644 --- a/src/argparser.h +++ b/src/argparser.h @@ -127,6 +127,7 @@ private: string m_pkgaddArgs; string m_pkgrmArgs; string m_filter; + string m_sortArgs; string m_commandName; string m_unknownOption; string m_installRoot; @@ -139,7 +140,6 @@ private: int m_verbose; - string m_sortArgs; list m_otherArgs; list< pair > m_configData; diff --git a/src/installtransaction.cpp b/src/installtransaction.cpp index c5df06a..400b3d8 100644 --- a/src/installtransaction.cpp +++ b/src/installtransaction.cpp @@ -658,9 +658,6 @@ bool InstallTransaction::calcDependencies( ) } -/* - * getPkgDest assumes that you're in the build directory already - */ string InstallTransaction::getPkgmkSetting(const string& setting) { string value = ""; @@ -696,7 +693,7 @@ string InstallTransaction::getPkgmkSettingFromFile(const string& setting, const if (p) { fgets(line, 256, p); value = StringHelper::stripWhiteSpace(line); - fclose(p); + pclose(p); } } diff --git a/src/installtransaction.h b/src/installtransaction.h index ebfc215..cca802d 100644 --- a/src/installtransaction.h +++ b/src/installtransaction.h @@ -121,21 +121,20 @@ private: // packages< pair > installed by this transaction list< pair > m_installedPackages; - // packages which were requested to be installed which where already + // packages requested to be installed, but already present list m_alreadyInstalledPackages; - // packages which are required by the transaction, but ignored by - // the user + // packages required by the transaction, but ignored by the user list m_ignoredPackages; list m_depNameList; vector m_depList; vector treeWalk; - // packages requested to be installed not found in the ports tree + // packages requested to be installed, but not found in the ports tree list< pair > m_missingPackages; - // packages where build/installed failed + // packages where build/install failed list< pair > m_installErrors; /// prt-get itself diff --git a/src/package.cpp b/src/package.cpp index f547658..ce484ac 100644 --- a/src/package.cpp +++ b/src/package.cpp @@ -124,7 +124,7 @@ const string& Package::maintainer() const } /*! \return whether or not this package has a readme file */ -const bool Package::hasReadme() const +bool Package::hasReadme() const { load(); return m_data->hasReadme; @@ -137,12 +137,12 @@ string Package::versionReleaseString() const return m_data->versionReleaseString; } -const bool Package::hasPreInstall() const +bool Package::hasPreInstall() const { return m_data->hasPreInstall; } -const bool Package::hasPostInstall() const +bool Package::hasPostInstall() const { return m_data->hasPostInstall; } @@ -345,11 +345,9 @@ void Package::expandShellCommands(std::string& input, pos = 0; while ((pos = input.find(startTag[i], pos)) != string::npos) { - if (unameBuf.release) { - input = replaceAll(input, - startTag[i] + "uname -r" + endTag[i], - unameBuf.release); - } + input = replaceAll(input, + startTag[i] + "uname -r" + endTag[i], + unameBuf.release); dpos = input.find(startTag[i] + "date"); if (dpos != string::npos) { diff --git a/src/package.h b/src/package.h index 2bcf1e9..d59d727 100644 --- a/src/package.h +++ b/src/package.h @@ -52,9 +52,9 @@ public: const std::string& url() const; const std::string& optionals() const; const std::string& maintainer() const; - const bool hasReadme() const; - const bool hasPreInstall() const; - const bool hasPostInstall() const; + bool hasReadme() const; + bool hasPreInstall() const; + bool hasPostInstall() const; std::string versionReleaseString() const; diff --git a/src/process.cpp b/src/process.cpp index c5865cd..0a6b255 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -68,9 +68,9 @@ int Process::execute() int status = 0; if ( m_fdlog > 0 ) { - status = execLog(argc, argv); + status = execLog(argv); } else { - status = exec(argc, argv); + status = exec(argv); } delete [] argv; @@ -78,7 +78,7 @@ int Process::execute() } -int Process::execLog(const int argc, char** argv) +int Process::execLog(char** argv) { int status = 0; int fdpipe[2]; @@ -123,7 +123,7 @@ int Process::execLog(const int argc, char** argv) } -int Process::exec(const int argc, char** argv) +int Process::exec(char** argv) { int status = 0; pid_t pid = fork(); diff --git a/src/process.h b/src/process.h index 416e65a..97433fc 100644 --- a/src/process.h +++ b/src/process.h @@ -32,8 +32,8 @@ public: private: - int exec(const int argc, char** argv); - int execLog(const int argc, char** argv); + int exec(char** argv); + int execLog(char** argv); int execShell(const char* shell); int execShellLog(const char* shell); diff --git a/src/prtget.cpp b/src/prtget.cpp index ed7f69a..4354312 100644 --- a/src/prtget.cpp +++ b/src/prtget.cpp @@ -554,9 +554,6 @@ void PrtGet::listInstalled() { void PrtGet::install( bool dependencies ) { assertMinArgCount(1); - const list& args = m_parser->otherArgs(); - list::const_iterator it = args.begin(); - initRepo(); if (dependencies) { @@ -634,7 +631,7 @@ void PrtGet::executeTransaction( InstallTransaction& transaction ) { cout << m_appName << ": can't create lock file for the log file. " << "\nMaybe there's another instance of prt-get using the same " << - "file." << "\nIf this is a stale not, please remove " << endl; + "file." << "\nIf this is a stale note, please remove " << endl; failed = true; break; default: @@ -1342,7 +1339,7 @@ void PrtGet::current() { } } -SignalHandler::HandlerResult PrtGet::handleSignal( int signal ) +SignalHandler::HandlerResult PrtGet::handleSignal() { // TODO: second argument could also be true: // TODO: kill installtransaction @@ -1561,10 +1558,7 @@ void PrtGet::cat() { string arg = *it; const Package* p = m_repo->getPackage( arg ); if ( p ) { - string fileName = "Pkgfile"; - if (++it != m_parser->otherArgs().end()) { - fileName = *it; - } + string fileName = (++it != m_parser->otherArgs().end()) ? *it : "Pkgfile"; string file = p->path() + "/" + p->name() + "/" + fileName; if (!printFile(file)) { cerr << "File '" << fileName << "' not found" << endl; @@ -1598,11 +1592,8 @@ void PrtGet::remove() { list::const_iterator it = args.begin(); for ( ; it != args.end(); ++it ) { if (m_pkgDB->isInstalled(*it)) { - // TODO: prettify - string args = ""; - if (m_parser->installRoot() != "") { - args = "-r " + m_parser->installRoot() + " "; - } + string args = (m_parser->installRoot() == "") ? "" : + "-r " + m_parser->installRoot() + " "; args += (m_parser->pkgrmArgs() + " " + *it); Process proc(command, args); @@ -1696,6 +1687,8 @@ void PrtGet::printDepTree() { return; } else if (reverse) { depTreeHeader = "Packages that depend on " + p->name(); + } else { + depTreeHeader = "Packages needed by " + p->name(); } if ( !m_followSoftdeps ) { @@ -1928,7 +1921,7 @@ void PrtGet::dumpConfig() { cout.setf( ios::left, ios::adjustfield ); cout.width( 20 ); cout.fill( ' ' ); - cout << "Pkgmk settings: " << m_config->logFilePattern() << endl; + cout << "Pkgmk settings: " << endl; cout.setf( ios::left, ios::adjustfield ); cout.width( 20 ); cout.fill( ' ' ); diff --git a/src/prtget.h b/src/prtget.h index 48f69b6..88bd7bf 100644 --- a/src/prtget.h +++ b/src/prtget.h @@ -87,7 +87,7 @@ public: int returnValue() const; - SignalHandler::HandlerResult handleSignal( int signal ); + SignalHandler::HandlerResult handleSignal(); protected: diff --git a/src/signaldispatcher.cpp b/src/signaldispatcher.cpp index 0c717a3..9db4363 100644 --- a/src/signaldispatcher.cpp +++ b/src/signaldispatcher.cpp @@ -36,7 +36,7 @@ void SignalDispatcher::dispatch( int signalNumber ) map::iterator it = SignalDispatcher::instance()->m_signalHandlers.find( signalNumber ); if ( it != SignalDispatcher::instance()->m_signalHandlers.end() ) { - it->second->handleSignal( signalNumber ); + it->second->handleSignal(); } else { cerr << "prt-get: caught signal " << signalNumber << endl; } diff --git a/src/signaldispatcher.h b/src/signaldispatcher.h index d29cdab..0902796 100644 --- a/src/signaldispatcher.h +++ b/src/signaldispatcher.h @@ -28,7 +28,7 @@ public: EXIT, /*!< signal handled, exit now */ CONTINUE /*!< signal handled, don't exit */ }; - virtual HandlerResult handleSignal( int signalNumber ) = 0; + virtual HandlerResult handleSignal() = 0; }; /*!