From 62d8a765b9b37354efab6ca838cbdb7f347f7cac Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 16 Jan 2014 19:51:23 +0100 Subject: rework some code to fix some scan-build warnings No visible functional changes, just code moved around and additional checks to eliminate impossible branches Reported-By: scan-build Git-Dch: Ignore --- ftparchive/override.cc | 56 +++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 30 deletions(-) (limited to 'ftparchive/override.cc') diff --git a/ftparchive/override.cc b/ftparchive/override.cc index 1288ff133..d2130db8a 100644 --- a/ftparchive/override.cc +++ b/ftparchive/override.cc @@ -52,45 +52,41 @@ bool Override::ReadOverride(string const &File,bool const &Source) if (*Pkg == 0) continue; +#define APT_FIND_NEXT_FIELD \ + for (End++; isspace(*End) != 0 && *End != 0; ++End) \ + /* skip spaces */ ; \ + Start = End; \ + for (; isspace(*End) == 0 && *End != 0; ++End) \ + /* find end of word */ ; + +#define APT_WARNING_MALFORMED_LINE(FIELD) \ + if (*End == 0) \ + { \ + _error->Warning(_("Malformed override %s line %llu (%s)"),File.c_str(), \ + Counter, FIELD ); \ + continue; \ + } \ + *End = 0; + // Find the package and zero.. - char *Start = Pkg; + char *Start; char *End = Pkg; for (; isspace(*End) == 0 && *End != 0; End++); - if (*End == 0) - { - _error->Warning(_("Malformed override %s line %llu #1"),File.c_str(), - Counter); - continue; - } - *End = 0; + APT_WARNING_MALFORMED_LINE("pkgname"); + + APT_FIND_NEXT_FIELD; // Find the priority if (Source == false) { - for (End++; isspace(*End) != 0 && *End != 0; End++); - Start = End; - for (; isspace(*End) == 0 && *End != 0; End++); - if (*End == 0) - { - _error->Warning(_("Malformed override %s line %llu #2"),File.c_str(), - Counter); - continue; - } - *End = 0; + APT_WARNING_MALFORMED_LINE("priority"); Itm.Priority = Start; + + APT_FIND_NEXT_FIELD; } - + // Find the Section - for (End++; isspace(*End) != 0 && *End != 0; End++); - Start = End; - for (; isspace(*End) == 0 && *End != 0; End++); - if (*End == 0) - { - _error->Warning(_("Malformed override %s line %llu #3"),File.c_str(), - Counter); - continue; - } - *End = 0; + APT_WARNING_MALFORMED_LINE("section"); Itm.FieldOverride["Section"] = Start; // Source override files only have the two columns @@ -99,7 +95,7 @@ bool Override::ReadOverride(string const &File,bool const &Source) Mapping[Pkg] = Itm; continue; } - + // Find the => for (End++; isspace(*End) != 0 && *End != 0; End++); if (*End != 0) -- cgit v1.2.3 From d3e8fbb395f57954acd7a2095f02ce530a05ec6a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 27 Feb 2014 01:20:53 +0100 Subject: =?UTF-8?q?warning:=20extra=20=E2=80=98;=E2=80=99=20[-Wpedantic]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Git-Dch: Ignore Reported-By: gcc -Wpedantic --- ftparchive/override.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ftparchive/override.cc') diff --git a/ftparchive/override.cc b/ftparchive/override.cc index d2130db8a..82cbc4c19 100644 --- a/ftparchive/override.cc +++ b/ftparchive/override.cc @@ -201,7 +201,7 @@ bool Override::ReadExtraOverride(string const &File,bool const &Source) } /*}}}*/ -// Override::GetItem - Get a architecture specific item /*{{{*/ +// Override::GetItem - Get a architecture specific item /*{{{*/ // --------------------------------------------------------------------- /* Returns a override item for the given package and the given architecture. * Treats "all" special @@ -232,10 +232,10 @@ Override::Item* Override::GetItem(string const &Package, string const &Architect { result->FieldOverride[foI->first] = foI->second; } - } - } + } + } return result; -}; +} // Override::Item::SwapMaint - Swap the maintainer field if necessary /*{{{*/ -- cgit v1.2.3 From 655122418d714f342b5d9789f45f8035f3fe8b9a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sat, 1 Mar 2014 15:11:42 +0100 Subject: =?UTF-8?q?warning:=20unused=20parameter=20=E2=80=98foo=E2=80=99?= =?UTF-8?q?=20[-Wunused-parameter]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-By: gcc -Wunused-parameter Git-Dch: Ignore --- ftparchive/override.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ftparchive/override.cc') diff --git a/ftparchive/override.cc b/ftparchive/override.cc index 82cbc4c19..38d76a6a3 100644 --- a/ftparchive/override.cc +++ b/ftparchive/override.cc @@ -129,7 +129,7 @@ bool Override::ReadOverride(string const &File,bool const &Source) // Override::ReadExtraOverride - Read the extra override file /*{{{*/ // --------------------------------------------------------------------- /* This parses the extra override file and reads it into the map */ -bool Override::ReadExtraOverride(string const &File,bool const &Source) +bool Override::ReadExtraOverride(string const &File,bool const &/*Source*/) { if (File.empty() == true) return true; -- cgit v1.2.3 From 453b82a388013e522b3a1b9fcd6ed0810dab1f4f Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 5 Mar 2014 22:11:25 +0100 Subject: cleanup headers and especially #includes everywhere Beside being a bit cleaner it hopefully also resolves oddball problems I have with high levels of parallel jobs. Git-Dch: Ignore Reported-By: iwyu (include-what-you-use) --- ftparchive/override.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ftparchive/override.cc') diff --git a/ftparchive/override.cc b/ftparchive/override.cc index 38d76a6a3..b4cd49b6c 100644 --- a/ftparchive/override.cc +++ b/ftparchive/override.cc @@ -16,6 +16,9 @@ #include #include +#include +#include +#include #include "override.h" -- cgit v1.2.3