[devel] [PATCH for apt v2 09/21] Rework identical conditions

Andrey Savchenko bircoph на altlinux.org
Чт Дек 12 22:55:53 MSK 2019


On Thu, 12 Dec 2019 12:57:18 +0300 Aleksei Nikiforov wrote:
> Found via cppcheck:
> [apt/methods/rsync.cc:371] -> [apt/methods/rsync.cc:373]:
> (style) The if condition is the same as the previous if condition
> ---
>  apt/cmdline/apt-shell.cc | 7 +++++--
>  apt/methods/rsync.cc     | 3 ++-
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/apt/cmdline/apt-shell.cc b/apt/cmdline/apt-shell.cc
> index 36fa223..951bc3c 100644
> --- a/apt/cmdline/apt-shell.cc
> +++ b/apt/cmdline/apt-shell.cc
> @@ -3044,8 +3044,9 @@ bool DoList(CommandLine &CmdL)
>  	    PkgSection = Pkg.Section();
>  	    StrLen = strlen(Str);
>      	    string status = "available";
> -	    if (Pkg->CurrentVer != 0) status = "installed";
> -            if (Pkg->CurrentVer != 0)
> +	    if (Pkg->CurrentVer != 0)
> +	    {
> +	        status = "installed";
>                for (pkgCache::DepIterator D = Pkg.RevDependsList(); not D.end(); ++D)
>                 {
>  	          pkgCache::PkgIterator P = D.ParentPkg();
> @@ -3053,7 +3054,9 @@ bool DoList(CommandLine &CmdL)
>  	          (P->Flags & pkgCache::Flag::Important) != pkgCache::Flag::Important)
>  	             continue;
>  	          status = "locked";
> +	          break;

Why this break? It does not look related to the identical
conditions merge.

>                 }
> +	    }
>  	    if (Pkg->CurrentVer != 0 && Cache[Pkg].Upgradable() == true) status = "upgradable";
>  	    if (Cache[Pkg].NewInstall()) status = "be-installed";
>  	    if (Cache[Pkg].Delete()) status = "be-removed";
> diff --git a/apt/methods/rsync.cc b/apt/methods/rsync.cc
> index bae22eb..64c9231 100644
> --- a/apt/methods/rsync.cc
> +++ b/apt/methods/rsync.cc
> @@ -369,9 +369,10 @@ bool RsyncMethod::RsyncConnExec::Get(pkgAcqMethod *Owner, FetchResult &FRes, con
>  	  return false;
>     }
>     if ( RsyncMethod::Debug )
> +   {
>  	  cerr << "RSYNC: Created pipe [" << p[0] << ',' << p[1] << ']' << endl;
> -   if ( RsyncMethod::Debug )
>  	  cerr << "RSYNC: Starting: " << string(argv) << endl;
> +   }
>  
>     switch ( ChildPid = fork() ) {
>  	  case -1:


Best regards,
Andrew Savchenko
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя     : отсутствует
Тип     : application/pgp-signature
Размер  : 833 байтов
Описание: отсутствует
Url     : <http://lists.altlinux.org/pipermail/devel/attachments/20191212/f3df5bac/attachment.bin>


Подробная информация о списке рассылки Devel