From ceb327789bf0a797a4e78d58cf1ec48585d16eae Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sat, 18 Aug 2018 22:47:16 -0400 Subject: 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 --- pngwtran.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'pngwtran.c') 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; -- cgit v1.2.1