]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virsh: Refactor parseRateStr to avoid false-positive uninitialized variable
authorPeter Krempa <pkrempa@redhat.com>
Wed, 12 Aug 2015 05:31:33 +0000 (07:31 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 12 Aug 2015 05:33:06 +0000 (07:33 +0200)
commit73ca6f98a32963e3143fc10400ea7d3f04b71017
treeb439e218f268dbd05c63e5ddb0bd1e578a61db0b
parentc7790408d7e16b1ad00a690433d9310f104994f7
virsh: Refactor parseRateStr to avoid false-positive uninitialized variable

Commit 6983d6d2 tried to improve parseRateStr but broke the build
instead for compilers that were not able to properly introspect the for
loop indexed by the enum resulting into the following error:

virsh-domain.c: In function 'parseRateStr':
virsh-domain.c:916:13: error: 'field_name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             vshError(ctl, _("malformed %s field"), field_name);
             ^
virsh-domain.c:915:13: error: 'tmp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         if (virStrToLong_ullp(token, NULL, 10, tmp) < 0) {
             ^
Rather than trying to fix the code, refactor the function again by
reusing virStringSplit.
tools/virsh-domain.c