[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 6/7] storage_backend: Resolve Coverity issue



On 07/11/2013 09:56 AM, Daniel P. Berrange wrote:
> On Thu, Jul 11, 2013 at 08:34:06AM -0400, John Ferlan wrote:
>> The switch statement in 'virStorageBackendCreateQemuImgOpts' used the
>> for loop end condition 'VIR_STORAGE_FILE_FEATURE_LAST' as a possible value,
>> but since that cannot happen Coverity spits out a DEADCODE message. Adding
>> the Coverity tag just removes the Coverity message
>> ---
>>  src/storage/storage_backend.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
>> index 5d06eb6..8d5880e 100644
>> --- a/src/storage/storage_backend.c
>> +++ b/src/storage/storage_backend.c
>> @@ -663,6 +663,7 @@ virStorageBackendCreateQemuImgOpts(char **opts,
>>                      }
>>                      break;
>>  
>> +                /* coverity[dead_error_begin] */
>>                  case VIR_STORAGE_FILE_FEATURE_LAST:
>>                      ;
>>                  }
> 
> Wow, I tend to think that this code is terribly over engineered. We
> really don't need to have a for loop with a nested case. The entire
> thing can be replaced with something much simpler.
> 
> 
> Daniel
> 

It's not the only code that does something similar, but I was following
how it was handled in other code. See:

src/lxc/lxc_driver.c  (search on dead_error_begin or LXC_NB_BLKIO_PARAM)

Should that code change as well?

For this code I wasn't sure if the future held more
VIR_STORAGE_FILE_FEATURE options...

John


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]