By the way, why do we need to strlen() the target buffer when strlcpy
already reports the length?  (You could argue that there is a difference
if the string is truncated ... but surely we don't care about that case)
I propose the attached.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 714260ddb13b440db68f4e6db1f8aef0a0baba0a Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvhe...@alvh.no-ip.org>
Date: Fri, 15 Jun 2018 11:48:53 -0400
Subject: [PATCH] no need for separate strlen

---
 src/backend/access/rmgrdesc/xactdesc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/backend/access/rmgrdesc/xactdesc.c 
b/src/backend/access/rmgrdesc/xactdesc.c
index 6d5ebd475b..da3a296e99 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -104,8 +104,8 @@ ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, 
xl_xact_parsed_commit *pars
 
                if (parsed->xinfo & XACT_XINFO_HAS_GID)
                {
-                       strlcpy(parsed->twophase_gid, data, 
sizeof(parsed->twophase_gid));
-                       data += strlen(data) + 1;
+                       data += strlcpy(parsed->twophase_gid, data,
+                                                       
sizeof(parsed->twophase_gid)) + 1;
                }
        }
 
@@ -188,8 +188,8 @@ ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, 
xl_xact_parsed_abort *parsed)
 
                if (parsed->xinfo & XACT_XINFO_HAS_GID)
                {
-                       strlcpy(parsed->twophase_gid, data, 
sizeof(parsed->twophase_gid));
-                       data += strlen(data) + 1;
+                       data += strlcpy(parsed->twophase_gid, data,
+                                                       
sizeof(parsed->twophase_gid)) + 1;
                }
        }
 
-- 
2.11.0

Reply via email to