This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Dead assignment in Py_UniversalNewlineFgets
Type: enhancement Stage: resolved
Components: IO Versions: Python 3.10
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: alex.henrie, iritkatriel, serhiy.storchaka, terry.reedy, vstinner
Priority: normal Keywords: patch

Created on 2021-03-02 02:16 by alex.henrie, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24699 closed alex.henrie, 2021-03-02 02:17
Messages (6)
msg387894 - (view) Author: Alex Henrie (alex.henrie) * Date: 2021-03-02 02:16
The function Py_UniversalNewlineFgets currently initializes the variable c to 'x' and then overwrites it without ever reading that value back. There used to be code that read back c's initial value, but it was commented out by commit b94767ff44edf5d461d7cb1c8eb5160f83886358 (bpo-8914) in 2011. So at this point, removing the dead initialization will not trigger a compiler warning or cause any other undesired behavior.

Defect identified by scan-build <https://clang-analyzer.llvm.org/scan-build.html>
msg388170 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-03-05 22:30
Victor and/or Serhiy: This and #43360 and #43361 are similar 1-line changes, suggested by scan-build, to eliminate dead or duplicate initializations in C code.  Can either of you either handle these or suggest someone else?  Would we have preferred 1 issue and PR?  Do we backport such changes?

All 3 diffs have a bunch of github beta check annotation warnings for an otherwise unchanged C file.  Fix?  Suppress somehow?
msg388282 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-08 18:54
>     c = 'x'; /* Shut up gcc warning */

IMHO this code is fine and should be kept. I hate fighting against stupid false alarms of compiler warnings. This code is harmless. It doesn't affect performances or anything.

I suggest to close this issue and its PR.
msg388284 - (view) Author: Alex Henrie (alex.henrie) * Date: 2021-03-08 19:08
Hi Victor, just so we're all on the same page, removing the line does not trigger a compiler warning. The comment on this line is misleading.
msg388291 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2021-03-08 19:49
> Hi Victor, just so we're all on the same page, removing the line does not trigger a compiler warning. The comment on this line is misleading.

I wrote the opposite. IMO the line and its commment should be kept.

> Defect identified by scan-build <https://clang-analyzer.llvm.org/scan-build.html>

Just tell your tool that the line is there on purpose.
msg412110 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-29 23:55
That function has been edited in the meantime and this line is no longer there.
History
Date User Action Args
2022-04-11 14:59:42adminsetgithub: 87525
2022-01-29 23:55:40iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg412110

resolution: out of date
stage: patch review -> resolved
2021-03-08 19:49:06vstinnersetmessages: + msg388291
2021-03-08 19:08:52alex.henriesetmessages: + msg388284
2021-03-08 18:54:23vstinnersetmessages: + msg388282
2021-03-05 22:30:57terry.reedysetnosy: + serhiy.storchaka, terry.reedy, vstinner
messages: + msg388170
2021-03-02 02:17:20alex.henriesetkeywords: + patch
stage: patch review
pull_requests: + pull_request23476
2021-03-02 02:16:27alex.henriecreate