summaryrefslogtreecommitdiff
path: root/ftparchive
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-01-16 19:51:23 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-01-16 19:51:23 +0100
commit62d8a765b9b37354efab6ca838cbdb7f347f7cac (patch)
tree4bd41cf6076cf264640ab2296f41c88379fecf44 /ftparchive
parentbee0670b2dc8c50ddfc65731c00383da4d377cae (diff)
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
Diffstat (limited to 'ftparchive')
-rw-r--r--ftparchive/contents.cc2
-rw-r--r--ftparchive/override.cc56
2 files changed, 27 insertions, 31 deletions
diff --git a/ftparchive/contents.cc b/ftparchive/contents.cc
index 015c790e0..80fe6e17e 100644
--- a/ftparchive/contents.cc
+++ b/ftparchive/contents.cc
@@ -233,7 +233,7 @@ void GenContents::Add(const char *Dir,const char *Package)
// The final component if it does not have a trailing /
if (I - Start >= 1)
- Root = Grab(Root,Start,Package);
+ Grab(Root,Start,Package);
}
/*}}}*/
// GenContents::WriteSpace - Write a given number of white space chars /*{{{*/
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)