Skip to content

remove pointless variable initialization in socketmodule #116675

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

Closed
wants to merge 1 commit into from

Conversation

wrongnull
Copy link
Contributor

This value is never read, so this assignment is meaningless and will be optimized away at compile time. The issue was not created and the new entry was skipped because the changes are not visible to the user.

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Mar 12, 2024

This value is never read, so this assignment is meaningless and will be optimized away at compile time.

Is it really so? ;)

cpython/Modules/socketmodule.c

Lines 1735 to 1739 in bb66600

if (strlen(data->buf) != len) {
Py_CLEAR(data->obj);
PyErr_SetString(PyExc_TypeError, "host name must not contain null character");
return 0;
}

In general, we try to not encourage PRs like this. As you already pointed out, in most of these cases the compiler will optimise it away anyway, so the CI, review, and Git history churn is (in most cases) not worth it.

I'm sure you can find a lot of interesting bugs to work on in the issue tracker :)

@erlend-aasland
Copy link
Contributor

Moreover, we try really hard to avoid the skip issue label. See the devguide for more details :)

@wrongnull
Copy link
Contributor Author

Is it really so? ;)

It is. I just ran clang static analyzer on that file.

@erlend-aasland
Copy link
Contributor

Before tearing down Chesterton's Fence, take a look and try to find out why a specific line of code was introduced in the first place. I find git log -L:funcname:filename to be a useful tool for this.

@wrongnull
Copy link
Contributor Author

wrongnull commented Mar 12, 2024

IMO, keeping dead code is a very strange decision anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants