[libvirt] [PATCH 05/11] util: drop the stpcpy gnulib module

Daniel P. Berrangé posted 11 patches 6 years, 2 months ago
[libvirt] [PATCH 05/11] util: drop the stpcpy gnulib module
Posted by Daniel P. Berrangé 6 years, 2 months ago
stpcpy returns a pointer to the end of the string just copied
which in theory makes it easier to then copy another string
after it. We only use stpcpy in one place though and that
is trivially rewritten to avoid stpcpy with no less in code
clarity or efficiency.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 bootstrap.conf      | 1 -
 src/util/virerror.c | 5 +++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 9964231bb7..9ca1e6ddd7 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -96,7 +96,6 @@ snprintf
 socket
 stat-time
 stdarg
-stpcpy
 strchrnul
 strdup-posix
 strndup
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 77f76a9abf..3bb9d1d32c 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -1367,8 +1367,9 @@ void virReportSystemErrorFull(int domcode,
 
         size_t len = strlen(errnoDetail);
         if (0 <= n && n + 2 + len < sizeof(msgDetailBuf)) {
-          char *p = msgDetailBuf + n;
-          stpcpy(stpcpy(p, ": "), errnoDetail);
+          strcpy(msgDetailBuf + n, ": ");
+          n += 2;
+          strcpy(msgDetailBuf + n, errnoDetail);
           msgDetail = msgDetailBuf;
         }
     }
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 05/11] util: drop the stpcpy gnulib module
Posted by Ján Tomko 6 years, 2 months ago
On Thu, Oct 03, 2019 at 02:53:12PM +0100, Daniel P. Berrangé wrote:
>stpcpy returns a pointer to the end of the string just copied
>which in theory makes it easier to then copy another string
>after it. We only use stpcpy in one place though and that
>is trivially rewritten to avoid stpcpy with no less in code

s/less/loss/

>clarity or efficiency.
>
>Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
>---
> bootstrap.conf      | 1 -
> src/util/virerror.c | 5 +++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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