From 790e7dfa5e3bec21dfa86f4e7c07ac47a7d407e0 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sat, 15 Nov 2014 18:33:39 +0100 Subject: [PATCH] Simplifies a disk check to avoid static analyzer warnings. --- cmdline/check.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/cmdline/check.c b/cmdline/check.c index 07019f15..858a47aa 100644 --- a/cmdline/check.c +++ b/cmdline/check.c @@ -631,9 +631,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna /* for each disk */ one_tocheck = 0; for (j = 0; j < diskmax; ++j) { - struct snapraid_block* block = BLOCK_EMPTY; - if (handle[j].disk) - block = disk_block_get(handle[j].disk, i); + struct snapraid_block* block; + + /* if no disk, nothing to check */ + if (!handle[j].disk) + continue; + + block = disk_block_get(handle[j].disk, i); /* try to recover all files, even the ones without hash */ /* because in some cases we can recover also them */ @@ -666,9 +670,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna /* for each disk */ one_tocheck = 0; for (j = 0; j < diskmax; ++j) { - struct snapraid_block* block = BLOCK_EMPTY; - if (handle[j].disk) - block = disk_block_get(handle[j].disk, i); + struct snapraid_block* block; + + /* if no disk, nothing to check */ + if (!handle[j].disk) + continue; + + block = disk_block_get(handle[j].disk, i); /* try to recover all files, even the ones without hash */ /* because in some cases we can recover also them */