[PATCH v2 3/8] src: Use VIR_STRDUP() wherever possible

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

 



virStrcpy() and friends are useful when the destination
buffer has already been allocated, eg. as part of a struct;
if we have to allocate it on the spot, VIR_STRDUP() is a
better choice.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/remote/remote_daemon_dispatch.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 4a93f09a7d..e62ebfb596 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -2309,9 +2309,7 @@ remoteDispatchDomainGetSecurityLabelList(virNetServerPtr server ATTRIBUTE_UNUSED
     for (i = 0; i < len; i++) {
         size_t label_len = strlen(seclabels[i].label) + 1;
         remote_domain_get_security_label_ret *cur = &ret->labels.labels_val[i];
-        if (VIR_ALLOC_N(cur->label.label_val, label_len) < 0)
-            goto cleanup;
-        if (virStrcpy(cur->label.label_val, seclabels[i].label, label_len) == NULL) {
+        if (VIR_STRDUP(cur->label.label_val, seclabels[i].label) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("failed to copy security label"));
             goto cleanup;
-- 
2.17.1

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

  Powered by Linux