[devel] [PATCH for apt v2 11/21] Remove useless variable shadowing

Andrey Savchenko bircoph на altlinux.org
Пт Дек 13 00:19:36 MSK 2019


On Thu, 12 Dec 2019 12:57:20 +0300 Aleksei Nikiforov wrote:
> Found via cppcheck:
> [apt/cmdline/apt-cdrom.cc:66] -> [apt/cmdline/apt-cdrom.cc:149]:
> (style) Local variable 'Buf' shadows outer variable
> ---
>  apt/cmdline/apt-cdrom.cc | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/apt/cmdline/apt-cdrom.cc b/apt/cmdline/apt-cdrom.cc
> index eded525..93ad41d 100644
> --- a/apt/cmdline/apt-cdrom.cc
> +++ b/apt/cmdline/apt-cdrom.cc
> @@ -146,7 +146,6 @@ bool FindPackages(string CD,vector<string> &List,vector<string> &SList,
>  #endif
>  
>        // See if the name is a sub directory
> -      struct stat Buf;
>        if (stat(Dir->d_name,&Buf) != 0)
>  	 continue;      
>        

LGTM since Buf declared outside of the for loop is not used after
the loop and it is unlikely it will be ever dereferenced after the
loop.

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


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