Add some fixes and workarounds for gcc-11 static analyzer.

Not everything is a real bug (false positive rate is very high here),
but the code is actually more readable.
This commit is contained in:
Milan Broz
2021-05-18 16:19:08 +02:00
parent 28dd0f5c05
commit 280c821b9b
4 changed files with 17 additions and 1 deletions

View File

@@ -162,6 +162,9 @@ static int device_ready(struct crypt_device *cd, struct device *device)
struct stat st;
size_t tmp_size;
if (!device)
return -EINVAL;
if (device->o_direct) {
log_dbg(cd, "Trying to open and read device %s with direct-io.",
device_path(device));
@@ -217,6 +220,9 @@ static int _open_locked(struct crypt_device *cd, struct device *device, int flag
{
int fd;
if (!device)
return -EINVAL;
log_dbg(cd, "Opening locked device %s", device_path(device));
if ((flags & O_ACCMODE) != O_RDONLY && device_locked_readonly(device->lh)) {