[libvirt] [PATCHv2] Ignore bridge template names with multiple printf conversions

Eric Blake eblake at redhat.com
Wed May 13 14:58:19 UTC 2015


On 05/13/2015 04:55 AM, Ján Tomko wrote:
>>> Okay, I see your counterargument.  Still, strstr() is pretty expensive
>>> compared to just:
>>>
>>> if (def->bridge &&
>>>     (p = strchr(def->bridge, '%')) == strrchr(def->bridge, '%') &&
>>>     p[1] == 'd')
>>>
>>
>> Coverity complains :
>>
>> Event returned_null: 	"strchr" returns null (checked 273 out of 288 times).
> 
> strchr does not return NULL here because networkFindUnusedBridgeName is
> only called if either def->bridge is NULL or def->bridge contains "%d".

Adding "p &&" just before "p[1] == 'd'" should silence the false
positive, right?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150513/268ebe2f/attachment-0001.sig>


More information about the libvir-list mailing list