Re: [PATCH python 05/14] override: Replace PyString_FromString with libvirt_constcharPtrWrap

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

 



On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange <berrange@xxxxxxxxxx> wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
>
> Make use of libvirt_constcharPtrWrap in all override code,
> to match generated code. This will isolate Python3 specific
> changes in one place.
>
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  libvirt-override.c      | 36 ++++++++++++++++++------------------
>  libvirt-qemu-override.c |  4 ++--
>  2 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/libvirt-override.c b/libvirt-override.c
> index 03aab89..84a5436 100644
> --- a/libvirt-override.c
> +++ b/libvirt-override.c
> @@ -2127,15 +2127,15 @@ static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
>          Py_INCREF(Py_None);
>          PyTuple_SetItem(pycred, i, pycreditem);
>          PyList_SetItem(pycreditem, 0, PyInt_FromLong((long) cred[i].type));
> -        PyList_SetItem(pycreditem, 1, PyString_FromString(cred[i].prompt));
> +        PyList_SetItem(pycreditem, 1, libvirt_constcharPtrWrap(cred[i].prompt));
>          if (cred[i].challenge) {
> -            PyList_SetItem(pycreditem, 2, PyString_FromString(cred[i].challenge));
> +            PyList_SetItem(pycreditem, 2, libvirt_constcharPtrWrap(cred[i].challenge));
>          } else {
>              Py_INCREF(Py_None);
>              PyList_SetItem(pycreditem, 2, Py_None);
>          }
>          if (cred[i].defresult) {
> -            PyList_SetItem(pycreditem, 3, PyString_FromString(cred[i].defresult));
> +            PyList_SetItem(pycreditem, 3, libvirt_constcharPtrWrap(cred[i].defresult));
>          } else {
>              Py_INCREF(Py_None);
>              PyList_SetItem(pycreditem, 3, Py_None);
> @@ -2319,7 +2319,7 @@ libvirt_virConnectGetCPUModelNames(PyObject *self ATTRIBUTE_UNUSED,
>
>      for (i = 0; i < c_retval; i++) {
>          PyObject *str;
> -        if ((str = PyString_FromString(models[i])) == NULL)
> +        if ((str = libvirt_constcharPtrWrap(models[i])) == NULL)
>              goto error;
>
>          PyList_SET_ITEM(rv, i, str);
> @@ -2969,7 +2969,7 @@ libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
>
>      if (c_retval < 0)
>          return VIR_PY_NONE;
> -    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
> +    py_retval = libvirt_charPtrSizeWrap((char *) &uuid[0], VIR_UUID_BUFLEN);
>
>      return py_retval;
>  }
> @@ -2997,7 +2997,7 @@ libvirt_virDomainGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
>      if (c_retval < 0)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromString((char *) &uuidstr[0]);
> +    py_retval = libvirt_constcharPtrWrap((char *) &uuidstr[0]);
>      return py_retval;
>  }
>
> @@ -3186,7 +3186,7 @@ libvirt_virNetworkGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
>
>      if (c_retval < 0)
>          return VIR_PY_NONE;
> -    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
> +    py_retval = libvirt_charPtrSizeWrap((char *) &uuid[0], VIR_UUID_BUFLEN);
>
>      return py_retval;
>  }
> @@ -3214,7 +3214,7 @@ libvirt_virNetworkGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
>      if (c_retval < 0)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromString((char *) &uuidstr[0]);
> +    py_retval = libvirt_constcharPtrWrap((char *) &uuidstr[0]);
>      return py_retval;
>  }
>
> @@ -3816,7 +3816,7 @@ libvirt_virStoragePoolGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
>      if (c_retval < 0)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
> +    py_retval = libvirt_charPtrSizeWrap((char *) &uuid[0], VIR_UUID_BUFLEN);
>
>      return py_retval;
>  }
> @@ -3843,7 +3843,7 @@ libvirt_virStoragePoolGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
>      if (c_retval < 0)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromString((char *) &uuidstr[0]);
> +    py_retval = libvirt_constcharPtrWrap((char *) &uuidstr[0]);
>      return py_retval;
>  }
>
> @@ -4030,7 +4030,7 @@ libvirt_virSecretGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
>
>      if (c_retval < 0)
>          return VIR_PY_NONE;
> -    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
> +    py_retval = libvirt_charPtrSizeWrap((char *) &uuid[0], VIR_UUID_BUFLEN);
>
>      return py_retval;
>  }
> @@ -4058,7 +4058,7 @@ libvirt_virSecretGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
>      if (c_retval < 0)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromString((char *) &uuidstr[0]);
> +    py_retval = libvirt_constcharPtrWrap((char *) &uuidstr[0]);
>      return py_retval;
>  }
>
> @@ -4201,7 +4201,7 @@ libvirt_virSecretGetValue(PyObject *self ATTRIBUTE_UNUSED,
>      if (c_retval == NULL)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromStringAndSize((const char *)c_retval, size);
> +    py_retval = libvirt_charPtrSizeWrap((char*)c_retval, size);
>      VIR_FREE(c_retval);
>
>      return py_retval;
> @@ -4252,7 +4252,7 @@ libvirt_virNWFilterGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
>
>      if (c_retval < 0)
>          return VIR_PY_NONE;
> -    py_retval = PyString_FromStringAndSize((char *) &uuid[0], VIR_UUID_BUFLEN);
> +    py_retval = libvirt_charPtrSizeWrap((char *) &uuid[0], VIR_UUID_BUFLEN);
>
>      return py_retval;
>  }
> @@ -4280,7 +4280,7 @@ libvirt_virNWFilterGetUUIDString(PyObject *self ATTRIBUTE_UNUSED,
>      if (c_retval < 0)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromString((char *) &uuidstr[0]);
> +    py_retval = libvirt_constcharPtrWrap((char *) &uuidstr[0]);
>      return py_retval;
>  }
>
> @@ -4601,7 +4601,7 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
>      if (base_cpu == NULL)
>          return VIR_PY_NONE;
>
> -    pybase_cpu = PyString_FromString(base_cpu);
> +    pybase_cpu = libvirt_constcharPtrWrap(base_cpu);
>      VIR_FREE(base_cpu);
>
>      if (pybase_cpu == NULL)
> @@ -6969,7 +6969,7 @@ libvirt_virDomainBlockPeek(PyObject *self ATTRIBUTE_UNUSED,
>          goto cleanup;
>      }
>
> -    py_retval = PyString_FromStringAndSize(buf, size);
> +    py_retval = libvirt_charPtrSizeWrap(buf, size);
>
>  cleanup:
>      VIR_FREE(buf);
> @@ -7006,7 +7006,7 @@ libvirt_virDomainMemoryPeek(PyObject *self ATTRIBUTE_UNUSED,
>          goto cleanup;
>      }
>
> -    py_retval = PyString_FromStringAndSize(buf, size);
> +    py_retval = libvirt_charPtrSizeWrap(buf, size);
>
>  cleanup:
>      VIR_FREE(buf);
> diff --git a/libvirt-qemu-override.c b/libvirt-qemu-override.c
> index 72257ac..480a7d3 100644
> --- a/libvirt-qemu-override.c
> +++ b/libvirt-qemu-override.c
> @@ -85,7 +85,7 @@ libvirt_qemu_virDomainQemuMonitorCommand(PyObject *self ATTRIBUTE_UNUSED,
>      if (c_retval < 0)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromString(result);
> +    py_retval = libvirt_constcharPtrWrap(result);
>      VIR_FREE(result);
>      return py_retval;
>  }
> @@ -116,7 +116,7 @@ libvirt_qemu_virDomainQemuAgentCommand(PyObject *self ATTRIBUTE_UNUSED, PyObject
>      if (!result)
>          return VIR_PY_NONE;
>
> -    py_retval = PyString_FromString(result);
> +    py_retval = libvirt_constcharPtrWrap(result);
>      VIR_FREE(result);
>      return py_retval;
>  }
> --
> 1.8.3.1
>
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

ACK.

-- 
Doug Goldstein

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]