diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-02-06 10:08:44 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-02-06 10:24:57 +0100 |
commit | 03f5e501b6b58cb05a275403af4a36694ff0c205 (patch) | |
tree | bbbc8ba970bf882d603de4c016dda3bc36a30c80 /src/partition | |
parent | repart: fix invalid errno in log (diff) | |
download | systemd-03f5e501b6b58cb05a275403af4a36694ff0c205.tar.xz systemd-03f5e501b6b58cb05a275403af4a36694ff0c205.zip |
repart: silence bogus gcc warning
[2/3] Compiling C object systemd-repart.p/src_partition_repart.c.o
../src/partition/repart.c: In function ‘context_open_copy_block_paths’:
../src/partition/repart.c:5194:41: warning: ‘devno’ may be used uninitialized [-Wmaybe-uninitialized]
5194 | source_fd = r = device_open_from_devnum(S_IFBLK, devno, O_RDONLY|O_CLOEXEC|O_NONBLOCK, &opened);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/partition/repart.c:5188:31: note: ‘devno’ was declared here
5188 | dev_t devno;
| ^~~~~
This is with gcc-13.0.1-0.2.fc38.x86_64, -O2. I'm pretty sure the code
is correct. I also tried adding some asserts where errno is used for the return
value, but that didn't help. I think resolve_copy_blocks_auto() is just too long
for gcc to understand.
Diffstat (limited to 'src/partition')
-rw-r--r-- | src/partition/repart.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c index 8e878dbd8b..6ba48b528e 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -5183,11 +5183,12 @@ static int context_open_copy_block_paths( "Copying from block device node is not permitted in --image=/--root= mode, refusing."); } else if (p->copy_blocks_auto) { - dev_t devno; + dev_t devno = 0; /* Fake initialization to appease gcc. */ r = resolve_copy_blocks_auto(p->type, p->copy_blocks_root, restrict_devno, &devno, &uuid); if (r < 0) return r; + assert(devno != 0); source_fd = r = device_open_from_devnum(S_IFBLK, devno, O_RDONLY|O_CLOEXEC|O_NONBLOCK, &opened); if (r < 0) |