Просмотр исходного кода

(error) va_list 'args' was opened but not closed by va_end()

Reported-By: cppcheck
Gbp-Dch: Ignore
David Kalnischkies лет назад: 10
Родитель
Сommit
196d590a99
4 измененных файлов с 26 добавлено и 30 удалено
  1. 16 18
      apt-pkg/contrib/error.cc
  2. 8 10
      apt-pkg/contrib/fileutl.cc
  3. 1 1
      apt-pkg/edsp.cc
  4. 1 1
      test/integration/test-releasefile-verification

+ 16 - 18
apt-pkg/contrib/error.cc

@@ -68,13 +68,12 @@ bool GlobalError::NAME (const char *Function, const char *Description,...) { \
 	va_list args; \
 	va_list args; \
 	size_t msgSize = 400; \
 	size_t msgSize = 400; \
 	int const errsv = errno; \
 	int const errsv = errno; \
-	while (true) { \
+	bool retry; \
+	do { \
 		va_start(args,Description); \
 		va_start(args,Description); \
-		bool const retry = InsertErrno(TYPE, Function, Description, args, errsv, msgSize); \
+		retry = InsertErrno(TYPE, Function, Description, args, errsv, msgSize); \
 		va_end(args); \
 		va_end(args); \
-		if (retry == false) \
-			break; \
-	} \
+	} while (retry); \
 	return false; \
 	return false; \
 }
 }
 GEMessage(FatalE, FATAL)
 GEMessage(FatalE, FATAL)
@@ -90,13 +89,12 @@ bool GlobalError::InsertErrno(MsgType const &type, const char *Function,
 	va_list args;
 	va_list args;
 	size_t msgSize = 400;
 	size_t msgSize = 400;
 	int const errsv = errno;
 	int const errsv = errno;
-	while (true) {
+	bool retry;
+	do {
 		va_start(args,Description);
 		va_start(args,Description);
-		bool const retry = InsertErrno(type, Function, Description, args, errsv, msgSize);
+		retry = InsertErrno(type, Function, Description, args, errsv, msgSize);
 		va_end(args);
 		va_end(args);
-		if (retry == false)
-		   break;
-	}
+	} while (retry);
 	return false;
 	return false;
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -127,12 +125,12 @@ bool GlobalError::InsertErrno(MsgType type, const char* Function,
 bool GlobalError::NAME (const char *Description,...) { \
 bool GlobalError::NAME (const char *Description,...) { \
 	va_list args; \
 	va_list args; \
 	size_t msgSize = 400; \
 	size_t msgSize = 400; \
-	while (true) { \
+	bool retry; \
+	do { \
 		va_start(args,Description); \
 		va_start(args,Description); \
-		if (Insert(TYPE, Description, args, msgSize) == false) \
-			break; \
+		retry = Insert(TYPE, Description, args, msgSize); \
 		va_end(args); \
 		va_end(args); \
-	} \
+	} while (retry); \
 	return false; \
 	return false; \
 }
 }
 GEMessage(Fatal, FATAL)
 GEMessage(Fatal, FATAL)
@@ -147,12 +145,12 @@ bool GlobalError::Insert(MsgType const &type, const char *Description,...)
 {
 {
 	va_list args;
 	va_list args;
 	size_t msgSize = 400;
 	size_t msgSize = 400;
-	while (true) {
+	bool retry;
+	do {
 		va_start(args,Description);
 		va_start(args,Description);
-		if (Insert(type, Description, args, msgSize) == false)
-			break;
+		retry = Insert(type, Description, args, msgSize);
 		va_end(args);
 		va_end(args);
-	}
+	} while (retry);
 	return false;
 	return false;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 8 - 10
apt-pkg/contrib/fileutl.cc

@@ -2682,13 +2682,12 @@ bool FileFd::FileFdErrno(const char *Function, const char *Description,...)
    va_list args;
    va_list args;
    size_t msgSize = 400;
    size_t msgSize = 400;
    int const errsv = errno;
    int const errsv = errno;
-   while (true)
-   {
+   bool retry;
+   do {
       va_start(args,Description);
       va_start(args,Description);
-      if (_error->InsertErrno(GlobalError::ERROR, Function, Description, args, errsv, msgSize) == false)
-	 break;
+      retry = _error->InsertErrno(GlobalError::ERROR, Function, Description, args, errsv, msgSize);
       va_end(args);
       va_end(args);
-   }
+   } while (retry);
    return false;
    return false;
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -2697,13 +2696,12 @@ bool FileFd::FileFdError(const char *Description,...) {
    Flags |= Fail;
    Flags |= Fail;
    va_list args;
    va_list args;
    size_t msgSize = 400;
    size_t msgSize = 400;
-   while (true)
-   {
+   bool retry;
+   do {
       va_start(args,Description);
       va_start(args,Description);
-      if (_error->Insert(GlobalError::ERROR, Description, args, msgSize) == false)
-	 break;
+      retry = _error->Insert(GlobalError::ERROR, Description, args, msgSize);
       va_end(args);
       va_end(args);
-   }
+   } while (retry);
    return false;
    return false;
 }
 }
 									/*}}}*/
 									/*}}}*/

+ 1 - 1
apt-pkg/edsp.cc

@@ -340,7 +340,7 @@ static bool WriteScenarioLimitedDependency(FileFd &output,
 static bool SkipUnavailableVersions(pkgDepCache &Cache, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver)/*{{{*/
 static bool SkipUnavailableVersions(pkgDepCache &Cache, pkgCache::PkgIterator const &Pkg, pkgCache::VerIterator const &Ver)/*{{{*/
 {
 {
    /* versions which aren't current and aren't available in
    /* versions which aren't current and aren't available in
-      any "online" source file are bad, expect if they are the choosen
+      any "online" source file are bad, expect if they are the chosen
       candidate: The exception is for build-dep implementation as it creates
       candidate: The exception is for build-dep implementation as it creates
       such pseudo (package) versions and removes them later on again.
       such pseudo (package) versions and removes them later on again.
       We filter out versions at all so packages in 'rc' state only available
       We filter out versions at all so packages in 'rc' state only available

+ 1 - 1
test/integration/test-releasefile-verification

@@ -379,7 +379,7 @@ cat > rootdir/etc/apt/apt.conf.d/weaken-security <<EOF
 Acquire::AllowInsecureRepositories "1";
 Acquire::AllowInsecureRepositories "1";
 Acquire::AllowDowngradeToInsecureRepositories "1";
 Acquire::AllowDowngradeToInsecureRepositories "1";
 EOF
 EOF
-# the hash marked as configureable in our gpgv method
+# the hash marked as configurable in our gpgv method
 export APT_TESTS_DIGEST_ALGO='SHA224'
 export APT_TESTS_DIGEST_ALGO='SHA224'
 
 
 successfulaptgetupdate() {
 successfulaptgetupdate() {