]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commit
rgw/rgw_cksum: work around -Wsometimes-uninitialized
authorMax Kellermann <max.kellermann@ionos.com>
Thu, 24 Apr 2025 11:22:55 +0000 (13:22 +0200)
committerThomas Serlin <tserlin@redhat.com>
Mon, 22 Sep 2025 19:18:18 +0000 (15:18 -0400)
commit72bfce9a24be3e963b4d4d67ce0cbc1f4014ebbe
tree21723abdd58ff4738fc7365ab9a1067cb63bbb64
parentf6a59913484a4fd3d1d5cf5c09b64742efcf31d6
rgw/rgw_cksum: work around -Wsometimes-uninitialized

clang complains that `cck3` might not be initialized:

```
 /home/jenkins-build/build/workspace/ceph-api/src/rgw/rgw_cksum.cc:74:2: error: variable 'cck3' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
    74 |         default:
       |         ^~~~~~~
 /home/jenkins-build/build/workspace/ceph-api/src/rgw/rgw_cksum.cc:78:31: note: uninitialized use occurs here
    78 |         cck3 = rgw::digest::byteswap(cck3);
       |                                      ^~~~
 /home/jenkins-build/build/workspace/ceph-api/src/rgw/rgw_cksum.cc:61:15: note: initialize the variable 'cck3' to silence this warning
    61 |         uint32_t cck3;
       |                      ^
       |                       = 0
```

The `default:` case however is not reachable because `ck1.type` has
already been checked.  Adding initializers to `cck3` would only hide
potential future bugs, therefore I suggest just bailing out of the
function for this unreachable piece of code.  With C++23, we could use
`std::unreachable()` instead.

Resolves: rhbz#2392604

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
(cherry picked from commit 2afbc2ff9d15e685edb26ce22efd3c377799efb4)
src/rgw/rgw_cksum.cc