[libvirt] [PATCH 1/2] virsh: Refactor parseRateStr to avoid false-positive uninitialized variable

Michal Privoznik mprivozn at redhat.com
Wed Aug 12 08:21:39 UTC 2015


On 12.08.2015 07:45, Peter Krempa wrote:
> 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 | 88 +++++++++++++++++++++-------------------------------
>  1 file changed, 35 insertions(+), 53 deletions(-)
> 

ACK

Michal




More information about the libvir-list mailing list