[devel] [PATCH for apt 2/2] Fix pointer arithmetics

Dmitry V. Levin ldv на altlinux.org
Пн Дек 9 02:31:17 MSK 2019


On Fri, Dec 06, 2019 at 04:16:06PM +0300, Aleksei Nikiforov wrote:
[...]
> diff --git a/apt/apt-pkg/rebase_pointer.h b/apt/apt-pkg/rebase_pointer.h
> new file mode 100644
> index 0000000..efc4074
> --- /dev/null
> +++ b/apt/apt-pkg/rebase_pointer.h
> @@ -0,0 +1,16 @@
> +#ifndef PKGLIB_REBASE_POINTER_H
> +#define PKGLIB_REBASE_POINTER_H
> +
> +template <typename T>
> +static inline T* RebasePointer(T *ptr, const void * const old_base, const void * const new_base)
> +{
> +   return reinterpret_cast<T*>(reinterpret_cast<char*>(ptr) + (reinterpret_cast<char const * const>(new_base) - reinterpret_cast<char const * const>(old_base)));
> +}
> +
> +template <typename T>
> +static inline const T* RebasePointer(const T *ptr, const void * const old_base, const void * const new_base)
> +{
> +   return reinterpret_cast<const T*>(reinterpret_cast<const char*>(ptr) + (reinterpret_cast<char const * const>(new_base) - reinterpret_cast<char const * const>(old_base)));

This line is way too long - about twice longer than a normal line of code.
Please break long lines.

My edition of rebase_pointer.h had the maximum length of all lines within
the traditional 80-symbol limit.


-- 
ldv
----------- следующая часть -----------
Было удалено вложение не в текстовом формате...
Имя     : signature.asc
Тип     : application/pgp-signature
Размер  : 801 байтов
Описание: отсутствует
Url     : <http://lists.altlinux.org/pipermail/devel/attachments/20191209/b5b61639/attachment.bin>


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