diff options
author | Cosmin Truta <ctruta@gmail.com> | 2018-08-18 22:47:16 -0400 |
---|---|---|
committer | Cosmin Truta <ctruta@gmail.com> | 2018-08-18 22:47:16 -0400 |
commit | ceb327789bf0a797a4e78d58cf1ec48585d16eae (patch) | |
tree | f165ad9fb1d924e4c6f49c2d684b0805eaf13090 /pngwtran.c | |
parent | 1ef88828146c23bfc6d81042c6d6ecd61ccc983b (diff) | |
download | libpng-ceb327789bf0a797a4e78d58cf1ec48585d16eae.tar.gz |
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
Diffstat (limited to 'pngwtran.c')
-rw-r--r-- | pngwtran.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/pngwtran.c b/pngwtran.c index 9ed551eca..49a13c1e9 100644 --- a/pngwtran.c +++ b/pngwtran.c @@ -254,8 +254,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, for (i = 0; i < istop; i++, bp++) { - - const unsigned int c = i%channels; + unsigned int c = i%channels; int j; unsigned int v, out; @@ -283,7 +282,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, for (bp = row, i = 0; i < istop; i++) { - const unsigned int c = i%channels; + unsigned int c = i%channels; int j; unsigned int value, v; |