diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-06-16 15:51:24 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-06-16 16:27:11 +0200 |
commit | 56d6fc58c930e4eeb5b5b7f713e94361451fdef2 (patch) | |
tree | 5aff4ecbceffbb27fa2e38f4363ec34fe978e2c8 | |
parent | 552ad76180d05a665fc32216eeed5c752be41db1 (diff) | |
download | python-systemd-56d6fc58c930e4eeb5b5b7f713e94361451fdef2.tar.gz |
id128: do not copy the id128 buffer bytes
There doesn't seem to be any particular need to do this.
Also remove unused uuid variable.
-rw-r--r-- | systemd/id128.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/systemd/id128.c b/systemd/id128.c index 291dede..1f525be 100644 --- a/systemd/id128.c +++ b/systemd/id128.c @@ -107,11 +107,10 @@ helper(get_machine) helper(get_boot) static PyObject *get_machine_app_specific(PyObject *self, PyObject *args) { - sd_id128_t app_id, machine_id; - int r; + sd_id128_t machine_id; Py_buffer buffer; - _cleanup_Py_DECREF_ PyObject - *uuid = NULL, *uuid_bytes = NULL; + _cleanup_Py_DECREF_ PyObject *uuid_bytes = NULL; + int r; uuid_bytes = PyObject_GetAttrString(args, "bytes"); if (!uuid_bytes) @@ -121,15 +120,13 @@ static PyObject *get_machine_app_specific(PyObject *self, PyObject *args) { if (r == -1) return NULL; - if (buffer.len != sizeof(app_id.bytes)) { + if (buffer.len != sizeof(sd_id128_t)) { PyBuffer_Release(&buffer); return NULL; } - memcpy(app_id.bytes, buffer.buf, sizeof(app_id.bytes)); + r = sd_id128_get_machine_app_specific(*(sd_id128_t*)buffer.buf, &machine_id); PyBuffer_Release(&buffer); - - r = sd_id128_get_machine_app_specific(app_id, &machine_id); if (r < 0) { errno = -r; return PyErr_SetFromErrno(PyExc_IOError); |