So my gcc 12.2 started complaining about possibly using an uninitialized variable eof:
,----
| fileio.c: In function ‘readfile’:
| fileio.c:221:17: warning: ‘eof’ may be used uninitialized [-Wmaybe-uninitialized]
| 221 | int eof;
| | ^~~
`----
It is currently only initialized in the if (read_buffer) case but not in the else clause. There is the following code:
if (read_buffer)
eof = FALSE;
else [1]
{
if (filesize == 0)
[...]
else if (filesize > 0 ... [4]
{
[...]
if (curbuf->b_cryptstate->method_nr == CRYPT_M_SOD
&& !eof && may_need_lseek) [3]
{
[...]
}
}
eof = size; [2]
In the else condition [1], eof will only be initialized at [2], while it looks like it may be used at [3].
So technically, the eof variable could be accessed uninitialized in the else if case [4]. This can not happen, because filesize is initialized to zero, so Vim cannot run into this case in practice and after the first loop, eof will be initialized.
However, I think it's worth it, to move the initialization of the eof variable to the beginning of the function and don't init it in both branches of the if/else condition and also also do not depend on the implicit initialization of the filesize variable.
https://github.com/vim/vim/pull/12549
(1 file)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Merging #12549 (8811ec4) into master (46acad7) will increase coverage by
0.00%.
The diff coverage is100.00%.
@@ Coverage Diff @@
## master #12549 +/- ##
=======================================
Coverage 82.09% 82.10%
=======================================
Files 160 160
Lines 193625 193650 +25
Branches 43475 43481 +6
=======================================
+ Hits 158966 158989 +23
- Misses 21815 21816 +1
- Partials 12844 12845 +1
| Flag | Coverage Δ | |
|---|---|---|
| huge-clang-none | 82.72% <100.00%> (-0.03%) |
⬇️ |
| linux | 82.72% <100.00%> (-0.03%) |
⬇️ |
| mingw-x64-HUGE | 76.60% <ø> (-0.01%) |
⬇️ |
| mingw-x86-HUGE | 77.07% <ø> (+<0.01%) |
⬆️ |
| windows | 78.20% <ø> (+<0.01%) |
⬆️ |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/fileio.c | 76.09% <100.00%> (ø) |
... and 20 files with indirect coverage changes
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()