Remove top-level const from function-scope variables

As per the const correctness rules, top-level const-ness of data
in automatic scopes does not propagate outside of these scopes
(unlike const-ness at lower levels, such as pointers to const data).

Previously, const was used liberally, but inconsistently across the
libpng codebase. Using const wherever applicable is not incorrect.
However, _consistent_ use of const is difficult to maintain in such
conditions.

In conclusion, we shall continue to use const only where doing so is
strictly necessary:

1. If a function guarantees that it will not modify an argument
   passed by pointer, the corresponding function parameter should be
   a pointer-to-const (const T *).

2. Static data should not be modified, therefore it should be const.

Reference:
Google C++ Style Guide
https://google.github.io/styleguide/cppguide.html#Use_of_const
This commit is contained in:
Cosmin Truta
2018-08-18 22:47:16 -04:00
parent 1ef8882814
commit ceb327789b
22 changed files with 196 additions and 205 deletions

View File

@@ -23,14 +23,12 @@
static int
png_have_vsx(png_structp png_ptr)
{
const unsigned long auxv = getauxval( AT_HWCAP );
unsigned long auxv = getauxval(AT_HWCAP);
PNG_UNUSED(png_ptr)
if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX ))
if(auxv & (PPC_FEATURE_HAS_ALTIVEC|PPC_FEATURE_HAS_VSX))
return 1;
else
return 0;
}