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

Aleksei Nikiforov darktemplar на altlinux.org
Пт Дек 13 11:10:49 MSK 2019


12.12.2019 22:55, Andrey Savchenko пишет:
> 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.
> 

Thank you. It looks like I missed unrelated change while working on this 
patch set. I'll split it into a separate patch.

>>                  }
>> +	    }
>>   	    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
> 
> 
> _______________________________________________
> Devel mailing list
> Devel на lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/devel
> 


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