On 05/20/2013 11:55 AM, Michal Privoznik wrote:
---
src/openvz/openvz_conf.c | 45 ++++++++++++++++++++++-----------------------
src/openvz/openvz_driver.c | 29 ++++++++++-------------------
2 files changed, 32 insertions(+), 42 deletions(-)
+++ b/src/openvz/openvz_driver.c
@@ -94,13 +94,8 @@ openvzDomainDefPostParse(virDomainDefPtr def,
void *opaque ATTRIBUTE_UNUSED)
{
/* fill the init path */
- if (STREQ(def->os.type, "exe") && !def->os.init) {
- if (!(def->os.init = strdup("/sbin/init"))) {
- virReportOOMError();
- return -1;
- }
- }
-
+ if (STREQ(def->os.type, "exe") && !def->os.init)
+ return VIR_STRDUP(def->os.init, "/sbin/init");
Unintentional change in return value from 0 to 1; I'd prefer keeping it
at 0.
@@ -770,12 +764,14 @@ openvzGenerateVethName(int veid, char
*dev_name_ve)
{
char dev_name[32];
int ifNo = 0;
+ char *ret;
if (sscanf(dev_name_ve, "%*[^0-9]%d", &ifNo) != 1)
return NULL;
if (snprintf(dev_name, sizeof(dev_name), "veth%d.%d", veid, ifNo) < 7)
return NULL;
- return strdup(dev_name);
+ ignore_value(VIR_STRDUP(ret, dev_name));
+ return ret;
Why snprintf only to strdup it? You can ditch dev_name, and just do:
if (virAsprintf(&ret, "veth%d.%d", veid, ifNo) < 0)
virReportOOMError();
return ret;
ACK with those fixes.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org