Re: [PATCH] Fix string handling in virDomain{Get, Set}SchedulerParameters

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

 



"Richard W.M. Jones" <rjones@xxxxxxxxxx> wrote:
> Let's try this updated patch.

Hi Rich,

It'd be nice to factor those "cap" and "weight" literal strings all
the way out, so each is defined in exactly one place.
Either with a file-scoped const declaration, e.g.,
  static const char *cap_str = "cap";
or a cpp define:
  #define CAP_STR "cap";

Then, there's no risk (however small) of changing
one of the literal strings without changing its mate.

> Index: src/xen_internal.c
> ===================================================================
> RCS file: /data/cvs/libvirt/src/xen_internal.c,v
> retrieving revision 1.79
> diff -u -p -r1.79 xen_internal.c
> --- src/xen_internal.c	6 Jun 2007 12:24:31 -0000	1.79
> +++ src/xen_internal.c	22 Jun 2007 10:01:29 -0000
> @@ -1071,8 +1071,6 @@ xenHypervisorGetSchedulerParameters(virD
...
> +		strncpy (params[0].field, "weight", VIR_DOMAIN_SCHED_FIELD_LENGTH);
...
> +		strncpy (params[1].field, "cap", VIR_DOMAIN_SCHED_FIELD_LENGTH);
...
> +                if (STREQ (params[i].field, "weight") &&
...
> +		} else if (STREQ (params[i].field, "cap") &&


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]