-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip reassignment of the initialization value #530
base: libpng16
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reason for such a change. The compiler can work it out too and making the change requires a code review which explains why the change from:
if (a > b)
spurious assignment;
else if (a <= b)
required assignment;
To:
if (a < b)
required assignment;
Is correct. I couldn't work it out; why is the case "a == b" irrelevant?
However, back to the words of the pull request rather than the code; why is this better documentation of what the code does than the original form, which you present as equivalent (ignoring the "a == b" issue)? It seems to me that "if/else" is always more clear ab initio than "if".
Thanks for reviewing. |
libpng-ng comment: libpng(ng) shouldn't even contain this code for IDAT There is no point detecting an over-long IDAT unless it exceeds the PNG spec length (indicating a corrupted stream). IDAT buffering needs to be controlled internally to optimize the specific zlib implementation (if known) and the architecture performance; small buffers or large buffers depend on the relative speed of the zlib window copy vs the libpng row handling for large images and for small images the code can avoid the window copy entirely if enough is known about the zlib implementation. |
As could be read, at least one more version of 1.6 was planned. So this code might stay for some time, while 1.7 branch did not pan out. PS. About 5 years ago in one discussion it was suggested to rename |
@ctruta: won't fix |
This was incorrect:
Reversed condition changed toless
instead ofless or equal
because the value still should bePNG_UINT_31_MAX
.Reassignment of the same value is a common kind of copy-paste errors.
Hence static analysis emits warning in this case.
A better way to avoid reassignment is in the updated commit.